All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch 1/4] rndis_wlan: integer overflows in rndis_wlan_do_link_up_work()
@ 2012-02-29  6:35 ` Dan Carpenter
  0 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2012-02-29  6:35 UTC (permalink / raw)
  To: Jussi Kivilinna; +Cc: John W. Linville, linux-wireless, kernel-janitors

If "offset" is negative then we can get past this check:
	if (offset > CONTROL_BUFFER_SIZE)
Or if we pick a very high "req_ie_len" then we can get around the check:
	if (offset + req_ie_len > CONTROL_BUFFER_SIZE)

I made "resp_ie_len" and "req_ie_len" unsigned.  I don't know if it was
intentional that they were signed in the original.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index a330c69..6d8a986 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -2755,9 +2755,10 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev)
 	struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
 	struct ndis_80211_assoc_info *info = NULL;
 	u8 bssid[ETH_ALEN];
-	int resp_ie_len, req_ie_len;
+	unsigned int resp_ie_len, req_ie_len;
+	unsigned int offset;
 	u8 *req_ie, *resp_ie;
-	int ret, offset;
+	int ret;
 	bool roamed = false;
 	bool match_bss;
 
@@ -2785,6 +2786,8 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev)
 		ret = get_association_info(usbdev, info, CONTROL_BUFFER_SIZE);
 		if (!ret) {
 			req_ie_len = le32_to_cpu(info->req_ie_length);
+			if (req_ie_len > CONTROL_BUFFER_SIZE)
+				req_ie_len = CONTROL_BUFFER_SIZE;
 			if (req_ie_len > 0) {
 				offset = le32_to_cpu(info->offset_req_ies);
 
@@ -2799,6 +2802,8 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev)
 			}
 
 			resp_ie_len = le32_to_cpu(info->resp_ie_length);
+			if (resp_ie_len > CONTROL_BUFFER_SIZE)
+				resp_ie_len = CONTROL_BUFFER_SIZE;
 			if (resp_ie_len > 0) {
 				offset = le32_to_cpu(info->offset_resp_ies);
 

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [patch 1/4] rndis_wlan: integer overflows in rndis_wlan_do_link_up_work()
@ 2012-02-29  6:35 ` Dan Carpenter
  0 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2012-02-29  6:35 UTC (permalink / raw)
  To: Jussi Kivilinna; +Cc: John W. Linville, linux-wireless, kernel-janitors

If "offset" is negative then we can get past this check:
	if (offset > CONTROL_BUFFER_SIZE)
Or if we pick a very high "req_ie_len" then we can get around the check:
	if (offset + req_ie_len > CONTROL_BUFFER_SIZE)

I made "resp_ie_len" and "req_ie_len" unsigned.  I don't know if it was
intentional that they were signed in the original.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index a330c69..6d8a986 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -2755,9 +2755,10 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev)
 	struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
 	struct ndis_80211_assoc_info *info = NULL;
 	u8 bssid[ETH_ALEN];
-	int resp_ie_len, req_ie_len;
+	unsigned int resp_ie_len, req_ie_len;
+	unsigned int offset;
 	u8 *req_ie, *resp_ie;
-	int ret, offset;
+	int ret;
 	bool roamed = false;
 	bool match_bss;
 
@@ -2785,6 +2786,8 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev)
 		ret = get_association_info(usbdev, info, CONTROL_BUFFER_SIZE);
 		if (!ret) {
 			req_ie_len = le32_to_cpu(info->req_ie_length);
+			if (req_ie_len > CONTROL_BUFFER_SIZE)
+				req_ie_len = CONTROL_BUFFER_SIZE;
 			if (req_ie_len > 0) {
 				offset = le32_to_cpu(info->offset_req_ies);
 
@@ -2799,6 +2802,8 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev)
 			}
 
 			resp_ie_len = le32_to_cpu(info->resp_ie_length);
+			if (resp_ie_len > CONTROL_BUFFER_SIZE)
+				resp_ie_len = CONTROL_BUFFER_SIZE;
 			if (resp_ie_len > 0) {
 				offset = le32_to_cpu(info->offset_resp_ies);
 

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [patch 1/4] rndis_wlan: integer overflows in rndis_wlan_do_link_up_work()
  2012-02-29  6:35 ` Dan Carpenter
@ 2012-02-29  8:21   ` walter harms
  -1 siblings, 0 replies; 14+ messages in thread
From: walter harms @ 2012-02-29  8:21 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jussi Kivilinna, John W. Linville, linux-wireless, kernel-janitors



Am 29.02.2012 07:35, schrieb Dan Carpenter:
> If "offset" is negative then we can get past this check:
> 	if (offset > CONTROL_BUFFER_SIZE)
> Or if we pick a very high "req_ie_len" then we can get around the check:
> 	if (offset + req_ie_len > CONTROL_BUFFER_SIZE)
> 
> I made "resp_ie_len" and "req_ie_len" unsigned.  I don't know if it was
> intentional that they were signed in the original.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
> index a330c69..6d8a986 100644
> --- a/drivers/net/wireless/rndis_wlan.c
> +++ b/drivers/net/wireless/rndis_wlan.c
> @@ -2755,9 +2755,10 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev)
>  	struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
>  	struct ndis_80211_assoc_info *info = NULL;
>  	u8 bssid[ETH_ALEN];
> -	int resp_ie_len, req_ie_len;
> +	unsigned int resp_ie_len, req_ie_len;
> +	unsigned int offset;
>  	u8 *req_ie, *resp_ie;
> -	int ret, offset;
> +	int ret;
>  	bool roamed = false;
>  	bool match_bss;
>  
> @@ -2785,6 +2786,8 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev)
>  		ret = get_association_info(usbdev, info, CONTROL_BUFFER_SIZE);
>  		if (!ret) {
>  			req_ie_len = le32_to_cpu(info->req_ie_length);
> +			if (req_ie_len > CONTROL_BUFFER_SIZE)
> +				req_ie_len = CONTROL_BUFFER_SIZE;
>  			if (req_ie_len > 0) {
>  				offset = le32_to_cpu(info->offset_req_ies);
>  
> @@ -2799,6 +2802,8 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev)
>  			}
>  
>  			resp_ie_len = le32_to_cpu(info->resp_ie_length);
> +			if (resp_ie_len > CONTROL_BUFFER_SIZE)
> +				resp_ie_len = CONTROL_BUFFER_SIZE;
>  			if (resp_ie_len > 0) {
>  				offset = le32_to_cpu(info->offset_resp_ies);
> 


hi dan,
the check below  "if (resp_ie_len > 0)" looks strange for an unsigned.

re,
 wh


> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch 1/4] rndis_wlan: integer overflows in rndis_wlan_do_link_up_work()
@ 2012-02-29  8:21   ` walter harms
  0 siblings, 0 replies; 14+ messages in thread
From: walter harms @ 2012-02-29  8:21 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jussi Kivilinna, John W. Linville, linux-wireless, kernel-janitors



Am 29.02.2012 07:35, schrieb Dan Carpenter:
> If "offset" is negative then we can get past this check:
> 	if (offset > CONTROL_BUFFER_SIZE)
> Or if we pick a very high "req_ie_len" then we can get around the check:
> 	if (offset + req_ie_len > CONTROL_BUFFER_SIZE)
> 
> I made "resp_ie_len" and "req_ie_len" unsigned.  I don't know if it was
> intentional that they were signed in the original.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
> index a330c69..6d8a986 100644
> --- a/drivers/net/wireless/rndis_wlan.c
> +++ b/drivers/net/wireless/rndis_wlan.c
> @@ -2755,9 +2755,10 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev)
>  	struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
>  	struct ndis_80211_assoc_info *info = NULL;
>  	u8 bssid[ETH_ALEN];
> -	int resp_ie_len, req_ie_len;
> +	unsigned int resp_ie_len, req_ie_len;
> +	unsigned int offset;
>  	u8 *req_ie, *resp_ie;
> -	int ret, offset;
> +	int ret;
>  	bool roamed = false;
>  	bool match_bss;
>  
> @@ -2785,6 +2786,8 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev)
>  		ret = get_association_info(usbdev, info, CONTROL_BUFFER_SIZE);
>  		if (!ret) {
>  			req_ie_len = le32_to_cpu(info->req_ie_length);
> +			if (req_ie_len > CONTROL_BUFFER_SIZE)
> +				req_ie_len = CONTROL_BUFFER_SIZE;
>  			if (req_ie_len > 0) {
>  				offset = le32_to_cpu(info->offset_req_ies);
>  
> @@ -2799,6 +2802,8 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev)
>  			}
>  
>  			resp_ie_len = le32_to_cpu(info->resp_ie_length);
> +			if (resp_ie_len > CONTROL_BUFFER_SIZE)
> +				resp_ie_len = CONTROL_BUFFER_SIZE;
>  			if (resp_ie_len > 0) {
>  				offset = le32_to_cpu(info->offset_resp_ies);
> 


hi dan,
the check below  "if (resp_ie_len > 0)" looks strange for an unsigned.

re,
 wh


> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch 1/4] rndis_wlan: integer overflows in rndis_wlan_do_link_up_work()
  2012-02-29  8:21   ` walter harms
@ 2012-03-01  6:58     ` Dan Carpenter
  -1 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2012-03-01  6:58 UTC (permalink / raw)
  To: walter harms
  Cc: Jussi Kivilinna, John W. Linville, linux-wireless, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 462 bytes --]

On Wed, Feb 29, 2012 at 09:21:29AM +0100, walter harms wrote:
> >  			resp_ie_len = le32_to_cpu(info->resp_ie_length);
> > +			if (resp_ie_len > CONTROL_BUFFER_SIZE)
> > +				resp_ie_len = CONTROL_BUFFER_SIZE;
> >  			if (resp_ie_len > 0) {
> >  				offset = le32_to_cpu(info->offset_resp_ies);
> > 
> 
> 
> hi dan,
> the check below  "if (resp_ie_len > 0)" looks strange for an unsigned.
> 

Good point.  I'll resend.

regards,
dan carpenter


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch 1/4] rndis_wlan: integer overflows in rndis_wlan_do_link_up_work()
@ 2012-03-01  6:58     ` Dan Carpenter
  0 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2012-03-01  6:58 UTC (permalink / raw)
  To: walter harms
  Cc: Jussi Kivilinna, John W. Linville, linux-wireless, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 462 bytes --]

On Wed, Feb 29, 2012 at 09:21:29AM +0100, walter harms wrote:
> >  			resp_ie_len = le32_to_cpu(info->resp_ie_length);
> > +			if (resp_ie_len > CONTROL_BUFFER_SIZE)
> > +				resp_ie_len = CONTROL_BUFFER_SIZE;
> >  			if (resp_ie_len > 0) {
> >  				offset = le32_to_cpu(info->offset_resp_ies);
> > 
> 
> 
> hi dan,
> the check below  "if (resp_ie_len > 0)" looks strange for an unsigned.
> 

Good point.  I'll resend.

regards,
dan carpenter


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [patch 1/4 v2] rndis_wlan: integer overflows in rndis_wlan_do_link_up_work()
  2012-02-29  8:21   ` walter harms
@ 2012-03-01  7:02     ` Dan Carpenter
  -1 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2012-03-01  7:02 UTC (permalink / raw)
  To: walter harms
  Cc: Jussi Kivilinna, John W. Linville, linux-wireless, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1929 bytes --]

If "offset" is negative then we can get past this check:
	if (offset > CONTROL_BUFFER_SIZE)
Or if we pick a very high "req_ie_len" then we can get around the check:
	if (offset + req_ie_len > CONTROL_BUFFER_SIZE)

I made "resp_ie_len" and "req_ie_len" unsigned.  I don't know if it was
intentional that they were signed in the original.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: Fixed a style issue for Walter Harms.  Changed > 0 to != 0.

diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index a330c69..dde45ef 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -2755,9 +2755,10 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev)
 	struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
 	struct ndis_80211_assoc_info *info = NULL;
 	u8 bssid[ETH_ALEN];
-	int resp_ie_len, req_ie_len;
+	unsigned int resp_ie_len, req_ie_len;
+	unsigned int offset;
 	u8 *req_ie, *resp_ie;
-	int ret, offset;
+	int ret;
 	bool roamed = false;
 	bool match_bss;
 
@@ -2785,7 +2786,9 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev)
 		ret = get_association_info(usbdev, info, CONTROL_BUFFER_SIZE);
 		if (!ret) {
 			req_ie_len = le32_to_cpu(info->req_ie_length);
-			if (req_ie_len > 0) {
+			if (req_ie_len > CONTROL_BUFFER_SIZE)
+				req_ie_len = CONTROL_BUFFER_SIZE;
+			if (req_ie_len != 0) {
 				offset = le32_to_cpu(info->offset_req_ies);
 
 				if (offset > CONTROL_BUFFER_SIZE)
@@ -2799,7 +2802,9 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev)
 			}
 
 			resp_ie_len = le32_to_cpu(info->resp_ie_length);
-			if (resp_ie_len > 0) {
+			if (resp_ie_len > CONTROL_BUFFER_SIZE)
+				resp_ie_len = CONTROL_BUFFER_SIZE;
+			if (resp_ie_len != 0) {
 				offset = le32_to_cpu(info->offset_resp_ies);
 
 				if (offset > CONTROL_BUFFER_SIZE)

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [patch 1/4 v2] rndis_wlan: integer overflows in rndis_wlan_do_link_up_work()
@ 2012-03-01  7:02     ` Dan Carpenter
  0 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2012-03-01  7:02 UTC (permalink / raw)
  To: walter harms
  Cc: Jussi Kivilinna, John W. Linville, linux-wireless, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1929 bytes --]

If "offset" is negative then we can get past this check:
	if (offset > CONTROL_BUFFER_SIZE)
Or if we pick a very high "req_ie_len" then we can get around the check:
	if (offset + req_ie_len > CONTROL_BUFFER_SIZE)

I made "resp_ie_len" and "req_ie_len" unsigned.  I don't know if it was
intentional that they were signed in the original.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: Fixed a style issue for Walter Harms.  Changed > 0 to != 0.

diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index a330c69..dde45ef 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -2755,9 +2755,10 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev)
 	struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
 	struct ndis_80211_assoc_info *info = NULL;
 	u8 bssid[ETH_ALEN];
-	int resp_ie_len, req_ie_len;
+	unsigned int resp_ie_len, req_ie_len;
+	unsigned int offset;
 	u8 *req_ie, *resp_ie;
-	int ret, offset;
+	int ret;
 	bool roamed = false;
 	bool match_bss;
 
@@ -2785,7 +2786,9 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev)
 		ret = get_association_info(usbdev, info, CONTROL_BUFFER_SIZE);
 		if (!ret) {
 			req_ie_len = le32_to_cpu(info->req_ie_length);
-			if (req_ie_len > 0) {
+			if (req_ie_len > CONTROL_BUFFER_SIZE)
+				req_ie_len = CONTROL_BUFFER_SIZE;
+			if (req_ie_len != 0) {
 				offset = le32_to_cpu(info->offset_req_ies);
 
 				if (offset > CONTROL_BUFFER_SIZE)
@@ -2799,7 +2802,9 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev)
 			}
 
 			resp_ie_len = le32_to_cpu(info->resp_ie_length);
-			if (resp_ie_len > 0) {
+			if (resp_ie_len > CONTROL_BUFFER_SIZE)
+				resp_ie_len = CONTROL_BUFFER_SIZE;
+			if (resp_ie_len != 0) {
 				offset = le32_to_cpu(info->offset_resp_ies);
 
 				if (offset > CONTROL_BUFFER_SIZE)

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [patch 1/4 v2] rndis_wlan: integer overflows in rndis_wlan_do_link_up_work()
  2012-03-01  7:02     ` Dan Carpenter
@ 2012-03-01  9:51       ` bojan prtvar
  -1 siblings, 0 replies; 14+ messages in thread
From: bojan prtvar @ 2012-03-01  9:51 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: walter harms, Jussi Kivilinna, John W. Linville, linux-wireless,
	kernel-janitors

Hi,


On Thu, Mar 1, 2012 at 8:02 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
>
>
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v2: Fixed a style issue for Walter Harms.  Changed > 0 to != 0.
>

Why not just  if (req_ie_len) and if (resp_ie_len) ?

Regards,
Bojan

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch 1/4 v2] rndis_wlan: integer overflows in rndis_wlan_do_link_up_work()
@ 2012-03-01  9:51       ` bojan prtvar
  0 siblings, 0 replies; 14+ messages in thread
From: bojan prtvar @ 2012-03-01  9:51 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: walter harms, Jussi Kivilinna, John W. Linville, linux-wireless,
	kernel-janitors

Hi,


On Thu, Mar 1, 2012 at 8:02 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
>
>
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v2: Fixed a style issue for Walter Harms.  Changed > 0 to != 0.
>

Why not just  if (req_ie_len) and if (resp_ie_len) ?

Regards,
Bojan

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch 1/4] rndis_wlan: integer overflows in rndis_wlan_do_link_up_work()
  2012-02-29  6:35 ` Dan Carpenter
@ 2012-03-01 10:19   ` Jussi Kivilinna
  -1 siblings, 0 replies; 14+ messages in thread
From: Jussi Kivilinna @ 2012-03-01 10:19 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: John W. Linville, linux-wireless, kernel-janitors

Quoting Dan Carpenter <dan.carpenter@oracle.com>:

> If "offset" is negative then we can get past this check:
> 	if (offset > CONTROL_BUFFER_SIZE)
> Or if we pick a very high "req_ie_len" then we can get around the check:
> 	if (offset + req_ie_len > CONTROL_BUFFER_SIZE)
>
> I made "resp_ie_len" and "req_ie_len" unsigned.  I don't know if it was
> intentional that they were signed in the original.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/net/wireless/rndis_wlan.c  
> b/drivers/net/wireless/rndis_wlan.c
> index a330c69..6d8a986 100644
> --- a/drivers/net/wireless/rndis_wlan.c
> +++ b/drivers/net/wireless/rndis_wlan.c
> @@ -2755,9 +2755,10 @@ static void rndis_wlan_do_link_up_work(struct  
> usbnet *usbdev)
>  	struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
>  	struct ndis_80211_assoc_info *info = NULL;
>  	u8 bssid[ETH_ALEN];
> -	int resp_ie_len, req_ie_len;
> +	unsigned int resp_ie_len, req_ie_len;
> +	unsigned int offset;
>  	u8 *req_ie, *resp_ie;
> -	int ret, offset;
> +	int ret;
>  	bool roamed = false;
>  	bool match_bss;
>
> @@ -2785,6 +2786,8 @@ static void rndis_wlan_do_link_up_work(struct  
> usbnet *usbdev)
>  		ret = get_association_info(usbdev, info, CONTROL_BUFFER_SIZE);
>  		if (!ret) {
>  			req_ie_len = le32_to_cpu(info->req_ie_length);
> +			if (req_ie_len > CONTROL_BUFFER_SIZE)
> +				req_ie_len = CONTROL_BUFFER_SIZE;
>  			if (req_ie_len > 0) {
>  				offset = le32_to_cpu(info->offset_req_ies);
>
> @@ -2799,6 +2802,8 @@ static void rndis_wlan_do_link_up_work(struct  
> usbnet *usbdev)
>  			}
>
>  			resp_ie_len = le32_to_cpu(info->resp_ie_length);
> +			if (resp_ie_len > CONTROL_BUFFER_SIZE)
> +				resp_ie_len = CONTROL_BUFFER_SIZE;
>  			if (resp_ie_len > 0) {

(resp_ie_len > 0), (resp_ie_len != 0), (resp_ie_len) .. all fine by me,

Acked-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>

>  				offset = le32_to_cpu(info->offset_resp_ies);
>
>
>




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch 1/4] rndis_wlan: integer overflows in rndis_wlan_do_link_up_work()
@ 2012-03-01 10:19   ` Jussi Kivilinna
  0 siblings, 0 replies; 14+ messages in thread
From: Jussi Kivilinna @ 2012-03-01 10:19 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: John W. Linville, linux-wireless, kernel-janitors

Quoting Dan Carpenter <dan.carpenter@oracle.com>:

> If "offset" is negative then we can get past this check:
> 	if (offset > CONTROL_BUFFER_SIZE)
> Or if we pick a very high "req_ie_len" then we can get around the check:
> 	if (offset + req_ie_len > CONTROL_BUFFER_SIZE)
>
> I made "resp_ie_len" and "req_ie_len" unsigned.  I don't know if it was
> intentional that they were signed in the original.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/net/wireless/rndis_wlan.c  
> b/drivers/net/wireless/rndis_wlan.c
> index a330c69..6d8a986 100644
> --- a/drivers/net/wireless/rndis_wlan.c
> +++ b/drivers/net/wireless/rndis_wlan.c
> @@ -2755,9 +2755,10 @@ static void rndis_wlan_do_link_up_work(struct  
> usbnet *usbdev)
>  	struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
>  	struct ndis_80211_assoc_info *info = NULL;
>  	u8 bssid[ETH_ALEN];
> -	int resp_ie_len, req_ie_len;
> +	unsigned int resp_ie_len, req_ie_len;
> +	unsigned int offset;
>  	u8 *req_ie, *resp_ie;
> -	int ret, offset;
> +	int ret;
>  	bool roamed = false;
>  	bool match_bss;
>
> @@ -2785,6 +2786,8 @@ static void rndis_wlan_do_link_up_work(struct  
> usbnet *usbdev)
>  		ret = get_association_info(usbdev, info, CONTROL_BUFFER_SIZE);
>  		if (!ret) {
>  			req_ie_len = le32_to_cpu(info->req_ie_length);
> +			if (req_ie_len > CONTROL_BUFFER_SIZE)
> +				req_ie_len = CONTROL_BUFFER_SIZE;
>  			if (req_ie_len > 0) {
>  				offset = le32_to_cpu(info->offset_req_ies);
>
> @@ -2799,6 +2802,8 @@ static void rndis_wlan_do_link_up_work(struct  
> usbnet *usbdev)
>  			}
>
>  			resp_ie_len = le32_to_cpu(info->resp_ie_length);
> +			if (resp_ie_len > CONTROL_BUFFER_SIZE)
> +				resp_ie_len = CONTROL_BUFFER_SIZE;
>  			if (resp_ie_len > 0) {

(resp_ie_len > 0), (resp_ie_len != 0), (resp_ie_len) .. all fine by me,

Acked-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>

>  				offset = le32_to_cpu(info->offset_resp_ies);
>
>
>




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch 1/4 v2] rndis_wlan: integer overflows in rndis_wlan_do_link_up_work()
  2012-03-01  9:51       ` bojan prtvar
@ 2012-03-01 12:57         ` Dan Carpenter
  -1 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2012-03-01 12:57 UTC (permalink / raw)
  To: bojan prtvar
  Cc: walter harms, Jussi Kivilinna, John W. Linville, linux-wireless,
	kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 825 bytes --]

On Thu, Mar 01, 2012 at 10:51:37AM +0100, bojan prtvar wrote:
> Hi,
> 
> 
> On Thu, Mar 1, 2012 at 8:02 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> >
> >
> >
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > v2: Fixed a style issue for Walter Harms.  Changed > 0 to != 0.
> >
> 
> Why not just  if (req_ie_len) and if (resp_ie_len) ?
> 

It could go either way.  I wrote it that way first, then I decided
that zero was a special enough case to draw attention to it.  In
this case it felt like zero was its own thing.

For allocation failures I would do:
	foo = kmalloc();
	if (!foo)
		return -ENOMEM;
Allocation failures are not interesting and the NULL doesn't have a
special meaning and doesn't need explanation.

Hard to explain.

regards,
dan carpenter

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch 1/4 v2] rndis_wlan: integer overflows in rndis_wlan_do_link_up_work()
@ 2012-03-01 12:57         ` Dan Carpenter
  0 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2012-03-01 12:57 UTC (permalink / raw)
  To: bojan prtvar
  Cc: walter harms, Jussi Kivilinna, John W. Linville, linux-wireless,
	kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 825 bytes --]

On Thu, Mar 01, 2012 at 10:51:37AM +0100, bojan prtvar wrote:
> Hi,
> 
> 
> On Thu, Mar 1, 2012 at 8:02 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> >
> >
> >
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > v2: Fixed a style issue for Walter Harms.  Changed > 0 to != 0.
> >
> 
> Why not just  if (req_ie_len) and if (resp_ie_len) ?
> 

It could go either way.  I wrote it that way first, then I decided
that zero was a special enough case to draw attention to it.  In
this case it felt like zero was its own thing.

For allocation failures I would do:
	foo = kmalloc();
	if (!foo)
		return -ENOMEM;
Allocation failures are not interesting and the NULL doesn't have a
special meaning and doesn't need explanation.

Hard to explain.

regards,
dan carpenter

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-03-01 12:57 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-29  6:35 [patch 1/4] rndis_wlan: integer overflows in rndis_wlan_do_link_up_work() Dan Carpenter
2012-02-29  6:35 ` Dan Carpenter
2012-02-29  8:21 ` walter harms
2012-02-29  8:21   ` walter harms
2012-03-01  6:58   ` Dan Carpenter
2012-03-01  6:58     ` Dan Carpenter
2012-03-01  7:02   ` [patch 1/4 v2] " Dan Carpenter
2012-03-01  7:02     ` Dan Carpenter
2012-03-01  9:51     ` bojan prtvar
2012-03-01  9:51       ` bojan prtvar
2012-03-01 12:57       ` Dan Carpenter
2012-03-01 12:57         ` Dan Carpenter
2012-03-01 10:19 ` [patch 1/4] " Jussi Kivilinna
2012-03-01 10:19   ` Jussi Kivilinna

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.