1
0
Fork 0
Commit Graph

28 Commits (877b5691f27a1aec0d9b53095a323e45c30069e2)

Author SHA1 Message Date
Eric Biggers 877b5691f2 crypto: shash - remove shash_desc::flags
The flags field in 'struct shash_desc' never actually does anything.
The only ostensibly supported flag is CRYPTO_TFM_REQ_MAY_SLEEP.
However, no shash algorithm ever sleeps, making this flag a no-op.

With this being the case, inevitably some users who can't sleep wrongly
pass MAY_SLEEP.  These would all need to be fixed if any shash algorithm
actually started sleeping.  For example, the shash_ahash_*() functions,
which wrap a shash algorithm with the ahash API, pass through MAY_SLEEP
from the ahash API to the shash API.  However, the shash functions are
called under kmap_atomic(), so actually they're assumed to never sleep.

Even if it turns out that some users do need preemption points while
hashing large buffers, we could easily provide a helper function
crypto_shash_update_large() which divides the data into smaller chunks
and calls crypto_shash_update() and cond_resched() for each chunk.  It's
not necessary to have a flag in 'struct shash_desc', nor is it necessary
to make individual shash algorithms aware of this at all.

Therefore, remove shash_desc::flags, and document that the
crypto_shash_*() functions can be called from any context.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2019-04-25 15:38:12 +08:00
Kees Cook db20f570e1 lib80211: Remove VLA usage of skcipher
In the quest to remove all stack VLA usage from the kernel[1], this
replaces struct crypto_skcipher and SKCIPHER_REQUEST_ON_STACK() usage
with struct crypto_sync_skcipher and SYNC_SKCIPHER_REQUEST_ON_STACK(),
which uses a fixed stack size.

[1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com

Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-09-28 12:46:07 +08:00
Kees Cook 2f675c91ee staging: rtl8192u: ieee80211: Convert from ahash to shash
This is an identical change to the wireless/lib80211 of the same name.
In preparing to remove all stack VLA usage from the kernel[1], this
removes the discouraged use of AHASH_REQUEST_ON_STACK in favor of
the smaller SHASH_DESC_ON_STACK by converting from ahash-wrapped-shash
to direct shash. By removing a layer of indirection this both improves
performance and reduces stack usage. The stack allocation will be made
a fixed size in a later patch to the crypto subsystem.

[1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-29 10:05:24 +02:00
Jia-Ju Bai 2accd50e15 staging: rtl8192u: Replace GFP_ATOMIC with GFP_KERNEL in ieee80211_tkip_init
ieee80211_tkip_init() is never called in atomic context.

ieee80211_tkip_init() is only set as ".init" in
struct ieee80211_crypto_ops.
The call chains ending up at "->init" function are:
[1] ->init() <- ieee80211_wpa_set_encryption() <-
    ieee80211_wpa_supplicant_ioctl()
[2] ->init() <- ieee80211_wx_set_encode_ext_rsl() <-
    r8192_wx_set_enc_ext()
[3] ->init() <- ieee80211_wx_set_encode_rsl() <-
    r8192_wx_set_enc()

ieee80211_wpa_supplicant_ioctl(), r8192_wx_set_enc_ext() and
r8192_wx_set_enc() call mutex_lock(), which indicates these functions
are not called in atomic context.

Despite never getting called from atomic context,
ieee80211_tkip_init() calls kzalloc() with GFP_ATOMIC,
which does not sleep for allocation.
GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL,
which can sleep and improve the possibility of sucessful allocation.

This is found by a static analysis tool named DCNS written by myself.
And I also manually check it.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-23 15:51:34 +02:00
Suniel Mahesh 55031da457 staging: rtl8192u: Fix type mismatch warnings reported by sparse
Mk16_le() is an inline function returning le16_to_cpu()
which is causing type mismatch warnings. Removed Mk16_le() and
replaced it with le16_to_cpu() with appropriate argument type as
suggested by Greg K-H.

Signed-off-by: Suniel Mahesh <suniel.spartan@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-05-15 12:51:20 +02:00
simran singhal 3956c8ac39 staging: rtl8192u: Clean up tests if NULL returned on failure
Some functions like kmalloc/kzalloc return NULL on failure.
When NULL represents failure, !x is commonly used.

This was done using Coccinelle:
@@
expression *e;
identifier l1;
@@

e = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\)(...);
...
- e == NULL
+ !e

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-09 18:19:07 +01:00
simran singhal 20f896c4db staging: rtl8192u: Fixing no new typedef warning
This patch fixes following checkpatch.pl
warnings: WARNING:do not add new typedefs.
All the related files have been modified.

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-12 13:48:33 +01:00
Arnd Bergmann 5d43dfdba0 staging: rtl8192x: fix bogus maybe-uninitialized warning
The rtllib_rx_extract_addr() is supposed to set up the mac addresses
for four possible cases, based on two bits of input data. For
some reason, gcc decides that it's possible that none of the these
four cases apply and the addresses remain uninitialized:

drivers/staging/rtl8192e/rtllib_rx.c: In function ‘rtllib_rx_InfraAdhoc’:
include/linux/etherdevice.h:316:61: error: ‘*((void *)&dst+4)’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
drivers/staging/rtl8192e/rtllib_rx.c:1318:5: note: ‘*((void *)&dst+4)’ was declared here
ded from /git/arm-soc/drivers/staging/rtl8192e/rtllib_rx.c:40:0:
include/linux/etherdevice.h:316:36: error: ‘dst’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
drivers/staging/rtl8192e/rtllib_rx.c:1318:5: note: ‘dst’ was declared here

This warning is clearly nonsense, but changing the last case into
'default' makes it obvious to the compiler too, which avoids the
warning and probably leads to better object code too.

As the same warning appears in other files that have the exact
same code, I'm fixing it in both rtl8192e and rtl8192u, even
though I did not observe it for the latter.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-25 09:40:44 +02:00
Herbert Xu c3a7922718 staging: rtl8192u: Use skcipher and ahash
This patch replaces uses of blkcipher with skcipher, and the long
obsolete hash interface with ahash.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-01-27 20:35:51 +08:00
Kurt Kanzenbach e3cc3136df Staging: rtl8192u: ieee80211: added missing blank lines
This patch resolves the following checkpatch warnings:
  - WARNING: Missing a blank line after declarations

Signed-off-by: Kurt Kanzenbach <kurt@kmk-computers.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-29 09:10:55 +09:00
Kurt Kanzenbach 0d92e43496 Staging: rtl8192u: ieee80211: removed unnecessary braces
This patch fixes the following checkpatch warning:
  - WARNING: braces {} are not necessary for single statement blocks

Signed-off-by: Kurt Kanzenbach <kurt@kmk-computers.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-29 09:10:55 +09:00
Kurt Kanzenbach e1cb1af28a Staging: rtl8192u: ieee80211: corrected block comments
This patch reformats some block comments in order to
match the Linux kernel coding style.

Signed-off-by: Kurt Kanzenbach <kurt@kmk-computers.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-29 09:10:55 +09:00
Kurt Kanzenbach 7bdb7d554e Staging: rtl8192u: ieee80211: corrected indent
This patch corrects the indentation in five instances in the
ieee80211_crypt_tkip.c file.

Signed-off-by: Kurt Kanzenbach <kurt@kmk-computers.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-29 09:10:55 +09:00
Kurt Kanzenbach 65ed40ddea Staging: rtl8192u: ieee80211: added missing spaces after if
This patch fixes the following checkpatch error:
  - ERROR: space required before the open parenthesis '('

Signed-off-by: Kurt Kanzenbach <kurt@kmk-computers.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-29 09:10:55 +09:00
Kurt Kanzenbach a4255e7c92 Staging: rtl8192u: ieee80211: added missing space around '='
This patch fixes the following checkpatch error:
  - ERROR: spaces required around that '='

Signed-off-by: Kurt Kanzenbach <kurt@kmk-computers.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-29 09:10:55 +09:00
Kurt Kanzenbach df58f2b9c8 Staging: rtl8192u: ieee80211: fixed position of else statements
This patch fixes the following checkpatch error:
  - ERROR: else should follow close brace '}'

Signed-off-by: Kurt Kanzenbach <kurt@kmk-computers.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-29 09:10:55 +09:00
Kurt Kanzenbach 840a121e06 Staging: rtl8192u: ieee80211: fixed open brace positions
This patch fixes the following checkpatch error:
  - ERROR: that open brace { should be on the previous line

Signed-off-by: Kurt Kanzenbach <kurt@kmk-computers.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-10-29 09:10:55 +09:00
Paul Gortmaker 5c2918a5ba rtl8192u: don't trample on <linux/ieee80211.h> struct namespace
In order to start reducing the duplicated code/constants/macros in this
driver, we need to include <linux/ieee80211.h> to provide the defacto
versions.  However this driver has structs with the same name as the
ones in the main include, so namespace collision prevents us from doing
step #1.

Since the structs actually differ in their respective fields, we can't
simply delete the local ones without impacting the runtime; a conversion
to use the global ones can be considered at a later date if desired.

Rename the ones here with a vendor specific prefix so that we won't have
the namespace collision, and hence can continue on with the cleanup.

Automated conversion done with:

    for i in `find . -name '*.[ch]'` ; do \
      sed -i 's/struct ieee80211_hdr/struct rtl_80211_hdr/g' $i ; \
    done

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-05-08 09:24:13 +02:00
Dilek Uzulmez 9a4ed8c506 Staging: rtl8192u: Added #include <linux/string.h> instead of <asm/string.h>
The following patch fixes the checkpatch.pl warning:
WARNING: Use #include <linux/string.h> instead of #include <asm/string.h>

Signed-off-by: Dilek Uzulmez <dilekuzulmez@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-09 13:36:22 +01:00
Navya Sri Nizamkari 45466a5c93 staging: rtl8192u: Remove commented header.
This patch removes the commented header <linux/config.h>
as it is not used in modern linux systems.

Signed-off-by: Navya Sri Nizamkari <navyasri.tech@gmail.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-02-26 13:37:34 -08:00
Joe Perches f8628a47ba staging: Convert __FUNCTION__ to __func__
Use the normal mechanism for emitting a function name.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-25 11:05:07 -07:00
Xenia Ragiadakou 8acfd58a4d STAGING: rtl8192u/ieee80211: fix checkpatch error about pointer position in ieee80211_crypt_tkip.c
This patch fixes the pointer position in ieee80211_crypt_tkip.c
to meet the kernel coding style conventions.

Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-05-13 07:14:50 -07:00
Jesper Juhl 41134db17a Remove unneeded version.h includes from drivers/staging/rtl*/
It was pointed out by 'make versioncheck' that some includes of
linux/version.h are not needed in drivers/staging/rtl8187se/,
drivers/staging/rtl8192e/, drivers/staging/rtl8192u/ &
drivers/staging/rtl8712/.
This patch removes them.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-07-05 10:39:40 -07:00
Julia Lawall 7a6cb0d549 Staging: Use kcalloc or kzalloc
Use kcalloc or kzalloc rather than the combination of kmalloc and memset.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression x,y,flags;
statement S;
type T;
@@

x =
-   kmalloc
+   kcalloc
           (
-           y * sizeof(T),
+           y, sizeof(T),
                flags);
 if (x == NULL) S
-memset(x, 0, y * sizeof(T));

@@
expression x,size,flags;
statement S;
@@

-x = kmalloc(size,flags);
+x = kzalloc(size,flags);
 if (x == NULL) S
-memset(x, 0, size);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
2010-05-14 14:02:56 -07:00
Joe Perches 0ee9f67c40 Staging: rtl8187x: Use %pM for mac address output
Uncompiled.  Doesn't currently build anyway.

Converted MAC_FMT to %pM
Converted some %02x%02x%02x%02x%02x%02x to %pm
Converted MAC_ARG to direct use
Removed MAC_FMT and MAC_ARG macros

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-03-03 16:42:29 -08:00
Mauro Carvalho Chehab e406322b4b Staging: rtl8192u: remove bad whitespaces
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-12-11 12:23:22 -08:00
Mauro Carvalho Chehab f61fb9356d Staging: rtl8192u: make it compile
Add it to staging Kbuild and fixes some API differences that prevents
compilation.

It seems that the ieee80211 stack is very close to rtl8192su one.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-12-11 12:23:22 -08:00
Jerry Chuang 8fc8598e61 Staging: Added Realtek rtl8192u driver to staging
Add Realtek linux driver for rtl8192u as provided by Realtek

rtl8192u_linux_2.6.0006.1031.2008.tar.gz, send to me C/C staging ML.

This version won't compile against upstream, doesn't follow
Linux CodingStyle and has their own ieee80211 stack.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-12-11 12:23:22 -08:00