* [PATCH] staging: rtl8192u: Fix signedness bug in ieee80211_check_auth_response()
@ 2022-04-22 2:10 Haowen Bai
0 siblings, 0 replies; 3+ messages in thread
From: Haowen Bai @ 2022-04-22 2:10 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Haowen Bai, linux-staging, linux-kernel
The ieee80211_check_auth_response() function has a signedness bug because
it's a declared as a u16 but it return -ENOMEM. When you look at it more
closely it returns a mix of error codes including 0xcafe, -ENOMEM, and
a->status which is WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG. This is a mess.
Clean it up to just return standard kernel error codes. We can print
out the a->status before returning a regular error code. The printks
in the caller need to be adjusted as well.
Signed-off-by: Haowen Bai <baihaowen@meizu.com>
---
drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
index 4e8fbd2410a1..dfe57748a70e 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
@@ -1461,13 +1461,13 @@ void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee)
spin_unlock_irqrestore(&ieee->lock, flags);
}
-static inline u16 auth_parse(struct sk_buff *skb, u8 **challenge, int *chlen)
+static inline int auth_parse(struct sk_buff *skb, u8 **challenge, int *chlen)
{
struct ieee80211_authentication *a;
u8 *t;
if (skb->len < (sizeof(struct ieee80211_authentication) - sizeof(struct ieee80211_info_element))) {
IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len);
- return 0xcafe;
+ return -EINVAL;
}
*challenge = NULL;
a = (struct ieee80211_authentication *)skb->data;
@@ -1482,7 +1482,12 @@ static inline u16 auth_parse(struct sk_buff *skb, u8 **challenge, int *chlen)
}
}
- return le16_to_cpu(a->status);
+ if (a->status) {
+ IEEE80211_DEBUG_MGMT("auth_parse() failed\n");
+ return -EINVAL;
+ }
+
+ return 0;
}
static int auth_rq_parse(struct sk_buff *skb, u8 *dest)
@@ -1829,7 +1834,7 @@ static void ieee80211_check_auth_response(struct ieee80211_device *ieee,
{
/* default support N mode, disable halfNmode */
bool bSupportNmode = true, bHalfSupportNmode = false;
- u16 errcode;
+ int errcode;
u8 *challenge;
int chlen = 0;
u32 iotAction;
@@ -1878,7 +1883,7 @@ static void ieee80211_check_auth_response(struct ieee80211_device *ieee,
}
} else {
ieee->softmac_stats.rx_auth_rs_err++;
- IEEE80211_DEBUG_MGMT("Auth response status code 0x%x", errcode);
+ IEEE80211_DEBUG_MGMT("Auth response status code %d\n", errcode);
ieee80211_associate_abort(ieee);
}
}
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Staging: rtl8192u: Fix signedness bug in ieee80211_check_auth_response()
2022-04-14 10:32 [PATCH] Staging: " Haowen Bai
@ 2022-04-14 11:33 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2022-04-14 11:33 UTC (permalink / raw)
To: Haowen Bai; +Cc: Greg Kroah-Hartman, linux-staging, linux-kernel
On Thu, Apr 14, 2022 at 06:32:12PM +0800, Haowen Bai wrote:
> function ieee80211_check_auth_response () unsigned errcode receive auth_parse()'s
> errcode -ENOMEM.
>
> Signed-off-by: Haowen Bai <baihaowen@meizu.com>
> ---
> drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
> index 1a43979939a8..4d060c3ec077 100644
> --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
> +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
> @@ -1461,7 +1461,7 @@ void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee)
> spin_unlock_irqrestore(&ieee->lock, flags);
> }
>
> -static inline u16 auth_parse(struct sk_buff *skb, u8 **challenge, int *chlen)
> +static inline s16 auth_parse(struct sk_buff *skb, u8 **challenge, int *chlen)
> {
> struct ieee80211_authentication *a;
> u8 *t;
The auth_parse() function returns 0xcafe on error or else it returns
-ENOMEM or it returns WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG (13). It
returns zero on success. It's a bit silly to return all these random
things. It should only return normal kernel error codes.
If we want we could make it print its own error message:
if (a->status) {
netdev_info(dev, "Authentication response status code 0x%x",
le16_to_cpu(a->status))
return -EINVAL;
}
return 0;
Then delete the printk in the caller or modify it to print an %d instead
of the error code in hex.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] Staging: rtl8192u: Fix signedness bug in ieee80211_check_auth_response()
@ 2022-04-14 10:32 Haowen Bai
2022-04-14 11:33 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Haowen Bai @ 2022-04-14 10:32 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Haowen Bai, linux-staging, linux-kernel
function ieee80211_check_auth_response () unsigned errcode receive auth_parse()'s
errcode -ENOMEM.
Signed-off-by: Haowen Bai <baihaowen@meizu.com>
---
drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
index 1a43979939a8..4d060c3ec077 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
@@ -1461,7 +1461,7 @@ void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee)
spin_unlock_irqrestore(&ieee->lock, flags);
}
-static inline u16 auth_parse(struct sk_buff *skb, u8 **challenge, int *chlen)
+static inline s16 auth_parse(struct sk_buff *skb, u8 **challenge, int *chlen)
{
struct ieee80211_authentication *a;
u8 *t;
@@ -1826,7 +1826,7 @@ static void ieee80211_check_auth_response(struct ieee80211_device *ieee,
{
/* default support N mode, disable halfNmode */
bool bSupportNmode = true, bHalfSupportNmode = false;
- u16 errcode;
+ s16 errcode;
u8 *challenge;
int chlen = 0;
u32 iotAction;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-22 2:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-22 2:10 [PATCH] staging: rtl8192u: Fix signedness bug in ieee80211_check_auth_response() Haowen Bai
-- strict thread matches above, loose matches on Subject: below --
2022-04-14 10:32 [PATCH] Staging: " Haowen Bai
2022-04-14 11:33 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).