Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1669928
| From | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: __user with scalar data types |
| Date | 2017-06-19 22:40 +0200 |
| Message-ID | <tUbCO-7vX-19@gated-at.bofh.it> (permalink) |
| References | <tU7ze-4Y3-59@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Mon, Jun 19, 2017 at 10:15:09AM -0600, Jordan Crouse wrote:
> struct uapistruct {
> ...
> __u64 __user myptr;
> ---
> };
>
> And then converting it for use in the kernel as such:
>
> {
> void __user *userptr = (void __user *)(uintptr_t)args->myptr;
>
> copy_from_user(local, userptr, size);
> ...
> }
>
> The problem is that sparse doesn't like the momentary switch to
> uintptr_t:
>
> warning: dereference of noderef expression
This warning doesn't come from the cast to uintptr_t but
simply from dereferencing the field which can't be dereferenced
since it's marked as '__user'. In other words, doing
'args->myptr' rightfully trigger the warning and no cast
will or should stop that.
Also, you can't expect the '__user' to be transmitted from
'myptr' to the pointer (without taking the address of 'myptr').
It's exactly like 'const int' vs. 'const int *': the '__user' or
the 'const' is not at the same level in the type hierarchy
('const object' vs. 'non-const pointer to const object').
-- Luc Van Oostenryck
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
__user with scalar data types Jordan Crouse <jcrouse@codeaurora.org> - 2017-06-19 18:20 +0200
Re: __user with scalar data types Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-19 18:40 +0200
Re: __user with scalar data types Daniel Vetter <daniel@ffwll.ch> - 2017-06-20 09:20 +0200
Re: __user with scalar data types Gerd Hoffmann <kraxel@redhat.com> - 2017-06-20 09:50 +0200
Re: __user with scalar data types Daniel Vetter <daniel@ffwll.ch> - 2017-06-20 10:40 +0200
Re: __user with scalar data types Luc Van Oostenryck <luc.vanoostenryck@gmail.com> - 2017-06-19 21:30 +0200
Re: __user with scalar data types Luc Van Oostenryck <luc.vanoostenryck@gmail.com> - 2017-06-19 22:40 +0200
Re: __user with scalar data types Al Viro <viro@ZenIV.linux.org.uk> - 2017-06-19 22:50 +0200
Re: __user with scalar data types Luc Van Oostenryck <luc.vanoostenryck@gmail.com> - 2017-06-20 00:40 +0200
csiph-web