* [PATCH] Staging: gdm72xx: Fix sparse warning
@ 2015-10-29 2:41 Ksenija Stanojevic
2015-11-04 19:06 ` [Outreachy kernel] " Greg KH
0 siblings, 1 reply; 4+ messages in thread
From: Ksenija Stanojevic @ 2015-10-29 2:41 UTC (permalink / raw)
To: outreachy-kernel; +Cc: Ksenija Stanojevic
Calls copy_{to,from}_user() do not use '__user' annotation
while refrencing user space pointers.
Fix following sparse warnings by passing missing __user annotation:
drivers/staging/gdm72xx/gdm_wimax.c:381:37: warning: incorrect type in
argument 1 (different address spaces)
drivers/staging/gdm72xx/gdm_wimax.c:381:37: expected void [noderef]
<asn:1>*to
drivers/staging/gdm72xx/gdm_wimax.c:381:37: got void *buf
drivers/staging/gdm72xx/gdm_wimax.c:404:41: warning: incorrect type in
argument 2 (different address spaces)
drivers/staging/gdm72xx/gdm_wimax.c:404:41: expected void const
[noderef] <asn:1>*from
drivers/staging/gdm72xx/gdm_wimax.c:404:41: got void *buf
Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
---
drivers/staging/gdm72xx/gdm_wimax.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c
index d9ddced..a5b4b72 100644
--- a/drivers/staging/gdm72xx/gdm_wimax.c
+++ b/drivers/staging/gdm72xx/gdm_wimax.c
@@ -378,7 +378,7 @@ static int gdm_wimax_ioctl_get_data(struct data_s *dst, struct data_s *src)
if (src->size) {
if (!dst->buf)
return -EINVAL;
- if (copy_to_user(dst->buf, src->buf, size))
+ if (copy_to_user((void __user *)dst->buf, src->buf, size))
return -EFAULT;
}
return 0;
@@ -401,7 +401,7 @@ static int gdm_wimax_ioctl_set_data(struct data_s *dst, struct data_s *src)
return -ENOMEM;
}
- if (copy_from_user(dst->buf, src->buf, src->size)) {
+ if (copy_from_user(dst->buf, (void __user *)src->buf, src->size)) {
kdelete(&dst->buf);
return -EFAULT;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [Outreachy kernel] [PATCH] Staging: gdm72xx: Fix sparse warning
2015-10-29 2:41 [PATCH] Staging: gdm72xx: Fix sparse warning Ksenija Stanojevic
@ 2015-11-04 19:06 ` Greg KH
2015-11-04 19:14 ` Ksenija Stanojević
0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2015-11-04 19:06 UTC (permalink / raw)
To: Ksenija Stanojevic; +Cc: outreachy-kernel
On Wed, Oct 28, 2015 at 07:41:18PM -0700, Ksenija Stanojevic wrote:
> Calls copy_{to,from}_user() do not use '__user' annotation
> while refrencing user space pointers.
>
> Fix following sparse warnings by passing missing __user annotation:
>
> drivers/staging/gdm72xx/gdm_wimax.c:381:37: warning: incorrect type in
> argument 1 (different address spaces)
> drivers/staging/gdm72xx/gdm_wimax.c:381:37: expected void [noderef]
> <asn:1>*to
> drivers/staging/gdm72xx/gdm_wimax.c:381:37: got void *buf
> drivers/staging/gdm72xx/gdm_wimax.c:404:41: warning: incorrect type in
> argument 2 (different address spaces)
> drivers/staging/gdm72xx/gdm_wimax.c:404:41: expected void const
> [noderef] <asn:1>*from
> drivers/staging/gdm72xx/gdm_wimax.c:404:41: got void *buf
>
> Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
> ---
> drivers/staging/gdm72xx/gdm_wimax.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c
> index d9ddced..a5b4b72 100644
> --- a/drivers/staging/gdm72xx/gdm_wimax.c
> +++ b/drivers/staging/gdm72xx/gdm_wimax.c
> @@ -378,7 +378,7 @@ static int gdm_wimax_ioctl_get_data(struct data_s *dst, struct data_s *src)
> if (src->size) {
> if (!dst->buf)
> return -EINVAL;
> - if (copy_to_user(dst->buf, src->buf, size))
> + if (copy_to_user((void __user *)dst->buf, src->buf, size))
Shouldn't the variable be described as a __user pointer instead? Don't
cast away warnings, fix the root problem.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [Outreachy kernel] [PATCH] Staging: gdm72xx: Fix sparse warning
2015-11-04 19:06 ` [Outreachy kernel] " Greg KH
@ 2015-11-04 19:14 ` Ksenija Stanojević
2015-11-04 19:21 ` Arnd Bergmann
0 siblings, 1 reply; 4+ messages in thread
From: Ksenija Stanojević @ 2015-11-04 19:14 UTC (permalink / raw)
To: Greg KH; +Cc: outreachy-kernel
On Wed, Nov 4, 2015 at 11:06 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Wed, Oct 28, 2015 at 07:41:18PM -0700, Ksenija Stanojevic wrote:
>> Calls copy_{to,from}_user() do not use '__user' annotation
>> while refrencing user space pointers.
>>
>> Fix following sparse warnings by passing missing __user annotation:
>>
>> drivers/staging/gdm72xx/gdm_wimax.c:381:37: warning: incorrect type in
>> argument 1 (different address spaces)
>> drivers/staging/gdm72xx/gdm_wimax.c:381:37: expected void [noderef]
>> <asn:1>*to
>> drivers/staging/gdm72xx/gdm_wimax.c:381:37: got void *buf
>> drivers/staging/gdm72xx/gdm_wimax.c:404:41: warning: incorrect type in
>> argument 2 (different address spaces)
>> drivers/staging/gdm72xx/gdm_wimax.c:404:41: expected void const
>> [noderef] <asn:1>*from
>> drivers/staging/gdm72xx/gdm_wimax.c:404:41: got void *buf
>>
>> Signed-off-by: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
>> ---
>> drivers/staging/gdm72xx/gdm_wimax.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c
>> index d9ddced..a5b4b72 100644
>> --- a/drivers/staging/gdm72xx/gdm_wimax.c
>> +++ b/drivers/staging/gdm72xx/gdm_wimax.c
>> @@ -378,7 +378,7 @@ static int gdm_wimax_ioctl_get_data(struct data_s *dst, struct data_s *src)
>> if (src->size) {
>> if (!dst->buf)
>> return -EINVAL;
>> - if (copy_to_user(dst->buf, src->buf, size))
>> + if (copy_to_user((void __user *)dst->buf, src->buf, size))
>
> Shouldn't the variable be described as a __user pointer instead? Don't
> cast away warnings, fix the root problem.
I don't think so because dst and src are both pointers to struct data_s
and dst->buf in one function used as user buffer and in the next one as
a kernel buffer. Same goes for src-buf.
struct data_s {
int size;
void *buf;
};
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [Outreachy kernel] [PATCH] Staging: gdm72xx: Fix sparse warning
2015-11-04 19:14 ` Ksenija Stanojević
@ 2015-11-04 19:21 ` Arnd Bergmann
0 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2015-11-04 19:21 UTC (permalink / raw)
To: outreachy-kernel; +Cc: Ksenija Stanojević, Greg KH
On Wednesday 04 November 2015 11:14:54 Ksenija Stanojević wrote:
> >>
> >> diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c
> >> index d9ddced..a5b4b72 100644
> >> --- a/drivers/staging/gdm72xx/gdm_wimax.c
> >> +++ b/drivers/staging/gdm72xx/gdm_wimax.c
> >> @@ -378,7 +378,7 @@ static int gdm_wimax_ioctl_get_data(struct data_s *dst, struct data_s *src)
> >> if (src->size) {
> >> if (!dst->buf)
> >> return -EINVAL;
> >> - if (copy_to_user(dst->buf, src->buf, size))
> >> + if (copy_to_user((void __user *)dst->buf, src->buf, size))
> >
> > Shouldn't the variable be described as a __user pointer instead? Don't
> > cast away warnings, fix the root problem.
>
> I don't think so because dst and src are both pointers to struct data_s
> and dst->buf in one function used as user buffer and in the next one as
> a kernel buffer. Same goes for src-buf.
>
> struct data_s {
> int size;
> void *buf;
> };
>
I think this should be two separate structures, one for the user-space
data and one for the kernel side.
Arnd
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-11-04 19:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-29 2:41 [PATCH] Staging: gdm72xx: Fix sparse warning Ksenija Stanojevic
2015-11-04 19:06 ` [Outreachy kernel] " Greg KH
2015-11-04 19:14 ` Ksenija Stanojević
2015-11-04 19:21 ` Arnd Bergmann
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.