* [PATCH 1/3] staging: rtl8188eu: Use existing arc4 implementation
@ 2021-04-10 11:55 ` Christophe JAILLET
0 siblings, 0 replies; 13+ messages in thread
From: Christophe JAILLET @ 2021-04-10 11:54 UTC (permalink / raw)
To: Larry.Finger, gregkh
Cc: linux-staging, linux-kernel, kernel-janitors, Christophe JAILLET
Use functions provided by <crypto/arc4.h> instead of hand writing them.
The implementations are slightly different, but are equivalent. It has
been checked with a test program which compares the output of the 2 sets of
functions.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/staging/rtl8188eu/core/rtw_security.c | 80 +++----------------
1 file changed, 11 insertions(+), 69 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c
index 617f89842c81..61e3eb0a4791 100644
--- a/drivers/staging/rtl8188eu/core/rtw_security.c
+++ b/drivers/staging/rtl8188eu/core/rtw_security.c
@@ -6,6 +6,7 @@
******************************************************************************/
#define _RTW_SECURITY_C_
+#include <crypto/arc4.h>
#include <osdep_service.h>
#include <drv_types.h>
#include <wifi.h>
@@ -16,65 +17,6 @@
#define CRC32_POLY 0x04c11db7
-struct arc4context {
- u32 x;
- u32 y;
- u8 state[256];
-};
-
-static void arcfour_init(struct arc4context *parc4ctx, u8 *key, u32 key_len)
-{
- u32 t, u;
- u32 keyindex;
- u32 stateindex;
- u8 *state;
- u32 counter;
-
- state = parc4ctx->state;
- parc4ctx->x = 0;
- parc4ctx->y = 0;
- for (counter = 0; counter < 256; counter++)
- state[counter] = (u8)counter;
- keyindex = 0;
- stateindex = 0;
- for (counter = 0; counter < 256; counter++) {
- t = state[counter];
- stateindex = (stateindex + key[keyindex] + t) & 0xff;
- u = state[stateindex];
- state[stateindex] = (u8)t;
- state[counter] = (u8)u;
- if (++keyindex >= key_len)
- keyindex = 0;
- }
-}
-
-static u32 arcfour_byte(struct arc4context *parc4ctx)
-{
- u32 x;
- u32 y;
- u32 sx, sy;
- u8 *state;
-
- state = parc4ctx->state;
- x = (parc4ctx->x + 1) & 0xff;
- sx = state[x];
- y = (sx + parc4ctx->y) & 0xff;
- sy = state[y];
- parc4ctx->x = x;
- parc4ctx->y = y;
- state[y] = (u8)sx;
- state[x] = (u8)sy;
- return state[(sx + sy) & 0xff];
-}
-
-static void arcfour_encrypt(struct arc4context *parc4ctx, u8 *dest, u8 *src, u32 len)
-{
- u32 i;
-
- for (i = 0; i < len; i++)
- dest[i] = src[i] ^ (unsigned char)arcfour_byte(parc4ctx);
-}
-
static int bcrc32initialized;
static u32 crc32_table[256];
@@ -564,7 +506,7 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe)
u8 ttkey[16];
u8 crc[4];
u8 hw_hdr_offset = 0;
- struct arc4context mycontext;
+ struct arc4_ctx mycontext;
int curfragnum, length;
u8 *pframe, *payload, *iv, *prwskey;
@@ -614,15 +556,15 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe)
pattrib->iv_len, pattrib->icv_len));
*((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/
- arcfour_init(&mycontext, rc4key, 16);
- arcfour_encrypt(&mycontext, payload, payload, length);
- arcfour_encrypt(&mycontext, payload + length, crc, 4);
+ arc4_setkey(&mycontext, rc4key, 16);
+ arc4_crypt(&mycontext, payload, payload, length);
+ arc4_crypt(&mycontext, payload + length, crc, 4);
} else {
length = pxmitpriv->frag_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len;
*((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/
- arcfour_init(&mycontext, rc4key, 16);
- arcfour_encrypt(&mycontext, payload, payload, length);
- arcfour_encrypt(&mycontext, payload + length, crc, 4);
+ arc4_setkey(&mycontext, rc4key, 16);
+ arc4_crypt(&mycontext, payload, payload, length);
+ arc4_crypt(&mycontext, payload + length, crc, 4);
pframe += pxmitpriv->frag_len;
pframe = (u8 *)round_up((size_t)(pframe), 4);
@@ -644,7 +586,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, struct recv_frame *precvframe)
u8 rc4key[16];
u8 ttkey[16];
u8 crc[4];
- struct arc4context mycontext;
+ struct arc4_ctx mycontext;
int length;
u8 *pframe, *payload, *iv, *prwskey;
union pn48 dot11txpn;
@@ -685,8 +627,8 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, struct recv_frame *precvframe)
/* 4 decrypt payload include icv */
- arcfour_init(&mycontext, rc4key, 16);
- arcfour_encrypt(&mycontext, payload, payload, length);
+ arc4_setkey(&mycontext, rc4key, 16);
+ arc4_crypt(&mycontext, payload, payload, length);
*((__le32 *)crc) = getcrc32(payload, length - 4);
--
2.27.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 1/3] staging: rtl8188eu: Use existing arc4 implementation
@ 2021-04-10 11:55 ` Christophe JAILLET
0 siblings, 0 replies; 13+ messages in thread
From: Christophe JAILLET @ 2021-04-10 11:55 UTC (permalink / raw)
To: gregkh; +Cc: linux-staging, linux-kernel, kernel-janitors, Christophe JAILLET
Use functions provided by <crypto/arc4.h> instead of hand writing them.
The implementations are slightly different, but are equivalent. It has
been checked with a test program which compares the output of the 2 sets of
functions.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/staging/rtl8188eu/core/rtw_security.c | 80 +++----------------
1 file changed, 11 insertions(+), 69 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c
index 617f89842c81..61e3eb0a4791 100644
--- a/drivers/staging/rtl8188eu/core/rtw_security.c
+++ b/drivers/staging/rtl8188eu/core/rtw_security.c
@@ -6,6 +6,7 @@
******************************************************************************/
#define _RTW_SECURITY_C_
+#include <crypto/arc4.h>
#include <osdep_service.h>
#include <drv_types.h>
#include <wifi.h>
@@ -16,65 +17,6 @@
#define CRC32_POLY 0x04c11db7
-struct arc4context {
- u32 x;
- u32 y;
- u8 state[256];
-};
-
-static void arcfour_init(struct arc4context *parc4ctx, u8 *key, u32 key_len)
-{
- u32 t, u;
- u32 keyindex;
- u32 stateindex;
- u8 *state;
- u32 counter;
-
- state = parc4ctx->state;
- parc4ctx->x = 0;
- parc4ctx->y = 0;
- for (counter = 0; counter < 256; counter++)
- state[counter] = (u8)counter;
- keyindex = 0;
- stateindex = 0;
- for (counter = 0; counter < 256; counter++) {
- t = state[counter];
- stateindex = (stateindex + key[keyindex] + t) & 0xff;
- u = state[stateindex];
- state[stateindex] = (u8)t;
- state[counter] = (u8)u;
- if (++keyindex >= key_len)
- keyindex = 0;
- }
-}
-
-static u32 arcfour_byte(struct arc4context *parc4ctx)
-{
- u32 x;
- u32 y;
- u32 sx, sy;
- u8 *state;
-
- state = parc4ctx->state;
- x = (parc4ctx->x + 1) & 0xff;
- sx = state[x];
- y = (sx + parc4ctx->y) & 0xff;
- sy = state[y];
- parc4ctx->x = x;
- parc4ctx->y = y;
- state[y] = (u8)sx;
- state[x] = (u8)sy;
- return state[(sx + sy) & 0xff];
-}
-
-static void arcfour_encrypt(struct arc4context *parc4ctx, u8 *dest, u8 *src, u32 len)
-{
- u32 i;
-
- for (i = 0; i < len; i++)
- dest[i] = src[i] ^ (unsigned char)arcfour_byte(parc4ctx);
-}
-
static int bcrc32initialized;
static u32 crc32_table[256];
@@ -564,7 +506,7 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe)
u8 ttkey[16];
u8 crc[4];
u8 hw_hdr_offset = 0;
- struct arc4context mycontext;
+ struct arc4_ctx mycontext;
int curfragnum, length;
u8 *pframe, *payload, *iv, *prwskey;
@@ -614,15 +556,15 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe)
pattrib->iv_len, pattrib->icv_len));
*((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/
- arcfour_init(&mycontext, rc4key, 16);
- arcfour_encrypt(&mycontext, payload, payload, length);
- arcfour_encrypt(&mycontext, payload + length, crc, 4);
+ arc4_setkey(&mycontext, rc4key, 16);
+ arc4_crypt(&mycontext, payload, payload, length);
+ arc4_crypt(&mycontext, payload + length, crc, 4);
} else {
length = pxmitpriv->frag_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len;
*((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/
- arcfour_init(&mycontext, rc4key, 16);
- arcfour_encrypt(&mycontext, payload, payload, length);
- arcfour_encrypt(&mycontext, payload + length, crc, 4);
+ arc4_setkey(&mycontext, rc4key, 16);
+ arc4_crypt(&mycontext, payload, payload, length);
+ arc4_crypt(&mycontext, payload + length, crc, 4);
pframe += pxmitpriv->frag_len;
pframe = (u8 *)round_up((size_t)(pframe), 4);
@@ -644,7 +586,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, struct recv_frame *precvframe)
u8 rc4key[16];
u8 ttkey[16];
u8 crc[4];
- struct arc4context mycontext;
+ struct arc4_ctx mycontext;
int length;
u8 *pframe, *payload, *iv, *prwskey;
union pn48 dot11txpn;
@@ -685,8 +627,8 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, struct recv_frame *precvframe)
/* 4 decrypt payload include icv */
- arcfour_init(&mycontext, rc4key, 16);
- arcfour_encrypt(&mycontext, payload, payload, length);
+ arc4_setkey(&mycontext, rc4key, 16);
+ arc4_crypt(&mycontext, payload, payload, length);
*((__le32 *)crc) = getcrc32(payload, length - 4);
--
2.27.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/3] staging: rtl8712: Use existing arc4 implementation
2021-04-10 11:55 ` Christophe JAILLET
(?)
@ 2021-04-10 11:56 ` Christophe JAILLET
2021-04-10 12:09 ` Greg KH
` (2 more replies)
-1 siblings, 3 replies; 13+ messages in thread
From: Christophe JAILLET @ 2021-04-10 11:56 UTC (permalink / raw)
To: Larry.Finger, florian.c.schilhabel, gregkh
Cc: linux-staging, linux-kernel, kernel-janitors, Christophe JAILLET
Use functions provided by <crypto/arc4.h> instead of hand writing them.
The implementations are slightly different, but are equivalent. It has
been checked with a test program which compares the output of the 2 sets of
functions.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/staging/rtl8712/rtl871x_security.c | 118 +++++----------------
1 file changed, 29 insertions(+), 89 deletions(-)
diff --git a/drivers/staging/rtl8712/rtl871x_security.c b/drivers/staging/rtl8712/rtl871x_security.c
index 1c7df65db3c9..b546e2f19620 100644
--- a/drivers/staging/rtl8712/rtl871x_security.c
+++ b/drivers/staging/rtl8712/rtl871x_security.c
@@ -16,6 +16,7 @@
#define _RTL871X_SECURITY_C_
+#include <crypto/arc4.h>
#include <linux/compiler.h>
#include <linux/kernel.h>
#include <linux/errno.h>
@@ -38,66 +39,6 @@
/* =====WEP related===== */
-struct arc4context {
- u32 x;
- u32 y;
- u8 state[256];
-};
-
-static void arcfour_init(struct arc4context *parc4ctx, u8 *key, u32 key_len)
-{
- u32 t, u;
- u32 keyindex;
- u32 stateindex;
- u8 *state;
- u32 counter;
-
- state = parc4ctx->state;
- parc4ctx->x = 0;
- parc4ctx->y = 0;
- for (counter = 0; counter < 256; counter++)
- state[counter] = (u8)counter;
- keyindex = 0;
- stateindex = 0;
- for (counter = 0; counter < 256; counter++) {
- t = state[counter];
- stateindex = (stateindex + key[keyindex] + t) & 0xff;
- u = state[stateindex];
- state[stateindex] = (u8)t;
- state[counter] = (u8)u;
- if (++keyindex >= key_len)
- keyindex = 0;
- }
-}
-
-static u32 arcfour_byte(struct arc4context *parc4ctx)
-{
- u32 x;
- u32 y;
- u32 sx, sy;
- u8 *state;
-
- state = parc4ctx->state;
- x = (parc4ctx->x + 1) & 0xff;
- sx = state[x];
- y = (sx + parc4ctx->y) & 0xff;
- sy = state[y];
- parc4ctx->x = x;
- parc4ctx->y = y;
- state[y] = (u8)sx;
- state[x] = (u8)sy;
- return state[(sx + sy) & 0xff];
-}
-
-static void arcfour_encrypt(struct arc4context *parc4ctx,
- u8 *dest, u8 *src, u32 len)
-{
- u32 i;
-
- for (i = 0; i < len; i++)
- dest[i] = src[i] ^ (unsigned char)arcfour_byte(parc4ctx);
-}
-
static sint bcrc32initialized;
static u32 crc32_table[256];
@@ -151,7 +92,7 @@ static u32 getcrc32(u8 *buf, u32 len)
void r8712_wep_encrypt(struct _adapter *padapter, u8 *pxmitframe)
{ /* exclude ICV */
unsigned char crc[4];
- struct arc4context mycontext;
+ struct arc4_ctx mycontext;
u32 curfragnum, length, keylength, pki;
u8 *pframe, *payload, *iv; /*,*wepkey*/
u8 wepkey[16];
@@ -182,22 +123,22 @@ void r8712_wep_encrypt(struct _adapter *padapter, u8 *pxmitframe)
pattrib->icv_len;
*((__le32 *)crc) = cpu_to_le32(getcrc32(
payload, length));
- arcfour_init(&mycontext, wepkey, 3 + keylength);
- arcfour_encrypt(&mycontext, payload, payload,
- length);
- arcfour_encrypt(&mycontext, payload + length,
- crc, 4);
+ arc4_setkey(&mycontext, wepkey, 3 + keylength);
+ arc4_crypt(&mycontext, payload, payload,
+ length);
+ arc4_crypt(&mycontext, payload + length,
+ crc, 4);
} else {
length = pxmitpriv->frag_len -
pattrib->hdrlen - pattrib->iv_len -
pattrib->icv_len;
*((__le32 *)crc) = cpu_to_le32(getcrc32(
payload, length));
- arcfour_init(&mycontext, wepkey, 3 + keylength);
- arcfour_encrypt(&mycontext, payload, payload,
- length);
- arcfour_encrypt(&mycontext, payload + length,
- crc, 4);
+ arc4_setkey(&mycontext, wepkey, 3 + keylength);
+ arc4_crypt(&mycontext, payload, payload,
+ length);
+ arc4_crypt(&mycontext, payload + length,
+ crc, 4);
pframe += pxmitpriv->frag_len;
pframe = (u8 *)RND4((addr_t)(pframe));
}
@@ -209,7 +150,7 @@ void r8712_wep_decrypt(struct _adapter *padapter, u8 *precvframe)
{
/* exclude ICV */
u8 crc[4];
- struct arc4context mycontext;
+ struct arc4_ctx mycontext;
u32 length, keylength;
u8 *pframe, *payload, *iv, wepkey[16];
u8 keyindex;
@@ -233,8 +174,8 @@ void r8712_wep_decrypt(struct _adapter *padapter, u8 *precvframe)
u.hdr.len - prxattrib->hdrlen - prxattrib->iv_len;
payload = pframe + prxattrib->iv_len + prxattrib->hdrlen;
/* decrypt payload include icv */
- arcfour_init(&mycontext, wepkey, 3 + keylength);
- arcfour_encrypt(&mycontext, payload, payload, length);
+ arc4_setkey(&mycontext, wepkey, 3 + keylength);
+ arc4_crypt(&mycontext, payload, payload, length);
/* calculate icv and compare the icv */
*((__le32 *)crc) = cpu_to_le32(getcrc32(payload, length - 4));
}
@@ -563,7 +504,7 @@ u32 r8712_tkip_encrypt(struct _adapter *padapter, u8 *pxmitframe)
u8 rc4key[16];
u8 ttkey[16];
u8 crc[4];
- struct arc4context mycontext;
+ struct arc4_ctx mycontext;
u32 curfragnum, length;
u8 *pframe, *payload, *iv, *prwskey;
@@ -606,11 +547,11 @@ u32 r8712_tkip_encrypt(struct _adapter *padapter, u8 *pxmitframe)
pattrib->icv_len;
*((__le32 *)crc) = cpu_to_le32(
getcrc32(payload, length));
- arcfour_init(&mycontext, rc4key, 16);
- arcfour_encrypt(&mycontext, payload,
- payload, length);
- arcfour_encrypt(&mycontext, payload +
- length, crc, 4);
+ arc4_setkey(&mycontext, rc4key, 16);
+ arc4_crypt(&mycontext, payload,
+ payload, length);
+ arc4_crypt(&mycontext, payload +
+ length, crc, 4);
} else {
length = pxmitpriv->frag_len -
pattrib->hdrlen -
@@ -618,12 +559,11 @@ u32 r8712_tkip_encrypt(struct _adapter *padapter, u8 *pxmitframe)
pattrib->icv_len;
*((__le32 *)crc) = cpu_to_le32(getcrc32(
payload, length));
- arcfour_init(&mycontext, rc4key, 16);
- arcfour_encrypt(&mycontext, payload,
- payload, length);
- arcfour_encrypt(&mycontext,
- payload + length, crc,
- 4);
+ arc4_setkey(&mycontext, rc4key, 16);
+ arc4_crypt(&mycontext, payload,
+ payload, length);
+ arc4_crypt(&mycontext,
+ payload + length, crc, 4);
pframe += pxmitpriv->frag_len;
pframe = (u8 *)RND4((addr_t)(pframe));
}
@@ -643,7 +583,7 @@ void r8712_tkip_decrypt(struct _adapter *padapter, u8 *precvframe)
u8 rc4key[16];
u8 ttkey[16];
u8 crc[4];
- struct arc4context mycontext;
+ struct arc4_ctx mycontext;
u32 length;
u8 *pframe, *payload, *iv, *prwskey, idx = 0;
union pn48 txpn;
@@ -682,8 +622,8 @@ void r8712_tkip_decrypt(struct _adapter *padapter, u8 *precvframe)
phase2(&rc4key[0], prwskey, (unsigned short *)
&ttkey[0], pnl);
/* 4 decrypt payload include icv */
- arcfour_init(&mycontext, rc4key, 16);
- arcfour_encrypt(&mycontext, payload, payload, length);
+ arc4_setkey(&mycontext, rc4key, 16);
+ arc4_crypt(&mycontext, payload, payload, length);
*((__le32 *)crc) = cpu_to_le32(getcrc32(payload,
length - 4));
}
--
2.27.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 3/3] staging: rtl8712: Use existing arc4 implementation
2021-04-10 11:56 ` [PATCH 3/3] staging: rtl8712: " Christophe JAILLET
@ 2021-04-10 12:09 ` Greg KH
2021-04-10 15:39 ` kernel test robot
2021-04-17 12:57 ` kernel test robot
2 siblings, 0 replies; 13+ messages in thread
From: Greg KH @ 2021-04-10 12:09 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Larry.Finger, florian.c.schilhabel, linux-staging, linux-kernel,
kernel-janitors
On Sat, Apr 10, 2021 at 01:56:57PM +0200, Christophe JAILLET wrote:
> Use functions provided by <crypto/arc4.h> instead of hand writing them.
>
> The implementations are slightly different, but are equivalent. It has
> been checked with a test program which compares the output of the 2 sets of
> functions.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
I can not see patch 2/3 of this series, what happened to it?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 2/3] staging: rtl8723bs: Use existing arc4 implementation
2021-04-10 11:55 ` Christophe JAILLET
(?)
(?)
@ 2021-04-10 13:35 ` Christophe JAILLET
2021-04-10 15:25 ` kernel test robot
2021-04-12 9:34 ` Greg KH
-1 siblings, 2 replies; 13+ messages in thread
From: Christophe JAILLET @ 2021-04-10 13:35 UTC (permalink / raw)
To: gregkh; +Cc: linux-staging, linux-kernel, kernel-janitors, Christophe JAILLET
Use functions provided by <crypto/arc4.h> instead of hand writing them.
The implementations are slightly different, but are equivalent. It has
been checked with a test program which compares the output of the 2 sets of
functions.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/staging/rtl8723bs/core/rtw_security.c | 101 ++++--------------
1 file changed, 21 insertions(+), 80 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c
index 9587d89a6b24..86949a65e96f 100644
--- a/drivers/staging/rtl8723bs/core/rtw_security.c
+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
@@ -6,6 +6,7 @@
******************************************************************************/
#define _RTW_SECURITY_C_
+#include <crypto/arc4.h>
#include <linux/crc32poly.h>
#include <drv_types.h>
#include <rtw_debug.h>
@@ -31,66 +32,6 @@ const char *security_type_str(u8 value)
/* WEP related ===== */
-struct arc4context {
- u32 x;
- u32 y;
- u8 state[256];
-};
-
-
-static void arcfour_init(struct arc4context *parc4ctx, u8 *key, u32 key_len)
-{
- u32 t, u;
- u32 keyindex;
- u32 stateindex;
- u8 *state;
- u32 counter;
-
- state = parc4ctx->state;
- parc4ctx->x = 0;
- parc4ctx->y = 0;
- for (counter = 0; counter < 256; counter++)
- state[counter] = (u8)counter;
- keyindex = 0;
- stateindex = 0;
- for (counter = 0; counter < 256; counter++) {
- t = state[counter];
- stateindex = (stateindex + key[keyindex] + t) & 0xff;
- u = state[stateindex];
- state[stateindex] = (u8)t;
- state[counter] = (u8)u;
- if (++keyindex >= key_len)
- keyindex = 0;
- }
-}
-
-static u32 arcfour_byte(struct arc4context *parc4ctx)
-{
- u32 x;
- u32 y;
- u32 sx, sy;
- u8 *state;
-
- state = parc4ctx->state;
- x = (parc4ctx->x + 1) & 0xff;
- sx = state[x];
- y = (sx + parc4ctx->y) & 0xff;
- sy = state[y];
- parc4ctx->x = x;
- parc4ctx->y = y;
- state[y] = (u8)sx;
- state[x] = (u8)sy;
- return state[(sx + sy) & 0xff];
-}
-
-static void arcfour_encrypt(struct arc4context *parc4ctx, u8 *dest, u8 *src, u32 len)
-{
- u32 i;
-
- for (i = 0; i < len; i++)
- dest[i] = src[i] ^ (unsigned char)arcfour_byte(parc4ctx);
-}
-
static signed int bcrc32initialized;
static u32 crc32_table[256];
@@ -150,7 +91,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
{ /* exclude ICV */
unsigned char crc[4];
- struct arc4context mycontext;
+ struct arc4_ctx mycontext;
signed int curfragnum, length;
u32 keylength;
@@ -184,16 +125,16 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
*((__le32 *)crc) = getcrc32(payload, length);
- arcfour_init(&mycontext, wepkey, 3+keylength);
- arcfour_encrypt(&mycontext, payload, payload, length);
- arcfour_encrypt(&mycontext, payload+length, crc, 4);
+ arc4_setkey(&mycontext, wepkey, 3 + keylength);
+ arc4_crypt(&mycontext, payload, payload, length);
+ arc4_crypt(&mycontext, payload + length, crc, 4);
} else {
length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
*((__le32 *)crc) = getcrc32(payload, length);
- arcfour_init(&mycontext, wepkey, 3+keylength);
- arcfour_encrypt(&mycontext, payload, payload, length);
- arcfour_encrypt(&mycontext, payload+length, crc, 4);
+ arc4_setkey(&mycontext, wepkey, 3 + keylength);
+ arc4_crypt(&mycontext, payload, payload, length);
+ arc4_crypt(&mycontext, payload + length, crc, 4);
pframe += pxmitpriv->frag_len;
pframe = (u8 *)round_up((SIZE_PTR)(pframe), 4);
@@ -206,7 +147,7 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe)
{
/* exclude ICV */
u8 crc[4];
- struct arc4context mycontext;
+ struct arc4_ctx mycontext;
signed int length;
u32 keylength;
u8 *pframe, *payload, *iv, wepkey[16];
@@ -230,8 +171,8 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe)
payload = pframe+prxattrib->iv_len+prxattrib->hdrlen;
/* decrypt payload include icv */
- arcfour_init(&mycontext, wepkey, 3+keylength);
- arcfour_encrypt(&mycontext, payload, payload, length);
+ arc4_setkey(&mycontext, wepkey, 3 + keylength);
+ arc4_crypt(&mycontext, payload, payload, length);
/* calculate icv and compare the icv */
*((u32 *)crc) = le32_to_cpu(getcrc32(payload, length-4));
@@ -579,7 +520,7 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
u8 ttkey[16];
u8 crc[4];
u8 hw_hdr_offset = 0;
- struct arc4context mycontext;
+ struct arc4_ctx mycontext;
signed int curfragnum, length;
u8 *pframe, *payload, *iv, *prwskey;
@@ -621,16 +562,16 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
*((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/
- arcfour_init(&mycontext, rc4key, 16);
- arcfour_encrypt(&mycontext, payload, payload, length);
- arcfour_encrypt(&mycontext, payload+length, crc, 4);
+ arc4_setkey(&mycontext, rc4key, 16);
+ arc4_crypt(&mycontext, payload, payload, length);
+ arc4_crypt(&mycontext, payload + length, crc, 4);
} else {
length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
*((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/
- arcfour_init(&mycontext, rc4key, 16);
- arcfour_encrypt(&mycontext, payload, payload, length);
- arcfour_encrypt(&mycontext, payload+length, crc, 4);
+ arc4_setkey(&mycontext, rc4key, 16);
+ arc4_crypt(&mycontext, payload, payload, length);
+ arc4_crypt(&mycontext, payload + length, crc, 4);
pframe += pxmitpriv->frag_len;
pframe = (u8 *)round_up((SIZE_PTR)(pframe), 4);
@@ -650,7 +591,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
u8 rc4key[16];
u8 ttkey[16];
u8 crc[4];
- struct arc4context mycontext;
+ struct arc4_ctx mycontext;
signed int length;
u8 *pframe, *payload, *iv, *prwskey;
@@ -721,8 +662,8 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
/* 4 decrypt payload include icv */
- arcfour_init(&mycontext, rc4key, 16);
- arcfour_encrypt(&mycontext, payload, payload, length);
+ arc4_setkey(&mycontext, rc4key, 16);
+ arc4_crypt(&mycontext, payload, payload, length);
*((u32 *)crc) = le32_to_cpu(getcrc32(payload, length-4));
--
2.27.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 2/3] staging: rtl8723bs: Use existing arc4 implementation
2021-04-10 13:35 ` [PATCH 2/3] staging: rtl8723bs: " Christophe JAILLET
@ 2021-04-10 15:25 ` kernel test robot
2021-04-12 9:34 ` Greg KH
1 sibling, 0 replies; 13+ messages in thread
From: kernel test robot @ 2021-04-10 15:25 UTC (permalink / raw)
To: Christophe JAILLET, gregkh
Cc: kbuild-all, linux-staging, linux-kernel, kernel-janitors,
Christophe JAILLET
[-- Attachment #1: Type: text/plain, Size: 7145 bytes --]
Hi Christophe,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on staging/staging-testing]
url: https://github.com/0day-ci/linux/commits/Christophe-JAILLET/staging-rtl8188eu-Use-existing-arc4-implementation/20210410-213656
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 32abcac8037da5dc570c22abf266cbb92eee9fc9
config: arm-randconfig-s032-20210410 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-279-g6d5d9b42-dirty
# https://github.com/0day-ci/linux/commit/e0f0911d8f1c282314b6c6df1c03a0656f575f77
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Christophe-JAILLET/staging-rtl8188eu-Use-existing-arc4-implementation/20210410-213656
git checkout e0f0911d8f1c282314b6c6df1c03a0656f575f77
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=arm
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
drivers/staging/rtl8723bs/core/rtw_security.c: In function 'rtw_wep_encrypt':
>> drivers/staging/rtl8723bs/core/rtw_security.c:144:1: warning: the frame size of 1072 bytes is larger than 1024 bytes [-Wframe-larger-than=]
144 | }
| ^
drivers/staging/rtl8723bs/core/rtw_security.c: In function 'rtw_wep_decrypt':
drivers/staging/rtl8723bs/core/rtw_security.c:181:1: warning: the frame size of 1056 bytes is larger than 1024 bytes [-Wframe-larger-than=]
181 | }
| ^
drivers/staging/rtl8723bs/core/rtw_security.c: In function 'rtw_tkip_encrypt':
drivers/staging/rtl8723bs/core/rtw_security.c:583:1: warning: the frame size of 1088 bytes is larger than 1024 bytes [-Wframe-larger-than=]
583 | }
| ^
drivers/staging/rtl8723bs/core/rtw_security.c: In function 'rtw_tkip_decrypt':
drivers/staging/rtl8723bs/core/rtw_security.c:679:1: warning: the frame size of 1072 bytes is larger than 1024 bytes [-Wframe-larger-than=]
679 | }
| ^
vim +144 drivers/staging/rtl8723bs/core/rtw_security.c
554c0a3abf216c Hans de Goede 2017-03-29 92
554c0a3abf216c Hans de Goede 2017-03-29 93 unsigned char crc[4];
e0f0911d8f1c28 Christophe JAILLET 2021-04-10 94 struct arc4_ctx mycontext;
554c0a3abf216c Hans de Goede 2017-03-29 95
d495c5503d1339 Marco Cesati 2021-03-12 96 signed int curfragnum, length;
554c0a3abf216c Hans de Goede 2017-03-29 97 u32 keylength;
554c0a3abf216c Hans de Goede 2017-03-29 98
554c0a3abf216c Hans de Goede 2017-03-29 99 u8 *pframe, *payload, *iv; /* wepkey */
554c0a3abf216c Hans de Goede 2017-03-29 100 u8 wepkey[16];
554c0a3abf216c Hans de Goede 2017-03-29 101 u8 hw_hdr_offset = 0;
554c0a3abf216c Hans de Goede 2017-03-29 102 struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib;
554c0a3abf216c Hans de Goede 2017-03-29 103 struct security_priv *psecuritypriv = &padapter->securitypriv;
554c0a3abf216c Hans de Goede 2017-03-29 104 struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
554c0a3abf216c Hans de Goede 2017-03-29 105
554c0a3abf216c Hans de Goede 2017-03-29 106 if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL)
554c0a3abf216c Hans de Goede 2017-03-29 107 return;
554c0a3abf216c Hans de Goede 2017-03-29 108
554c0a3abf216c Hans de Goede 2017-03-29 109 hw_hdr_offset = TXDESC_OFFSET;
554c0a3abf216c Hans de Goede 2017-03-29 110 pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset;
554c0a3abf216c Hans de Goede 2017-03-29 111
554c0a3abf216c Hans de Goede 2017-03-29 112 /* start to encrypt each fragment */
554c0a3abf216c Hans de Goede 2017-03-29 113 if ((pattrib->encrypt == _WEP40_) || (pattrib->encrypt == _WEP104_)) {
554c0a3abf216c Hans de Goede 2017-03-29 114 keylength = psecuritypriv->dot11DefKeylen[psecuritypriv->dot11PrivacyKeyIndex];
554c0a3abf216c Hans de Goede 2017-03-29 115
554c0a3abf216c Hans de Goede 2017-03-29 116 for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) {
554c0a3abf216c Hans de Goede 2017-03-29 117 iv = pframe+pattrib->hdrlen;
554c0a3abf216c Hans de Goede 2017-03-29 118 memcpy(&wepkey[0], iv, 3);
554c0a3abf216c Hans de Goede 2017-03-29 119 memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[psecuritypriv->dot11PrivacyKeyIndex].skey[0], keylength);
554c0a3abf216c Hans de Goede 2017-03-29 120 payload = pframe+pattrib->iv_len+pattrib->hdrlen;
554c0a3abf216c Hans de Goede 2017-03-29 121
554c0a3abf216c Hans de Goede 2017-03-29 122 if ((curfragnum+1) == pattrib->nr_frags) { /* the last fragment */
554c0a3abf216c Hans de Goede 2017-03-29 123
554c0a3abf216c Hans de Goede 2017-03-29 124 length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
554c0a3abf216c Hans de Goede 2017-03-29 125
554c0a3abf216c Hans de Goede 2017-03-29 126 *((__le32 *)crc) = getcrc32(payload, length);
554c0a3abf216c Hans de Goede 2017-03-29 127
e0f0911d8f1c28 Christophe JAILLET 2021-04-10 128 arc4_setkey(&mycontext, wepkey, 3 + keylength);
e0f0911d8f1c28 Christophe JAILLET 2021-04-10 129 arc4_crypt(&mycontext, payload, payload, length);
e0f0911d8f1c28 Christophe JAILLET 2021-04-10 130 arc4_crypt(&mycontext, payload + length, crc, 4);
554c0a3abf216c Hans de Goede 2017-03-29 131
554c0a3abf216c Hans de Goede 2017-03-29 132 } else {
554c0a3abf216c Hans de Goede 2017-03-29 133 length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
554c0a3abf216c Hans de Goede 2017-03-29 134 *((__le32 *)crc) = getcrc32(payload, length);
e0f0911d8f1c28 Christophe JAILLET 2021-04-10 135 arc4_setkey(&mycontext, wepkey, 3 + keylength);
e0f0911d8f1c28 Christophe JAILLET 2021-04-10 136 arc4_crypt(&mycontext, payload, payload, length);
e0f0911d8f1c28 Christophe JAILLET 2021-04-10 137 arc4_crypt(&mycontext, payload + length, crc, 4);
554c0a3abf216c Hans de Goede 2017-03-29 138
554c0a3abf216c Hans de Goede 2017-03-29 139 pframe += pxmitpriv->frag_len;
87fe08d74ca66d Ross Schmidt 2020-10-03 140 pframe = (u8 *)round_up((SIZE_PTR)(pframe), 4);
554c0a3abf216c Hans de Goede 2017-03-29 141 }
554c0a3abf216c Hans de Goede 2017-03-29 142 }
554c0a3abf216c Hans de Goede 2017-03-29 143 }
554c0a3abf216c Hans de Goede 2017-03-29 @144 }
554c0a3abf216c Hans de Goede 2017-03-29 145
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30594 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/3] staging: rtl8723bs: Use existing arc4 implementation
@ 2021-04-10 15:25 ` kernel test robot
0 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2021-04-10 15:25 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 7252 bytes --]
Hi Christophe,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on staging/staging-testing]
url: https://github.com/0day-ci/linux/commits/Christophe-JAILLET/staging-rtl8188eu-Use-existing-arc4-implementation/20210410-213656
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 32abcac8037da5dc570c22abf266cbb92eee9fc9
config: arm-randconfig-s032-20210410 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-279-g6d5d9b42-dirty
# https://github.com/0day-ci/linux/commit/e0f0911d8f1c282314b6c6df1c03a0656f575f77
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Christophe-JAILLET/staging-rtl8188eu-Use-existing-arc4-implementation/20210410-213656
git checkout e0f0911d8f1c282314b6c6df1c03a0656f575f77
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=arm
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
drivers/staging/rtl8723bs/core/rtw_security.c: In function 'rtw_wep_encrypt':
>> drivers/staging/rtl8723bs/core/rtw_security.c:144:1: warning: the frame size of 1072 bytes is larger than 1024 bytes [-Wframe-larger-than=]
144 | }
| ^
drivers/staging/rtl8723bs/core/rtw_security.c: In function 'rtw_wep_decrypt':
drivers/staging/rtl8723bs/core/rtw_security.c:181:1: warning: the frame size of 1056 bytes is larger than 1024 bytes [-Wframe-larger-than=]
181 | }
| ^
drivers/staging/rtl8723bs/core/rtw_security.c: In function 'rtw_tkip_encrypt':
drivers/staging/rtl8723bs/core/rtw_security.c:583:1: warning: the frame size of 1088 bytes is larger than 1024 bytes [-Wframe-larger-than=]
583 | }
| ^
drivers/staging/rtl8723bs/core/rtw_security.c: In function 'rtw_tkip_decrypt':
drivers/staging/rtl8723bs/core/rtw_security.c:679:1: warning: the frame size of 1072 bytes is larger than 1024 bytes [-Wframe-larger-than=]
679 | }
| ^
vim +144 drivers/staging/rtl8723bs/core/rtw_security.c
554c0a3abf216c Hans de Goede 2017-03-29 92
554c0a3abf216c Hans de Goede 2017-03-29 93 unsigned char crc[4];
e0f0911d8f1c28 Christophe JAILLET 2021-04-10 94 struct arc4_ctx mycontext;
554c0a3abf216c Hans de Goede 2017-03-29 95
d495c5503d1339 Marco Cesati 2021-03-12 96 signed int curfragnum, length;
554c0a3abf216c Hans de Goede 2017-03-29 97 u32 keylength;
554c0a3abf216c Hans de Goede 2017-03-29 98
554c0a3abf216c Hans de Goede 2017-03-29 99 u8 *pframe, *payload, *iv; /* wepkey */
554c0a3abf216c Hans de Goede 2017-03-29 100 u8 wepkey[16];
554c0a3abf216c Hans de Goede 2017-03-29 101 u8 hw_hdr_offset = 0;
554c0a3abf216c Hans de Goede 2017-03-29 102 struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib;
554c0a3abf216c Hans de Goede 2017-03-29 103 struct security_priv *psecuritypriv = &padapter->securitypriv;
554c0a3abf216c Hans de Goede 2017-03-29 104 struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
554c0a3abf216c Hans de Goede 2017-03-29 105
554c0a3abf216c Hans de Goede 2017-03-29 106 if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL)
554c0a3abf216c Hans de Goede 2017-03-29 107 return;
554c0a3abf216c Hans de Goede 2017-03-29 108
554c0a3abf216c Hans de Goede 2017-03-29 109 hw_hdr_offset = TXDESC_OFFSET;
554c0a3abf216c Hans de Goede 2017-03-29 110 pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset;
554c0a3abf216c Hans de Goede 2017-03-29 111
554c0a3abf216c Hans de Goede 2017-03-29 112 /* start to encrypt each fragment */
554c0a3abf216c Hans de Goede 2017-03-29 113 if ((pattrib->encrypt == _WEP40_) || (pattrib->encrypt == _WEP104_)) {
554c0a3abf216c Hans de Goede 2017-03-29 114 keylength = psecuritypriv->dot11DefKeylen[psecuritypriv->dot11PrivacyKeyIndex];
554c0a3abf216c Hans de Goede 2017-03-29 115
554c0a3abf216c Hans de Goede 2017-03-29 116 for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) {
554c0a3abf216c Hans de Goede 2017-03-29 117 iv = pframe+pattrib->hdrlen;
554c0a3abf216c Hans de Goede 2017-03-29 118 memcpy(&wepkey[0], iv, 3);
554c0a3abf216c Hans de Goede 2017-03-29 119 memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[psecuritypriv->dot11PrivacyKeyIndex].skey[0], keylength);
554c0a3abf216c Hans de Goede 2017-03-29 120 payload = pframe+pattrib->iv_len+pattrib->hdrlen;
554c0a3abf216c Hans de Goede 2017-03-29 121
554c0a3abf216c Hans de Goede 2017-03-29 122 if ((curfragnum+1) == pattrib->nr_frags) { /* the last fragment */
554c0a3abf216c Hans de Goede 2017-03-29 123
554c0a3abf216c Hans de Goede 2017-03-29 124 length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
554c0a3abf216c Hans de Goede 2017-03-29 125
554c0a3abf216c Hans de Goede 2017-03-29 126 *((__le32 *)crc) = getcrc32(payload, length);
554c0a3abf216c Hans de Goede 2017-03-29 127
e0f0911d8f1c28 Christophe JAILLET 2021-04-10 128 arc4_setkey(&mycontext, wepkey, 3 + keylength);
e0f0911d8f1c28 Christophe JAILLET 2021-04-10 129 arc4_crypt(&mycontext, payload, payload, length);
e0f0911d8f1c28 Christophe JAILLET 2021-04-10 130 arc4_crypt(&mycontext, payload + length, crc, 4);
554c0a3abf216c Hans de Goede 2017-03-29 131
554c0a3abf216c Hans de Goede 2017-03-29 132 } else {
554c0a3abf216c Hans de Goede 2017-03-29 133 length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
554c0a3abf216c Hans de Goede 2017-03-29 134 *((__le32 *)crc) = getcrc32(payload, length);
e0f0911d8f1c28 Christophe JAILLET 2021-04-10 135 arc4_setkey(&mycontext, wepkey, 3 + keylength);
e0f0911d8f1c28 Christophe JAILLET 2021-04-10 136 arc4_crypt(&mycontext, payload, payload, length);
e0f0911d8f1c28 Christophe JAILLET 2021-04-10 137 arc4_crypt(&mycontext, payload + length, crc, 4);
554c0a3abf216c Hans de Goede 2017-03-29 138
554c0a3abf216c Hans de Goede 2017-03-29 139 pframe += pxmitpriv->frag_len;
87fe08d74ca66d Ross Schmidt 2020-10-03 140 pframe = (u8 *)round_up((SIZE_PTR)(pframe), 4);
554c0a3abf216c Hans de Goede 2017-03-29 141 }
554c0a3abf216c Hans de Goede 2017-03-29 142 }
554c0a3abf216c Hans de Goede 2017-03-29 143 }
554c0a3abf216c Hans de Goede 2017-03-29 @144 }
554c0a3abf216c Hans de Goede 2017-03-29 145
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 30594 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/3] staging: rtl8712: Use existing arc4 implementation
2021-04-10 11:56 ` [PATCH 3/3] staging: rtl8712: " Christophe JAILLET
@ 2021-04-10 15:39 ` kernel test robot
2021-04-10 15:39 ` kernel test robot
2021-04-17 12:57 ` kernel test robot
2 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2021-04-10 15:39 UTC (permalink / raw)
To: Christophe JAILLET, Larry.Finger, florian.c.schilhabel, gregkh
Cc: kbuild-all, linux-staging, linux-kernel, kernel-janitors,
Christophe JAILLET
[-- Attachment #1: Type: text/plain, Size: 7714 bytes --]
Hi Christophe,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on staging/staging-testing]
url: https://github.com/0day-ci/linux/commits/Christophe-JAILLET/staging-rtl8188eu-Use-existing-arc4-implementation/20210410-213656
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 32abcac8037da5dc570c22abf266cbb92eee9fc9
config: arm-randconfig-s032-20210410 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-279-g6d5d9b42-dirty
# https://github.com/0day-ci/linux/commit/ea2709e5f53370e588967f79d2eb847555ea9d3b
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Christophe-JAILLET/staging-rtl8188eu-Use-existing-arc4-implementation/20210410-213656
git checkout ea2709e5f53370e588967f79d2eb847555ea9d3b
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=arm
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
drivers/staging/rtl8712/rtl871x_security.c: In function 'r8712_wep_encrypt':
>> drivers/staging/rtl8712/rtl871x_security.c:147:1: warning: the frame size of 1072 bytes is larger than 1024 bytes [-Wframe-larger-than=]
147 | }
| ^
drivers/staging/rtl8712/rtl871x_security.c: In function 'r8712_wep_decrypt':
drivers/staging/rtl8712/rtl871x_security.c:182:1: warning: the frame size of 1056 bytes is larger than 1024 bytes [-Wframe-larger-than=]
182 | }
| ^
drivers/staging/rtl8712/rtl871x_security.c: In function 'r8712_tkip_encrypt':
drivers/staging/rtl8712/rtl871x_security.c:576:1: warning: the frame size of 1088 bytes is larger than 1024 bytes [-Wframe-larger-than=]
576 | }
| ^
drivers/staging/rtl8712/rtl871x_security.c: In function 'r8712_tkip_decrypt':
drivers/staging/rtl8712/rtl871x_security.c:631:1: warning: the frame size of 1072 bytes is larger than 1024 bytes [-Wframe-larger-than=]
631 | }
| ^
vim +147 drivers/staging/rtl8712/rtl871x_security.c
2865d42c78a912 Larry Finger 2010-08-20 88
2865d42c78a912 Larry Finger 2010-08-20 89 /*
09b080f73a4191 Vijai Kumar K 2016-11-20 90 * Need to consider the fragment situation
2865d42c78a912 Larry Finger 2010-08-20 91 */
2865d42c78a912 Larry Finger 2010-08-20 92 void r8712_wep_encrypt(struct _adapter *padapter, u8 *pxmitframe)
2865d42c78a912 Larry Finger 2010-08-20 93 { /* exclude ICV */
2865d42c78a912 Larry Finger 2010-08-20 94 unsigned char crc[4];
ea2709e5f53370 Christophe JAILLET 2021-04-10 95 struct arc4_ctx mycontext;
b78559b60518eb Martin Homuth 2017-12-19 96 u32 curfragnum, length, keylength, pki;
2865d42c78a912 Larry Finger 2010-08-20 97 u8 *pframe, *payload, *iv; /*,*wepkey*/
2865d42c78a912 Larry Finger 2010-08-20 98 u8 wepkey[16];
2865d42c78a912 Larry Finger 2010-08-20 99 struct pkt_attrib *pattrib = &((struct xmit_frame *)
2865d42c78a912 Larry Finger 2010-08-20 100 pxmitframe)->attrib;
2865d42c78a912 Larry Finger 2010-08-20 101 struct security_priv *psecuritypriv = &padapter->securitypriv;
2865d42c78a912 Larry Finger 2010-08-20 102 struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
2865d42c78a912 Larry Finger 2010-08-20 103
2865d42c78a912 Larry Finger 2010-08-20 104 if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL)
2865d42c78a912 Larry Finger 2010-08-20 105 return;
2865d42c78a912 Larry Finger 2010-08-20 106 pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + TXDESC_OFFSET;
2865d42c78a912 Larry Finger 2010-08-20 107 /*start to encrypt each fragment*/
2865d42c78a912 Larry Finger 2010-08-20 108 if ((pattrib->encrypt == _WEP40_) || (pattrib->encrypt == _WEP104_)) {
b78559b60518eb Martin Homuth 2017-12-19 109 pki = psecuritypriv->PrivacyKeyIndex;
b78559b60518eb Martin Homuth 2017-12-19 110 keylength = psecuritypriv->DefKeylen[pki];
2865d42c78a912 Larry Finger 2010-08-20 111 for (curfragnum = 0; curfragnum < pattrib->nr_frags;
2865d42c78a912 Larry Finger 2010-08-20 112 curfragnum++) {
2865d42c78a912 Larry Finger 2010-08-20 113 iv = pframe + pattrib->hdrlen;
2865d42c78a912 Larry Finger 2010-08-20 114 memcpy(&wepkey[0], iv, 3);
2865d42c78a912 Larry Finger 2010-08-20 115 memcpy(&wepkey[3], &psecuritypriv->DefKey[
2865d42c78a912 Larry Finger 2010-08-20 116 psecuritypriv->PrivacyKeyIndex].skey[0],
2865d42c78a912 Larry Finger 2010-08-20 117 keylength);
2865d42c78a912 Larry Finger 2010-08-20 118 payload = pframe + pattrib->iv_len + pattrib->hdrlen;
2865d42c78a912 Larry Finger 2010-08-20 119 if ((curfragnum + 1) == pattrib->nr_frags) {
b78559b60518eb Martin Homuth 2017-12-19 120 length = pattrib->last_txcmdsz -
b78559b60518eb Martin Homuth 2017-12-19 121 pattrib->hdrlen -
b78559b60518eb Martin Homuth 2017-12-19 122 pattrib->iv_len -
2865d42c78a912 Larry Finger 2010-08-20 123 pattrib->icv_len;
dd9161483f420c Jannik Becher 2016-12-20 124 *((__le32 *)crc) = cpu_to_le32(getcrc32(
2865d42c78a912 Larry Finger 2010-08-20 125 payload, length));
ea2709e5f53370 Christophe JAILLET 2021-04-10 126 arc4_setkey(&mycontext, wepkey, 3 + keylength);
ea2709e5f53370 Christophe JAILLET 2021-04-10 127 arc4_crypt(&mycontext, payload, payload,
2865d42c78a912 Larry Finger 2010-08-20 128 length);
ea2709e5f53370 Christophe JAILLET 2021-04-10 129 arc4_crypt(&mycontext, payload + length,
2865d42c78a912 Larry Finger 2010-08-20 130 crc, 4);
2865d42c78a912 Larry Finger 2010-08-20 131 } else {
4ef2de5ae0377b Luis de Bethencourt 2015-10-19 132 length = pxmitpriv->frag_len -
4ef2de5ae0377b Luis de Bethencourt 2015-10-19 133 pattrib->hdrlen - pattrib->iv_len -
4ef2de5ae0377b Luis de Bethencourt 2015-10-19 134 pattrib->icv_len;
dd9161483f420c Jannik Becher 2016-12-20 135 *((__le32 *)crc) = cpu_to_le32(getcrc32(
2865d42c78a912 Larry Finger 2010-08-20 136 payload, length));
ea2709e5f53370 Christophe JAILLET 2021-04-10 137 arc4_setkey(&mycontext, wepkey, 3 + keylength);
ea2709e5f53370 Christophe JAILLET 2021-04-10 138 arc4_crypt(&mycontext, payload, payload,
2865d42c78a912 Larry Finger 2010-08-20 139 length);
ea2709e5f53370 Christophe JAILLET 2021-04-10 140 arc4_crypt(&mycontext, payload + length,
2865d42c78a912 Larry Finger 2010-08-20 141 crc, 4);
2865d42c78a912 Larry Finger 2010-08-20 142 pframe += pxmitpriv->frag_len;
2865d42c78a912 Larry Finger 2010-08-20 143 pframe = (u8 *)RND4((addr_t)(pframe));
2865d42c78a912 Larry Finger 2010-08-20 144 }
2865d42c78a912 Larry Finger 2010-08-20 145 }
2865d42c78a912 Larry Finger 2010-08-20 146 }
2865d42c78a912 Larry Finger 2010-08-20 @147 }
2865d42c78a912 Larry Finger 2010-08-20 148
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30594 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/3] staging: rtl8712: Use existing arc4 implementation
@ 2021-04-10 15:39 ` kernel test robot
0 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2021-04-10 15:39 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 7828 bytes --]
Hi Christophe,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on staging/staging-testing]
url: https://github.com/0day-ci/linux/commits/Christophe-JAILLET/staging-rtl8188eu-Use-existing-arc4-implementation/20210410-213656
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 32abcac8037da5dc570c22abf266cbb92eee9fc9
config: arm-randconfig-s032-20210410 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-279-g6d5d9b42-dirty
# https://github.com/0day-ci/linux/commit/ea2709e5f53370e588967f79d2eb847555ea9d3b
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Christophe-JAILLET/staging-rtl8188eu-Use-existing-arc4-implementation/20210410-213656
git checkout ea2709e5f53370e588967f79d2eb847555ea9d3b
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=arm
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
drivers/staging/rtl8712/rtl871x_security.c: In function 'r8712_wep_encrypt':
>> drivers/staging/rtl8712/rtl871x_security.c:147:1: warning: the frame size of 1072 bytes is larger than 1024 bytes [-Wframe-larger-than=]
147 | }
| ^
drivers/staging/rtl8712/rtl871x_security.c: In function 'r8712_wep_decrypt':
drivers/staging/rtl8712/rtl871x_security.c:182:1: warning: the frame size of 1056 bytes is larger than 1024 bytes [-Wframe-larger-than=]
182 | }
| ^
drivers/staging/rtl8712/rtl871x_security.c: In function 'r8712_tkip_encrypt':
drivers/staging/rtl8712/rtl871x_security.c:576:1: warning: the frame size of 1088 bytes is larger than 1024 bytes [-Wframe-larger-than=]
576 | }
| ^
drivers/staging/rtl8712/rtl871x_security.c: In function 'r8712_tkip_decrypt':
drivers/staging/rtl8712/rtl871x_security.c:631:1: warning: the frame size of 1072 bytes is larger than 1024 bytes [-Wframe-larger-than=]
631 | }
| ^
vim +147 drivers/staging/rtl8712/rtl871x_security.c
2865d42c78a912 Larry Finger 2010-08-20 88
2865d42c78a912 Larry Finger 2010-08-20 89 /*
09b080f73a4191 Vijai Kumar K 2016-11-20 90 * Need to consider the fragment situation
2865d42c78a912 Larry Finger 2010-08-20 91 */
2865d42c78a912 Larry Finger 2010-08-20 92 void r8712_wep_encrypt(struct _adapter *padapter, u8 *pxmitframe)
2865d42c78a912 Larry Finger 2010-08-20 93 { /* exclude ICV */
2865d42c78a912 Larry Finger 2010-08-20 94 unsigned char crc[4];
ea2709e5f53370 Christophe JAILLET 2021-04-10 95 struct arc4_ctx mycontext;
b78559b60518eb Martin Homuth 2017-12-19 96 u32 curfragnum, length, keylength, pki;
2865d42c78a912 Larry Finger 2010-08-20 97 u8 *pframe, *payload, *iv; /*,*wepkey*/
2865d42c78a912 Larry Finger 2010-08-20 98 u8 wepkey[16];
2865d42c78a912 Larry Finger 2010-08-20 99 struct pkt_attrib *pattrib = &((struct xmit_frame *)
2865d42c78a912 Larry Finger 2010-08-20 100 pxmitframe)->attrib;
2865d42c78a912 Larry Finger 2010-08-20 101 struct security_priv *psecuritypriv = &padapter->securitypriv;
2865d42c78a912 Larry Finger 2010-08-20 102 struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
2865d42c78a912 Larry Finger 2010-08-20 103
2865d42c78a912 Larry Finger 2010-08-20 104 if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL)
2865d42c78a912 Larry Finger 2010-08-20 105 return;
2865d42c78a912 Larry Finger 2010-08-20 106 pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + TXDESC_OFFSET;
2865d42c78a912 Larry Finger 2010-08-20 107 /*start to encrypt each fragment*/
2865d42c78a912 Larry Finger 2010-08-20 108 if ((pattrib->encrypt == _WEP40_) || (pattrib->encrypt == _WEP104_)) {
b78559b60518eb Martin Homuth 2017-12-19 109 pki = psecuritypriv->PrivacyKeyIndex;
b78559b60518eb Martin Homuth 2017-12-19 110 keylength = psecuritypriv->DefKeylen[pki];
2865d42c78a912 Larry Finger 2010-08-20 111 for (curfragnum = 0; curfragnum < pattrib->nr_frags;
2865d42c78a912 Larry Finger 2010-08-20 112 curfragnum++) {
2865d42c78a912 Larry Finger 2010-08-20 113 iv = pframe + pattrib->hdrlen;
2865d42c78a912 Larry Finger 2010-08-20 114 memcpy(&wepkey[0], iv, 3);
2865d42c78a912 Larry Finger 2010-08-20 115 memcpy(&wepkey[3], &psecuritypriv->DefKey[
2865d42c78a912 Larry Finger 2010-08-20 116 psecuritypriv->PrivacyKeyIndex].skey[0],
2865d42c78a912 Larry Finger 2010-08-20 117 keylength);
2865d42c78a912 Larry Finger 2010-08-20 118 payload = pframe + pattrib->iv_len + pattrib->hdrlen;
2865d42c78a912 Larry Finger 2010-08-20 119 if ((curfragnum + 1) == pattrib->nr_frags) {
b78559b60518eb Martin Homuth 2017-12-19 120 length = pattrib->last_txcmdsz -
b78559b60518eb Martin Homuth 2017-12-19 121 pattrib->hdrlen -
b78559b60518eb Martin Homuth 2017-12-19 122 pattrib->iv_len -
2865d42c78a912 Larry Finger 2010-08-20 123 pattrib->icv_len;
dd9161483f420c Jannik Becher 2016-12-20 124 *((__le32 *)crc) = cpu_to_le32(getcrc32(
2865d42c78a912 Larry Finger 2010-08-20 125 payload, length));
ea2709e5f53370 Christophe JAILLET 2021-04-10 126 arc4_setkey(&mycontext, wepkey, 3 + keylength);
ea2709e5f53370 Christophe JAILLET 2021-04-10 127 arc4_crypt(&mycontext, payload, payload,
2865d42c78a912 Larry Finger 2010-08-20 128 length);
ea2709e5f53370 Christophe JAILLET 2021-04-10 129 arc4_crypt(&mycontext, payload + length,
2865d42c78a912 Larry Finger 2010-08-20 130 crc, 4);
2865d42c78a912 Larry Finger 2010-08-20 131 } else {
4ef2de5ae0377b Luis de Bethencourt 2015-10-19 132 length = pxmitpriv->frag_len -
4ef2de5ae0377b Luis de Bethencourt 2015-10-19 133 pattrib->hdrlen - pattrib->iv_len -
4ef2de5ae0377b Luis de Bethencourt 2015-10-19 134 pattrib->icv_len;
dd9161483f420c Jannik Becher 2016-12-20 135 *((__le32 *)crc) = cpu_to_le32(getcrc32(
2865d42c78a912 Larry Finger 2010-08-20 136 payload, length));
ea2709e5f53370 Christophe JAILLET 2021-04-10 137 arc4_setkey(&mycontext, wepkey, 3 + keylength);
ea2709e5f53370 Christophe JAILLET 2021-04-10 138 arc4_crypt(&mycontext, payload, payload,
2865d42c78a912 Larry Finger 2010-08-20 139 length);
ea2709e5f53370 Christophe JAILLET 2021-04-10 140 arc4_crypt(&mycontext, payload + length,
2865d42c78a912 Larry Finger 2010-08-20 141 crc, 4);
2865d42c78a912 Larry Finger 2010-08-20 142 pframe += pxmitpriv->frag_len;
2865d42c78a912 Larry Finger 2010-08-20 143 pframe = (u8 *)RND4((addr_t)(pframe));
2865d42c78a912 Larry Finger 2010-08-20 144 }
2865d42c78a912 Larry Finger 2010-08-20 145 }
2865d42c78a912 Larry Finger 2010-08-20 146 }
2865d42c78a912 Larry Finger 2010-08-20 @147 }
2865d42c78a912 Larry Finger 2010-08-20 148
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 30594 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/3] staging: rtl8723bs: Use existing arc4 implementation
2021-04-10 13:35 ` [PATCH 2/3] staging: rtl8723bs: " Christophe JAILLET
2021-04-10 15:25 ` kernel test robot
@ 2021-04-12 9:34 ` Greg KH
2021-04-12 21:09 ` Christophe JAILLET
1 sibling, 1 reply; 13+ messages in thread
From: Greg KH @ 2021-04-12 9:34 UTC (permalink / raw)
To: Christophe JAILLET; +Cc: linux-staging, linux-kernel, kernel-janitors
On Sat, Apr 10, 2021 at 03:35:52PM +0200, Christophe JAILLET wrote:
> Use functions provided by <crypto/arc4.h> instead of hand writing them.
>
> The implementations are slightly different, but are equivalent. It has
> been checked with a test program which compares the output of the 2 sets of
> functions.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> drivers/staging/rtl8723bs/core/rtw_security.c | 101 ++++--------------
> 1 file changed, 21 insertions(+), 80 deletions(-)
>
> diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c
> index 9587d89a6b24..86949a65e96f 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_security.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_security.c
> @@ -6,6 +6,7 @@
> ******************************************************************************/
> #define _RTW_SECURITY_C_
>
> +#include <crypto/arc4.h>
> #include <linux/crc32poly.h>
> #include <drv_types.h>
> #include <rtw_debug.h>
> @@ -31,66 +32,6 @@ const char *security_type_str(u8 value)
>
> /* WEP related ===== */
>
> -struct arc4context {
> - u32 x;
> - u32 y;
> - u8 state[256];
> -};
> -
> -
> -static void arcfour_init(struct arc4context *parc4ctx, u8 *key, u32 key_len)
> -{
> - u32 t, u;
> - u32 keyindex;
> - u32 stateindex;
> - u8 *state;
> - u32 counter;
> -
> - state = parc4ctx->state;
> - parc4ctx->x = 0;
> - parc4ctx->y = 0;
> - for (counter = 0; counter < 256; counter++)
> - state[counter] = (u8)counter;
> - keyindex = 0;
> - stateindex = 0;
> - for (counter = 0; counter < 256; counter++) {
> - t = state[counter];
> - stateindex = (stateindex + key[keyindex] + t) & 0xff;
> - u = state[stateindex];
> - state[stateindex] = (u8)t;
> - state[counter] = (u8)u;
> - if (++keyindex >= key_len)
> - keyindex = 0;
> - }
> -}
> -
> -static u32 arcfour_byte(struct arc4context *parc4ctx)
> -{
> - u32 x;
> - u32 y;
> - u32 sx, sy;
> - u8 *state;
> -
> - state = parc4ctx->state;
> - x = (parc4ctx->x + 1) & 0xff;
> - sx = state[x];
> - y = (sx + parc4ctx->y) & 0xff;
> - sy = state[y];
> - parc4ctx->x = x;
> - parc4ctx->y = y;
> - state[y] = (u8)sx;
> - state[x] = (u8)sy;
> - return state[(sx + sy) & 0xff];
> -}
> -
> -static void arcfour_encrypt(struct arc4context *parc4ctx, u8 *dest, u8 *src, u32 len)
> -{
> - u32 i;
> -
> - for (i = 0; i < len; i++)
> - dest[i] = src[i] ^ (unsigned char)arcfour_byte(parc4ctx);
> -}
> -
> static signed int bcrc32initialized;
> static u32 crc32_table[256];
>
> @@ -150,7 +91,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
> { /* exclude ICV */
>
> unsigned char crc[4];
> - struct arc4context mycontext;
> + struct arc4_ctx mycontext;
Are you sure you can declare that much space on the stack? Is that what
other users of this api do? In looking at the in-kernel users, they do
not :(
Can you fix up this series to not take up so much stack memory?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/3] staging: rtl8723bs: Use existing arc4 implementation
2021-04-12 9:34 ` Greg KH
@ 2021-04-12 21:09 ` Christophe JAILLET
0 siblings, 0 replies; 13+ messages in thread
From: Christophe JAILLET @ 2021-04-12 21:09 UTC (permalink / raw)
To: Greg KH; +Cc: linux-staging, linux-kernel, kernel-janitors
Le 12/04/2021 à 11:34, Greg KH a écrit :
> On Sat, Apr 10, 2021 at 03:35:52PM +0200, Christophe JAILLET wrote:
>> Use functions provided by <crypto/arc4.h> instead of hand writing them.
>>
>> The implementations are slightly different, but are equivalent. It has
>> been checked with a test program which compares the output of the 2 sets of
>> functions.
>>
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> ---
>> drivers/staging/rtl8723bs/core/rtw_security.c | 101 ++++--------------
>> 1 file changed, 21 insertions(+), 80 deletions(-)
>>
>> diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c
>> index 9587d89a6b24..86949a65e96f 100644
>> --- a/drivers/staging/rtl8723bs/core/rtw_security.c
>> +++ b/drivers/staging/rtl8723bs/core/rtw_security.c
>> @@ -6,6 +6,7 @@
>> ******************************************************************************/
>> #define _RTW_SECURITY_C_
>>
>> +#include <crypto/arc4.h>
>> #include <linux/crc32poly.h>
>> #include <drv_types.h>
>> #include <rtw_debug.h>
>> @@ -31,66 +32,6 @@ const char *security_type_str(u8 value)
>>
>> /* WEP related ===== */
>>
>> -struct arc4context {
>> - u32 x;
>> - u32 y;
>> - u8 state[256];
>> -};
>> -
>> -
>> -static void arcfour_init(struct arc4context *parc4ctx, u8 *key, u32 key_len)
>> -{
>> - u32 t, u;
>> - u32 keyindex;
>> - u32 stateindex;
>> - u8 *state;
>> - u32 counter;
>> -
>> - state = parc4ctx->state;
>> - parc4ctx->x = 0;
>> - parc4ctx->y = 0;
>> - for (counter = 0; counter < 256; counter++)
>> - state[counter] = (u8)counter;
>> - keyindex = 0;
>> - stateindex = 0;
>> - for (counter = 0; counter < 256; counter++) {
>> - t = state[counter];
>> - stateindex = (stateindex + key[keyindex] + t) & 0xff;
>> - u = state[stateindex];
>> - state[stateindex] = (u8)t;
>> - state[counter] = (u8)u;
>> - if (++keyindex >= key_len)
>> - keyindex = 0;
>> - }
>> -}
>> -
>> -static u32 arcfour_byte(struct arc4context *parc4ctx)
>> -{
>> - u32 x;
>> - u32 y;
>> - u32 sx, sy;
>> - u8 *state;
>> -
>> - state = parc4ctx->state;
>> - x = (parc4ctx->x + 1) & 0xff;
>> - sx = state[x];
>> - y = (sx + parc4ctx->y) & 0xff;
>> - sy = state[y];
>> - parc4ctx->x = x;
>> - parc4ctx->y = y;
>> - state[y] = (u8)sx;
>> - state[x] = (u8)sy;
>> - return state[(sx + sy) & 0xff];
>> -}
>> -
>> -static void arcfour_encrypt(struct arc4context *parc4ctx, u8 *dest, u8 *src, u32 len)
>> -{
>> - u32 i;
>> -
>> - for (i = 0; i < len; i++)
>> - dest[i] = src[i] ^ (unsigned char)arcfour_byte(parc4ctx);
>> -}
>> -
>> static signed int bcrc32initialized;
>> static u32 crc32_table[256];
>>
>> @@ -150,7 +91,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
>> { /* exclude ICV */
>>
>> unsigned char crc[4];
>> - struct arc4context mycontext;
>> + struct arc4_ctx mycontext;
>
> Are you sure you can declare that much space on the stack? Is that what
> other users of this api do? In looking at the in-kernel users, they do
> not :(
>
In fact arc4context was a u8[256] but arc4_ctx uses a u32[256].
Maybe arc4 function should be modified to use u8? Or at least when
CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is defined?
Concerning the other uses of the arc4 API, in fact there is only few of
them. Most uses are buried into lib80211_crypt_tkip.c and
lib80211_crypt_wep.c which is the way to go, IMHO.
In fact, I think that most, if not all 'rtl871x_security.c' could be
removed.
However, it looks like a big step to me. And without any hardware to
test, I'm pretty sure to break something.
Any hints on the best way to axe some duplicated code without to much
risks to break everything?
CJ
> Can you fix up this series to not take up so much stack memory?
I guess that _adapter could be used to store this arc4_ctx, but I'm not
convinced that it is the way to go.
CJ
>
> thanks,
>
> greg k-h
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/3] staging: rtl8712: Use existing arc4 implementation
2021-04-10 11:56 ` [PATCH 3/3] staging: rtl8712: " Christophe JAILLET
@ 2021-04-17 12:57 ` kernel test robot
2021-04-10 15:39 ` kernel test robot
2021-04-17 12:57 ` kernel test robot
2 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2021-04-17 12:57 UTC (permalink / raw)
To: Christophe JAILLET, Larry.Finger, florian.c.schilhabel, gregkh
Cc: kbuild-all, linux-staging, linux-kernel, kernel-janitors,
Christophe JAILLET
[-- Attachment #1: Type: text/plain, Size: 5571 bytes --]
Hi Christophe,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on staging/staging-testing]
url: https://github.com/0day-ci/linux/commits/Christophe-JAILLET/staging-rtl8188eu-Use-existing-arc4-implementation/20210410-213656
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 32abcac8037da5dc570c22abf266cbb92eee9fc9
config: x86_64-randconfig-s021-20210416 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.3-280-g2cd6d34e-dirty
# https://github.com/0day-ci/linux/commit/ea2709e5f53370e588967f79d2eb847555ea9d3b
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Christophe-JAILLET/staging-rtl8188eu-Use-existing-arc4-implementation/20210410-213656
git checkout ea2709e5f53370e588967f79d2eb847555ea9d3b
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' W=1 ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
ld: drivers/staging/rtl8712/rtl871x_security.o: in function `r8712_wep_encrypt':
>> drivers/staging/rtl8712/rtl871x_security.c:126: undefined reference to `arc4_setkey'
>> ld: drivers/staging/rtl8712/rtl871x_security.c:127: undefined reference to `arc4_crypt'
ld: drivers/staging/rtl8712/rtl871x_security.c:129: undefined reference to `arc4_crypt'
>> ld: drivers/staging/rtl8712/rtl871x_security.c:137: undefined reference to `arc4_setkey'
ld: drivers/staging/rtl8712/rtl871x_security.c:138: undefined reference to `arc4_crypt'
ld: drivers/staging/rtl8712/rtl871x_security.c:140: undefined reference to `arc4_crypt'
ld: drivers/staging/rtl8712/rtl871x_security.o: in function `r8712_wep_decrypt':
drivers/staging/rtl8712/rtl871x_security.c:177: undefined reference to `arc4_setkey'
ld: drivers/staging/rtl8712/rtl871x_security.c:178: undefined reference to `arc4_crypt'
ld: drivers/staging/rtl8712/rtl871x_security.o: in function `r8712_tkip_encrypt':
drivers/staging/rtl8712/rtl871x_security.c:550: undefined reference to `arc4_setkey'
ld: drivers/staging/rtl8712/rtl871x_security.c:551: undefined reference to `arc4_crypt'
ld: drivers/staging/rtl8712/rtl871x_security.c:553: undefined reference to `arc4_crypt'
ld: drivers/staging/rtl8712/rtl871x_security.c:562: undefined reference to `arc4_setkey'
ld: drivers/staging/rtl8712/rtl871x_security.c:563: undefined reference to `arc4_crypt'
ld: drivers/staging/rtl8712/rtl871x_security.c:565: undefined reference to `arc4_crypt'
ld: drivers/staging/rtl8712/rtl871x_security.o: in function `r8712_tkip_decrypt':
drivers/staging/rtl8712/rtl871x_security.c:625: undefined reference to `arc4_setkey'
ld: drivers/staging/rtl8712/rtl871x_security.c:626: undefined reference to `arc4_crypt'
vim +126 drivers/staging/rtl8712/rtl871x_security.c
88
89 /*
90 * Need to consider the fragment situation
91 */
92 void r8712_wep_encrypt(struct _adapter *padapter, u8 *pxmitframe)
93 { /* exclude ICV */
94 unsigned char crc[4];
95 struct arc4_ctx mycontext;
96 u32 curfragnum, length, keylength, pki;
97 u8 *pframe, *payload, *iv; /*,*wepkey*/
98 u8 wepkey[16];
99 struct pkt_attrib *pattrib = &((struct xmit_frame *)
100 pxmitframe)->attrib;
101 struct security_priv *psecuritypriv = &padapter->securitypriv;
102 struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
103
104 if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL)
105 return;
106 pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + TXDESC_OFFSET;
107 /*start to encrypt each fragment*/
108 if ((pattrib->encrypt == _WEP40_) || (pattrib->encrypt == _WEP104_)) {
109 pki = psecuritypriv->PrivacyKeyIndex;
110 keylength = psecuritypriv->DefKeylen[pki];
111 for (curfragnum = 0; curfragnum < pattrib->nr_frags;
112 curfragnum++) {
113 iv = pframe + pattrib->hdrlen;
114 memcpy(&wepkey[0], iv, 3);
115 memcpy(&wepkey[3], &psecuritypriv->DefKey[
116 psecuritypriv->PrivacyKeyIndex].skey[0],
117 keylength);
118 payload = pframe + pattrib->iv_len + pattrib->hdrlen;
119 if ((curfragnum + 1) == pattrib->nr_frags) {
120 length = pattrib->last_txcmdsz -
121 pattrib->hdrlen -
122 pattrib->iv_len -
123 pattrib->icv_len;
124 *((__le32 *)crc) = cpu_to_le32(getcrc32(
125 payload, length));
> 126 arc4_setkey(&mycontext, wepkey, 3 + keylength);
> 127 arc4_crypt(&mycontext, payload, payload,
128 length);
129 arc4_crypt(&mycontext, payload + length,
130 crc, 4);
131 } else {
132 length = pxmitpriv->frag_len -
133 pattrib->hdrlen - pattrib->iv_len -
134 pattrib->icv_len;
135 *((__le32 *)crc) = cpu_to_le32(getcrc32(
136 payload, length));
> 137 arc4_setkey(&mycontext, wepkey, 3 + keylength);
138 arc4_crypt(&mycontext, payload, payload,
139 length);
140 arc4_crypt(&mycontext, payload + length,
141 crc, 4);
142 pframe += pxmitpriv->frag_len;
143 pframe = (u8 *)RND4((addr_t)(pframe));
144 }
145 }
146 }
147 }
148
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 46237 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/3] staging: rtl8712: Use existing arc4 implementation
@ 2021-04-17 12:57 ` kernel test robot
0 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2021-04-17 12:57 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 5687 bytes --]
Hi Christophe,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on staging/staging-testing]
url: https://github.com/0day-ci/linux/commits/Christophe-JAILLET/staging-rtl8188eu-Use-existing-arc4-implementation/20210410-213656
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 32abcac8037da5dc570c22abf266cbb92eee9fc9
config: x86_64-randconfig-s021-20210416 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.3-280-g2cd6d34e-dirty
# https://github.com/0day-ci/linux/commit/ea2709e5f53370e588967f79d2eb847555ea9d3b
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Christophe-JAILLET/staging-rtl8188eu-Use-existing-arc4-implementation/20210410-213656
git checkout ea2709e5f53370e588967f79d2eb847555ea9d3b
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' W=1 ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
ld: drivers/staging/rtl8712/rtl871x_security.o: in function `r8712_wep_encrypt':
>> drivers/staging/rtl8712/rtl871x_security.c:126: undefined reference to `arc4_setkey'
>> ld: drivers/staging/rtl8712/rtl871x_security.c:127: undefined reference to `arc4_crypt'
ld: drivers/staging/rtl8712/rtl871x_security.c:129: undefined reference to `arc4_crypt'
>> ld: drivers/staging/rtl8712/rtl871x_security.c:137: undefined reference to `arc4_setkey'
ld: drivers/staging/rtl8712/rtl871x_security.c:138: undefined reference to `arc4_crypt'
ld: drivers/staging/rtl8712/rtl871x_security.c:140: undefined reference to `arc4_crypt'
ld: drivers/staging/rtl8712/rtl871x_security.o: in function `r8712_wep_decrypt':
drivers/staging/rtl8712/rtl871x_security.c:177: undefined reference to `arc4_setkey'
ld: drivers/staging/rtl8712/rtl871x_security.c:178: undefined reference to `arc4_crypt'
ld: drivers/staging/rtl8712/rtl871x_security.o: in function `r8712_tkip_encrypt':
drivers/staging/rtl8712/rtl871x_security.c:550: undefined reference to `arc4_setkey'
ld: drivers/staging/rtl8712/rtl871x_security.c:551: undefined reference to `arc4_crypt'
ld: drivers/staging/rtl8712/rtl871x_security.c:553: undefined reference to `arc4_crypt'
ld: drivers/staging/rtl8712/rtl871x_security.c:562: undefined reference to `arc4_setkey'
ld: drivers/staging/rtl8712/rtl871x_security.c:563: undefined reference to `arc4_crypt'
ld: drivers/staging/rtl8712/rtl871x_security.c:565: undefined reference to `arc4_crypt'
ld: drivers/staging/rtl8712/rtl871x_security.o: in function `r8712_tkip_decrypt':
drivers/staging/rtl8712/rtl871x_security.c:625: undefined reference to `arc4_setkey'
ld: drivers/staging/rtl8712/rtl871x_security.c:626: undefined reference to `arc4_crypt'
vim +126 drivers/staging/rtl8712/rtl871x_security.c
88
89 /*
90 * Need to consider the fragment situation
91 */
92 void r8712_wep_encrypt(struct _adapter *padapter, u8 *pxmitframe)
93 { /* exclude ICV */
94 unsigned char crc[4];
95 struct arc4_ctx mycontext;
96 u32 curfragnum, length, keylength, pki;
97 u8 *pframe, *payload, *iv; /*,*wepkey*/
98 u8 wepkey[16];
99 struct pkt_attrib *pattrib = &((struct xmit_frame *)
100 pxmitframe)->attrib;
101 struct security_priv *psecuritypriv = &padapter->securitypriv;
102 struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
103
104 if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL)
105 return;
106 pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + TXDESC_OFFSET;
107 /*start to encrypt each fragment*/
108 if ((pattrib->encrypt == _WEP40_) || (pattrib->encrypt == _WEP104_)) {
109 pki = psecuritypriv->PrivacyKeyIndex;
110 keylength = psecuritypriv->DefKeylen[pki];
111 for (curfragnum = 0; curfragnum < pattrib->nr_frags;
112 curfragnum++) {
113 iv = pframe + pattrib->hdrlen;
114 memcpy(&wepkey[0], iv, 3);
115 memcpy(&wepkey[3], &psecuritypriv->DefKey[
116 psecuritypriv->PrivacyKeyIndex].skey[0],
117 keylength);
118 payload = pframe + pattrib->iv_len + pattrib->hdrlen;
119 if ((curfragnum + 1) == pattrib->nr_frags) {
120 length = pattrib->last_txcmdsz -
121 pattrib->hdrlen -
122 pattrib->iv_len -
123 pattrib->icv_len;
124 *((__le32 *)crc) = cpu_to_le32(getcrc32(
125 payload, length));
> 126 arc4_setkey(&mycontext, wepkey, 3 + keylength);
> 127 arc4_crypt(&mycontext, payload, payload,
128 length);
129 arc4_crypt(&mycontext, payload + length,
130 crc, 4);
131 } else {
132 length = pxmitpriv->frag_len -
133 pattrib->hdrlen - pattrib->iv_len -
134 pattrib->icv_len;
135 *((__le32 *)crc) = cpu_to_le32(getcrc32(
136 payload, length));
> 137 arc4_setkey(&mycontext, wepkey, 3 + keylength);
138 arc4_crypt(&mycontext, payload, payload,
139 length);
140 arc4_crypt(&mycontext, payload + length,
141 crc, 4);
142 pframe += pxmitpriv->frag_len;
143 pframe = (u8 *)RND4((addr_t)(pframe));
144 }
145 }
146 }
147 }
148
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 46237 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2021-04-17 12:57 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-10 11:54 [PATCH 1/3] staging: rtl8188eu: Use existing arc4 implementation Christophe JAILLET
2021-04-10 11:55 ` Christophe JAILLET
2021-04-10 11:56 ` [PATCH 3/3] staging: rtl8712: " Christophe JAILLET
2021-04-10 12:09 ` Greg KH
2021-04-10 15:39 ` kernel test robot
2021-04-10 15:39 ` kernel test robot
2021-04-17 12:57 ` kernel test robot
2021-04-17 12:57 ` kernel test robot
2021-04-10 13:35 ` [PATCH 2/3] staging: rtl8723bs: " Christophe JAILLET
2021-04-10 15:25 ` kernel test robot
2021-04-10 15:25 ` kernel test robot
2021-04-12 9:34 ` Greg KH
2021-04-12 21:09 ` Christophe JAILLET
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.