* [PATCH] staging: wlan-ng: Fixed incorrect type warning in p80211netdev.c @ 2021-02-17 15:42 Pritthijit Nath 2021-02-17 15:53 ` Greg KH ` (2 more replies) 0 siblings, 3 replies; 5+ messages in thread From: Pritthijit Nath @ 2021-02-17 15:42 UTC (permalink / raw) To: gregkh; +Cc: devel, linux-kernel, Pritthijit Nath This change fixes a sparse warning "incorrect type in argument 1 (different address spaces)". Signed-off-by: Pritthijit Nath <pritthijit.nath@icloud.com> --- drivers/staging/wlan-ng/p80211netdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c index 6f9666dc0277..70570e8a5ad2 100644 --- a/drivers/staging/wlan-ng/p80211netdev.c +++ b/drivers/staging/wlan-ng/p80211netdev.c @@ -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; -- 2.25.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: wlan-ng: Fixed incorrect type warning in p80211netdev.c 2021-02-17 15:42 [PATCH] staging: wlan-ng: Fixed incorrect type warning in p80211netdev.c Pritthijit Nath @ 2021-02-17 15:53 ` Greg KH 2021-02-17 16:27 ` Pritthijit Nath 2021-02-18 12:04 ` Dan Carpenter 2021-02-19 7:37 ` Ivan Safonov 2 siblings, 1 reply; 5+ messages in thread From: Greg KH @ 2021-02-17 15:53 UTC (permalink / raw) To: Pritthijit Nath; +Cc: devel, linux-kernel On Wed, Feb 17, 2021 at 09:12:55PM +0530, Pritthijit Nath wrote: > This change fixes a sparse warning "incorrect type in argument 1 > (different address spaces)". > > Signed-off-by: Pritthijit Nath <pritthijit.nath@icloud.com> > --- > drivers/staging/wlan-ng/p80211netdev.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c > index 6f9666dc0277..70570e8a5ad2 100644 > --- a/drivers/staging/wlan-ng/p80211netdev.c > +++ b/drivers/staging/wlan-ng/p80211netdev.c > @@ -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); Odd. Why isn't data tagged as a __user pointer to start with? thanks, greg k-h ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: wlan-ng: Fixed incorrect type warning in p80211netdev.c 2021-02-17 15:53 ` Greg KH @ 2021-02-17 16:27 ` Pritthijit Nath 0 siblings, 0 replies; 5+ messages in thread From: Pritthijit Nath @ 2021-02-17 16:27 UTC (permalink / raw) To: Greg KH; +Cc: devel, linux-kernel On 17/02/21 9:23 pm, Greg KH wrote: > On Wed, Feb 17, 2021 at 09:12:55PM +0530, Pritthijit Nath wrote: >> This change fixes a sparse warning "incorrect type in argument 1 >> (different address spaces)". >> >> Signed-off-by: Pritthijit Nath <pritthijit.nath@icloud.com> >> --- >> drivers/staging/wlan-ng/p80211netdev.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c >> index 6f9666dc0277..70570e8a5ad2 100644 >> --- a/drivers/staging/wlan-ng/p80211netdev.c >> +++ b/drivers/staging/wlan-ng/p80211netdev.c >> @@ -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); > > Odd. Why isn't data tagged as a __user pointer to start with? > > thanks, > > greg k-h > In lines 540-548 -> ... static int p80211knetdev_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) { int result = 0; struct p80211ioctl_req *req = (struct p80211ioctl_req *)ifr; struct wlandevice *wlandev = dev->ml_priv; u8 *msgbuf; netdev_dbg(dev, "rx'd ioctl, cmd=%d, len=%d\n", cmd, req->len); ... it can be seen that *req is essentially coming from an explicit cast of *ifr. ifr->data itself is of char* type. So, imo, an explicit __user pointer cast is required. The patch above was based on the __user pointer cast done in lines 580-586 -> ... if (result == 0) { if (copy_to_user ((void __user *)req->data, msgbuf, req->len)) { result = -EFAULT; } } kfree(msgbuf); ... and lines 550-556 -> #ifdef SIOCETHTOOL if (cmd == SIOCETHTOOL) { result = p80211netdev_ethtool(wlandev, (void __user *)ifr->ifr_data); goto bail; } #endif ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: wlan-ng: Fixed incorrect type warning in p80211netdev.c 2021-02-17 15:42 [PATCH] staging: wlan-ng: Fixed incorrect type warning in p80211netdev.c Pritthijit Nath 2021-02-17 15:53 ` Greg KH @ 2021-02-18 12:04 ` Dan Carpenter 2021-02-19 7:37 ` Ivan Safonov 2 siblings, 0 replies; 5+ messages in thread From: Dan Carpenter @ 2021-02-18 12:04 UTC (permalink / raw) To: Pritthijit Nath; +Cc: gregkh, devel, linux-kernel On Wed, Feb 17, 2021 at 09:12:55PM +0530, Pritthijit Nath wrote: > This change fixes a sparse warning "incorrect type in argument 1 > (different address spaces)". > > Signed-off-by: Pritthijit Nath <pritthijit.nath@icloud.com> > --- > drivers/staging/wlan-ng/p80211netdev.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c > index 6f9666dc0277..70570e8a5ad2 100644 > --- a/drivers/staging/wlan-ng/p80211netdev.c > +++ b/drivers/staging/wlan-ng/p80211netdev.c > @@ -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); Probably the correct fix is to just change the type of (struct p80211ioctl_req)->data from caddr_t to "void __user *data;". I haven't looked at this though, so double check. regards, dan carpenter ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: wlan-ng: Fixed incorrect type warning in p80211netdev.c 2021-02-17 15:42 [PATCH] staging: wlan-ng: Fixed incorrect type warning in p80211netdev.c Pritthijit Nath 2021-02-17 15:53 ` Greg KH 2021-02-18 12:04 ` Dan Carpenter @ 2021-02-19 7:37 ` Ivan Safonov 2 siblings, 0 replies; 5+ messages in thread From: Ivan Safonov @ 2021-02-19 7:37 UTC (permalink / raw) To: Greg Kroah-Hartman; +Cc: devel, linux-kernel, Dan Carpenter, Pritthijit Nath On 2/17/21 6:42 PM, pritthijit.nath at icloud.com (Pritthijit Nath) wrote: > This change fixes a sparse warning "incorrect type in argument 1 > (different address spaces)". > > Signed-off-by: Pritthijit Nath <pritthijit.nath at icloud.com> > --- > drivers/staging/wlan-ng/p80211netdev.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c > index 6f9666dc0277..70570e8a5ad2 100644 > --- a/drivers/staging/wlan-ng/p80211netdev.c > +++ b/drivers/staging/wlan-ng/p80211netdev.c > @@ -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; > Reviewed-by: Ivan Safonov <insafonov@gmail.com> ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-02-19 7:38 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-02-17 15:42 [PATCH] staging: wlan-ng: Fixed incorrect type warning in p80211netdev.c Pritthijit Nath 2021-02-17 15:53 ` Greg KH 2021-02-17 16:27 ` Pritthijit Nath 2021-02-18 12:04 ` Dan Carpenter 2021-02-19 7:37 ` Ivan Safonov
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).