Skip to contentSkip to conversation

init: make sure syscall arguments are marked __user where needed

RFC PATCH In review H Hartley Sweeten 2 participants 5 messages Apr 17, 2012 – Apr 21, 2012

lore
Share & tools
lore
#0 lore raw

cover init: make sure syscall arguments are marked __user where needed

When using syscall routines in the kernel, some of the arguments should be user pointers but are missing the __user markup. This produces a number of sparse warnings of the format:

warning: incorrect type in argument 1 (different address spaces)
expected char [noderef] <asn:1>*dev_name
got char *name

Wrap the syscall routines in the private do_mounts.h header so that the appropriate __user markups are added for the init mount code.

init: introduce private syscall wrappers for non-user space pointers
init: use private syscall wrappers for non-user space pointers

 init/do_mounts.c        |   14 +++---
 init/do_mounts.h        |  107 ++++++++++++++++++++++++++++++++++++++++++++++-
 init/do_mounts_initrd.c |   28 ++++++------
 init/do_mounts_md.c     |    6 +-
 init/do_mounts_rd.c     |   22 +++++-----
 init/initramfs.c        |   54 ++++++++++++-----------
 init/noinitramfs.c      |    9 ++--
 7 files changed, 173 insertions(+), 67 deletions(-)
#1 lore raw
Quoted 10 lines · On Mon, 16 Apr 2012 17:33:23 -0700 H Hartley Sweeten…

When using syscall routines in the kernel, some of the arguments should be user pointers but are missing the __user markup. This produces a number of sparse warnings of the format:

warning: incorrect type in argument 1 (different address spaces)
expected char [noderef] <asn:1>*dev_name
got char *name

Wrap the syscall routines in the private do_mounts.h header so that the appropriate __user markups are added for the init mount code.

This makes rather a mess of do_mounts.c for pretty marginal benefit.

Can we just make "make C=1" skip that file or something?

#2 lore raw
Quoted 6 lines · Andrew Morton
Quoted 4 lines · On Mon, 16 Apr 2012 17:33:23 -0700 H Hartley Sweeten wrote:

When using syscall routines in the kernel, some of the arguments should be user pointers but are missing the __user markup. This produces a number of sparse warnings of the format:

Quoted 8 lines
Quoted 6 lines

warning: incorrect type in argument 1 (different address spaces)
expected char [noderef] <asn:1>*dev_name
got char *name

Wrap the syscall routines in the private do_mounts.h header so that the appropriate __user markups are added for the init mount code.

This makes rather a mess of do_mounts.c for pretty marginal benefit.

Well... That's why it was a RFC... ;-)

Quoted 1 line

Can we just make "make C=1" skip that file or something?

What about putting something like this at the top of the files:

/*
* Many of the syscalls used in this file expect some of the arguments
* to be __user pointers not __kernel pointers. To limit the sparse
* noise, turn off sparse checking for this file.
*/
#ifdef __CHECKER__
#undef __CHECKER__
#warning "Sparse checking disabled for this file"
#endif

Maybe without the warning if it doesn't seem necessary.

This keeps <linux/compiler.h> from defining the __attribute__* checks.

Regards,
Hartley

#3 lore raw
Quoted 16 lines · On Fri, 20 Apr 2012 19:05:46 -0500 H Hartley Sweeten…
Quoted 1 line

Can we just make "make C=1" skip that file or something?

What about putting something like this at the top of the files:

/*
* Many of the syscalls used in this file expect some of the arguments
* to be __user pointers not __kernel pointers. To limit the sparse
* noise, turn off sparse checking for this file.
*/
#ifdef __CHECKER__
#undef __CHECKER__
#warning "Sparse checking disabled for this file"
#endif

Quoted 3 lines

Maybe without the warning if it doesn't seem necessary.

This keeps <linux/compiler.h> from defining the __attribute__* checks.

That looks nice and explicit.

#4 lore raw
Quoted 18 lines · Andrew Morton
Quoted 16 lines · On Fri, 20 Apr 2012 19:05:46 -0500 H Hartley Sweeten wrote:
Quoted 1 line

Can we just make "make C=1" skip that file or something?

What about putting something like this at the top of the files:

/*
* Many of the syscalls used in this file expect some of the arguments
* to be __user pointers not __kernel pointers. To limit the sparse
* noise, turn off sparse checking for this file.
*/
#ifdef __CHECKER__
#undef __CHECKER__
#warning "Sparse checking disabled for this file"
#endif

Quoted 5 lines
Quoted 3 lines

Maybe without the warning if it doesn't seem necessary.

This keeps <linux/compiler.h> from defining the __attribute__* checks.

That looks nice and explicit.

Another option would be to just undef the __user and __kernel checks. That way the other sparse checks should still work.

I'll post an updated patch with the #undef __CHECKER__ method shortly.

Regards,
Hartley