From: Jaco Kroon <jaco@kroon.co.za>
To: kernel-janitors@vger.kernel.org
Subject: Re: [KJ] proper casting (if any) in copy_to_user() calls?
Date: Sat, 06 Jan 2007 07:47:26 +0000 [thread overview]
Message-ID: <459F540E.90707@kroon.co.za> (raw)
In-Reply-To: <Pine.LNX.4.64.0701050850140.1045@localhost.localdomain>
[-- Attachment #1.1: Type: text/plain, Size: 1634 bytes --]
Ahmed S. Darwish wrote:
> On Fri, Jan 05, 2007 at 08:54:28AM -0500, Robert P. J. Day wrote:
>
>>you'll notice that numerous calls to copy_to_user() insist on casting
>>the pointer type of the first argument, despite the fact that that
>>first pointer is declared as being of type "void __user *" for the
>>routine itself, so it would seem no pointer is casting is required.
>>
>> and yet, you can see that calls to copy_to_user() are casting the
>>first argument to (among other types) "char *" and "char __user *" and
>>"void *" and "void __user *" and "unsigned long *" and ... well, you
>>get the idea. (the same can be said for the second argument to
>>copy_from_user().)
>>
>> what is the proper rule for casting in this situation? one would
>>think most of those casts are totally superfluous, no?
>
>
> I've written a patch to remove 30 unneeded copy_to_user casts in the infinband
> subsystem (drivers/infiniband/core) and the result ?. I got 30 warning from
> gcc while compiling :(.
>
> The reason of the warnings was that the first argument of copy_to_user is
> unsigned long and not a pointer. so I get the infamous warning:
> warning: passing argument 1 of ‘copy_to_user’ makes pointer from integer
> without a cast
>
> So Janitors, I think it's better to remove the casts _only_ when the given
> argument is a pointer and not an unsigned long (why do people use unsigned
> long and not void* in the beginning anyway ?).
To prevent dereferencing an __user pointer? But then imho that should
be standard right through the kernel and copy_(to,from)_user should take
unsigned long to begin with.
Jaco
[-- Attachment #1.2: S/MIME Cryptographic Signature --]
[-- Type: application/x-pkcs7-signature, Size: 3233 bytes --]
[-- Attachment #2: Type: text/plain, Size: 168 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
next prev parent reply other threads:[~2007-01-06 7:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-05 13:54 [KJ] proper casting (if any) in copy_to_user() calls? Robert P. J. Day
2007-01-06 6:31 ` Ahmed S. Darwish
2007-01-06 7:47 ` Jaco Kroon [this message]
2007-01-06 8:23 ` Robert P. J. Day
2007-01-06 9:07 ` Robert P. J. Day
2007-01-06 11:32 ` Jaco Kroon
2007-01-08 13:11 ` Thomas Petazzoni
2007-01-08 16:15 ` Jaco Kroon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=459F540E.90707@kroon.co.za \
--to=jaco@kroon.co.za \
--cc=kernel-janitors@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.