* [PATCH] staging: rtl8192u: ieee80211: Silence sparse warning
@ 2015-04-19 20:43 Gaston Gonzalez
2015-04-20 8:24 ` Dan Carpenter
0 siblings, 1 reply; 5+ messages in thread
From: Gaston Gonzalez @ 2015-04-19 20:43 UTC (permalink / raw)
To: gregkh, navyasri.tech, joe, arnd; +Cc: devel, linux-kernel, Gaston Gonzalez
Silence the following sparse warning:
drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c:184:16: warning: cast to restricted __le16
Signed-off-by: Gaston Gonzalez <gascoar@gmail.com>
---
.../rtl8192u/ieee80211/ieee80211_crypt_tkip.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
index e815c81..efa6983 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
@@ -179,1 +179,1 @@ static inline u16 Mk16(u8 hi, u8 lo)
}
-static inline u16 Mk16_le(u16 *v)
+static inline u16 Mk16_le(__le16 *v)
{
return le16_to_cpu(*v);
}
@@ -270,1 +270,1 @@ static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
PPK[5] = TTAK[4] + IV16;
/* Step 2 - 96-bit bijective mixing using S-box */
- PPK[0] += _S_(PPK[5] ^ Mk16_le((u16 *) &TK[0]));
- PPK[1] += _S_(PPK[0] ^ Mk16_le((u16 *) &TK[2]));
- PPK[2] += _S_(PPK[1] ^ Mk16_le((u16 *) &TK[4]));
- PPK[3] += _S_(PPK[2] ^ Mk16_le((u16 *) &TK[6]));
- PPK[4] += _S_(PPK[3] ^ Mk16_le((u16 *) &TK[8]));
- PPK[5] += _S_(PPK[4] ^ Mk16_le((u16 *) &TK[10]));
-
- PPK[0] += RotR1(PPK[5] ^ Mk16_le((u16 *) &TK[12]));
- PPK[1] += RotR1(PPK[0] ^ Mk16_le((u16 *) &TK[14]));
+ PPK[0] += _S_(PPK[5] ^ Mk16_le((__le16 *) &TK[0]));
+ PPK[1] += _S_(PPK[0] ^ Mk16_le((__le16 *) &TK[2]));
+ PPK[2] += _S_(PPK[1] ^ Mk16_le((__le16 *) &TK[4]));
+ PPK[3] += _S_(PPK[2] ^ Mk16_le((__le16 *) &TK[6]));
+ PPK[4] += _S_(PPK[3] ^ Mk16_le((__le16 *) &TK[8]));
+ PPK[5] += _S_(PPK[4] ^ Mk16_le((__le16 *) &TK[10]));
+
+ PPK[0] += RotR1(PPK[5] ^ Mk16_le((__le16 *) &TK[12]));
+ PPK[1] += RotR1(PPK[0] ^ Mk16_le((__le16 *) &TK[14]));
PPK[2] += RotR1(PPK[1]);
PPK[3] += RotR1(PPK[2]);
PPK[4] += RotR1(PPK[3]);
@@ -289,4 +289,4 @@ static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
WEPSeed[0] = Hi8(IV16);
WEPSeed[1] = (Hi8(IV16) | 0x20) & 0x7F;
WEPSeed[2] = Lo8(IV16);
- WEPSeed[3] = Lo8((PPK[5] ^ Mk16_le((u16 *) &TK[0])) >> 1);
+ WEPSeed[3] = Lo8((PPK[5] ^ Mk16_le((__le16 *) &TK[0])) >> 1);
#ifdef __BIG_ENDIAN
{
--
2.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] staging: rtl8192u: ieee80211: Silence sparse warning
2015-04-19 20:43 [PATCH] staging: rtl8192u: ieee80211: Silence sparse warning Gaston Gonzalez
@ 2015-04-20 8:24 ` Dan Carpenter
2015-04-25 22:44 ` Gaston Gonzalez
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2015-04-20 8:24 UTC (permalink / raw)
To: Gaston Gonzalez; +Cc: gregkh, navyasri.tech, joe, arnd, devel, linux-kernel
On Sun, Apr 19, 2015 at 05:43:51PM -0300, Gaston Gonzalez wrote:
> Silence the following sparse warning:
>
> drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c:184:16: warning: cast to restricted __le16
>
We have a tkip_mixing_phase2() function in net/mac80211/tkip.c. That's
probably the better thing.
> Signed-off-by: Gaston Gonzalez <gascoar@gmail.com>
> ---
> .../rtl8192u/ieee80211/ieee80211_crypt_tkip.c | 22 +++++++++++-----------
> 1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
> index e815c81..efa6983 100644
> --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
> +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
> @@ -179,1 +179,1 @@ static inline u16 Mk16(u8 hi, u8 lo)
> }
>
>
> -static inline u16 Mk16_le(u16 *v)
> +static inline u16 Mk16_le(__le16 *v)
> {
> return le16_to_cpu(*v);
> }
Mk16_le() is a bad function name and as we can see from tkip.c it just
duplicates get_unaligned_le16(). Better to make TK void pointer instead
of a u8 pointer (because it doesn't point to u8s so we have to cast it
every time we use it). This is another trick I learned from tkip.c.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] staging: rtl8192u: ieee80211: Silence sparse warning
2015-04-20 8:24 ` Dan Carpenter
@ 2015-04-25 22:44 ` Gaston Gonzalez
2015-04-27 10:12 ` Dan Carpenter
0 siblings, 1 reply; 5+ messages in thread
From: Gaston Gonzalez @ 2015-04-25 22:44 UTC (permalink / raw)
To: Dan Carpenter; +Cc: gregkh, navyasri.tech, joe, arnd, devel, linux-kernel
On 20/04/15 05:24, Dan Carpenter wrote:
> Mk16_le() is a bad function name and as we can see from tkip.c it just
> duplicates get_unaligned_le16(). Better to make TK void pointer instead
> of a u8 pointer (because it doesn't point to u8s so we have to cast it
> every time we use it). This is another trick I learned from tkip.c.
Ok. Could I just remove Mk16_le() and use get_unaligned_le16() instead?
I built rtl8192u/ using get_unaligned_le16() for the following lines and
I didn't get any warning:
+#include <asm/unaligned.h>
- PPK[0] += _S_(PPK[5] ^ Mk16_le((u16 *) &TK[0]));
- PPK[0] += _S_(PPK[5] ^ Mk16_le((u16 *) &TK[0]));
- PPK[1] += _S_(PPK[0] ^ Mk16_le((u16 *) &TK[2]));
- PPK[2] += _S_(PPK[1] ^ Mk16_le((u16 *) &TK[4]));
- PPK[3] += _S_(PPK[2] ^ Mk16_le((u16 *) &TK[6]));
- PPK[4] += _S_(PPK[3] ^ Mk16_le((u16 *) &TK[8]));
- PPK[5] += _S_(PPK[4] ^ Mk16_le((u16 *) &TK[10]));
-
- PPK[0] += RotR1(PPK[5] ^ Mk16_le((u16 *) &TK[12]));
- PPK[1] += RotR1(PPK[0] ^ Mk16_le((u16 *) &TK[14]));
+ PPK[0] += _S_(PPK[5] ^ get_unaligned_le16(TK + 0));
+ PPK[1] += _S_(PPK[0] ^ get_unaligned_le16(TK + 2));
+ PPK[2] += _S_(PPK[1] ^ get_unaligned_le16(TK + 4));
+ PPK[3] += _S_(PPK[2] ^ get_unaligned_le16(TK + 6));
+ PPK[4] += _S_(PPK[3] ^ get_unaligned_le16(TK + 8));
+ PPK[5] += _S_(PPK[4] ^ get_unaligned_le16(TK + 10));
+
+ PPK[0] += RotR1(PPK[5] ^ get_unaligned_le16(TK + 12));
+ PPK[1] += RotR1(PPK[0] ^ get_unaligned_le16(TK + 14));
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: rtl8192u: ieee80211: Silence sparse warning
2015-04-25 22:44 ` Gaston Gonzalez
@ 2015-04-27 10:12 ` Dan Carpenter
2015-05-07 3:09 ` Gaston Gonzalez
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2015-04-27 10:12 UTC (permalink / raw)
To: Gaston Gonzalez; +Cc: devel, arnd, gregkh, linux-kernel, joe, navyasri.tech
Can't we just export the tkip.c function?
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: rtl8192u: ieee80211: Silence sparse warning
2015-04-27 10:12 ` Dan Carpenter
@ 2015-05-07 3:09 ` Gaston Gonzalez
0 siblings, 0 replies; 5+ messages in thread
From: Gaston Gonzalez @ 2015-05-07 3:09 UTC (permalink / raw)
To: Dan Carpenter; +Cc: devel, arnd, gregkh, linux-kernel, joe, navyasri.tech
On 27/04/15 07:12, Dan Carpenter wrote:
> Can't we just export the tkip.c function?
>
> regards,
> dan carpenter
>
Hi Dan,
(sorry for the delayed response)
The inputs of the two implementations of tkip_mixing_phase2() differ in
one parameter:
- ieee80211_crypt_tkip.c expects 'const u16 *TTAK'
- tkip.c expects 'struct tkip_ctx *ctx'
tkip_mixing_phase2() is called two times in ieee80211_crypt_tkip.c:
git grep tkip_mixing_phase2 drivers/staging/rtl8192u/ieee80211/
drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c:static void
tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c:
tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16);
drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c:
tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16);
tkey is a 'struct ieee80211_tkip_data', which differs from tkip_ctx
structure. So in the case of exporting the tkip.c function, we would
need to add 'struct tkip_ctx' definition, and not just change the
function input definition.
The only member of tkip_ctx structure used in tkip_mixing_phase2() is
p1k, which is the equivalent of TTAK array in ieee80211_crypt_tkip.c .
Thus - I'm new to this so I may be missing something - one way would be
to just add the tkip_ctx structure definition in ieee80211_crypt_tkip.c.
The down side of doing this is that there would be some parameters
defined twice in two different structures: u32 iv32, u16 iv16, u16
p1k[5], u32 p1k_iv32
Another way would be split ieee80211_tkip_data structure in struct
tkip_ctx on one side, and leave the rest of the members on the original
structure. This would avoid to duplicate the members definitions, but I
guess that approach could broke other things...
As I said, I'm new to this so I may be missing something, maybe a
different approach?
One detail: although not used in the function, 'enum
ieee80211_internal_tkip_state state' is not defined in 'struct
ieee80211_tkip_data', thus in any case that definition would have to be
added.
regards,
Gaston
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-05-07 3:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-19 20:43 [PATCH] staging: rtl8192u: ieee80211: Silence sparse warning Gaston Gonzalez
2015-04-20 8:24 ` Dan Carpenter
2015-04-25 22:44 ` Gaston Gonzalez
2015-04-27 10:12 ` Dan Carpenter
2015-05-07 3:09 ` Gaston Gonzalez
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox