* proper way to annotate kernel use of sys_xxx?
@ 2004-10-05 5:28 Roland Dreier
2004-10-05 8:32 ` Arnd Bergmann
0 siblings, 1 reply; 3+ messages in thread
From: Roland Dreier @ 2004-10-05 5:28 UTC (permalink / raw)
To: linux-kernel
What is the correct way to annotate kernel code that calls a sys_xxx
function that expects a __user pointer as an argument?
To give a concrete example, sparse (among lots of other warnings for
do_mounts.c) says:
init/do_mounts.c:69:16: warning: incorrect type in argument 1 (different address spaces)
init/do_mounts.c:69:16: expected char const [noderef] *filename<asn:1>
init/do_mounts.c:69:16: got char [addressable] *<noident>
The code in question is the following:
char path[64];
/* ... */
sprintf(path, "/sys/block/%s/dev", name);
fd = sys_open(path, 0, 0); /* LINE 69 */
This is an abuse of sys_open(), but we know it's OK. Is the right way
to shut up sparse to just change it to:
fd = sys_open((const char __user *) path, 0, 0);
Thanks,
Roland
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: proper way to annotate kernel use of sys_xxx?
2004-10-05 5:28 proper way to annotate kernel use of sys_xxx? Roland Dreier
@ 2004-10-05 8:32 ` Arnd Bergmann
2004-10-05 17:23 ` Roland Dreier
0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2004-10-05 8:32 UTC (permalink / raw)
To: Roland Dreier; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 497 bytes --]
On Dienstag, 5. Oktober 2004 07:28, Roland Dreier wrote:
> This is an abuse of sys_open(), but we know it's OK. Is the right way
> to shut up sparse to just change it to:
>
> fd = sys_open((const char __user *) path, 0, 0);
>
No, that's wrong, see
http://marc.theaimsgroup.com/?l=linux-kernel&m=108697882525067 ;-)
In this case, you can easily convert the calls to use
filp_open/vfs_read/filp_close, though I'm not sure if that's
the correct solution either.
Arnd <><
[-- Attachment #2: signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: proper way to annotate kernel use of sys_xxx?
2004-10-05 8:32 ` Arnd Bergmann
@ 2004-10-05 17:23 ` Roland Dreier
0 siblings, 0 replies; 3+ messages in thread
From: Roland Dreier @ 2004-10-05 17:23 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: linux-kernel
Arnd> In this case, you can easily convert the calls to use
Arnd> filp_open/vfs_read/filp_close, though I'm not sure if that's
Arnd> the correct solution either.
For the do_mounts.c code, I see how the call to sys_open() could be
replaced with a call to filp_open(). However, vfs_read() still takes
a __user pointer for its buffer argument -- in fact, even the
filesystem .aio_read method takes a __user pointer. So I'm not sure
how this code should be fixed.
Thanks,
Roland
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-10-05 17:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-05 5:28 proper way to annotate kernel use of sys_xxx? Roland Dreier
2004-10-05 8:32 ` Arnd Bergmann
2004-10-05 17:23 ` Roland Dreier
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).