Skip to contentSkip to conversation

staging: wimax: fix sparse incorrect type issue

PATCH In review karthik alapati 2 participants 4 messages Feb 20, 2021 – Feb 22, 2021 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: wimax: fix sparse incorrect type issue

fix sparse warning by casting to explicit user address-space pointer type

---
 drivers/staging/wlan-ng/p80211netdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wlan-ng/p80211netdev.c +1 -1
index 6f9666dc0..70570e8a5 100644
@@ -569,7 +569,7 @@ static int p80211knetdev_do_ioctl(struct net_device *dev,
 		goto bail;
 	}
 
-	msgbuf = memdup_user(req->data, req->len);
+	msgbuf = memdup_user((void __user *)req->data, req->len);
 	if (IS_ERR(msgbuf)) {
 		result = PTR_ERR(msgbuf);
 		goto bail;
Signature · 1 line
2.30.1
#1 lore raw
Quoted 13 lines · karthik alapati

fix sparse warning by casting to explicit user address-space pointer type

---
 drivers/staging/wlan-ng/p80211netdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wlan-ng/p80211netdev.c +0 -0
index 6f9666dc0..70570e8a5 100644

drivers/staging/wlan-ng/p80211netdev.c static int p80211knetdev_do_ioctl(struct net_device *dev, · line 572

Quoted 5 lines
drivers/staging/wlan-ng/p80211netdev.c +1 -1
@@ -569,7 +569,7 @@ static int p80211knetdev_do_ioctl(struct net_device *dev,
 		goto bail;
 	}
 
-	msgbuf = memdup_user(req->data, req->len);
+	msgbuf = memdup_user((void __user *)req->data, req->len);

This doesn't fix anything it just silences the warning. Linus Torvalds worked very hard to create Sparse for the express purpose of printing the warning. People don't realize that warnings are very valuable because they show where the bugs are.

Please look at this some more and figure out how to fix the warning.

To be honest, I'm tempted to not accept any patch which doesn't also fix the buffer overflows when we pass:

	result = p80211req_dorequest(wlandev, msgbuf);

How do we know that "msgbuf" is large enough?

regards,
dan carpenter

author
#2 lore raw
Quoted 31 lines · Dan Carpenter
Quoted 13 lines · karthik alapati

fix sparse warning by casting to explicit user address-space pointer type

---
 drivers/staging/wlan-ng/p80211netdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wlan-ng/p80211netdev.c +0 -0
index 6f9666dc0..70570e8a5 100644

drivers/staging/wlan-ng/p80211netdev.c static int p80211knetdev_do_ioctl(struct net_device *dev, · line 572

Quoted 5 lines
drivers/staging/wlan-ng/p80211netdev.c +1 -1
@@ -569,7 +569,7 @@ static int p80211knetdev_do_ioctl(struct net_device *dev,
              goto bail;
      }
 
-     msgbuf = memdup_user(req->data, req->len);
+     msgbuf = memdup_user((void __user *)req->data, req->len);

This doesn't fix anything it just silences the warning. Linus Torvalds worked very hard to create Sparse for the express purpose of printing the warning. People don't realize that warnings are very valuable because they show where the bugs are.

Please look at this some more and figure out how to fix the warning.

To be honest, I'm tempted to not accept any patch which doesn't also fix the buffer overflows when we pass:

Quoted 7 lines
        result = p80211req_dorequest(wlandev, msgbuf);

How do we know that "msgbuf" is large enough?

regards,
dan carpenter

Thanks dan but right after sending this patch i immediately replied to it stating
to ignore this patch as i found this already applied in staging-testing branch
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/commit/?h=staging-testing&id=3a8a144d2a754df45127c74e273fa166f690ba43

#3 lore raw
Quoted 36 lines · karthek
Quoted 35 lines · Dan Carpenter
Quoted 13 lines · karthik alapati

fix sparse warning by casting to explicit user address-space pointer type

---
 drivers/staging/wlan-ng/p80211netdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wlan-ng/p80211netdev.c +0 -0
index 6f9666dc0..70570e8a5 100644

drivers/staging/wlan-ng/p80211netdev.c static int p80211knetdev_do_ioctl(struct net_device *dev, · line 572

Quoted 5 lines
drivers/staging/wlan-ng/p80211netdev.c +1 -1
@@ -569,7 +569,7 @@ static int p80211knetdev_do_ioctl(struct net_device *dev,
              goto bail;
      }
 
-     msgbuf = memdup_user(req->data, req->len);
+     msgbuf = memdup_user((void __user *)req->data, req->len);

This doesn't fix anything it just silences the warning. Linus Torvalds worked very hard to create Sparse for the express purpose of printing the warning. People don't realize that warnings are very valuable because they show where the bugs are.

Please look at this some more and figure out how to fix the warning.

To be honest, I'm tempted to not accept any patch which doesn't also fix the buffer overflows when we pass:

        result = p80211req_dorequest(wlandev, msgbuf);

How do we know that "msgbuf" is large enough?

Quoted 8 lines
Quoted 3 lines

regards,
dan carpenter

Thanks dan but right after sending this patch i immediately replied to it stating
to ignore this patch as i found this already applied in staging-testing branch
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/commit/?h=staging-testing&id=3a8a144d2a754df45127c74e273fa166f690ba43

It's still possible to fix this in the correct way and fix the buffer overflows.

regards,
dan carpenter