kernel-ark/include
Alexey Dobriyan 9774a1f54f [PATCH] Compile-time check re world-writeable module params
One of the mistakes a module_param() user can make is to supply default
value of module parameter as the last argument.  module_param() accepts
permissions instead.  If default value is, say, 3 (-------wx), parameter
becomes world-writeable.

So far, the only remedy was to apply grep(1) and read drivers submitted
to -mm. BTDT.

With this patch applied, compiler will finally do some job.

*) bounds checking on permissions
*) world-writeable bit checking on permissions
*) compile breakage if checks trigger

First version of this check (only "& 2" part) directly caught 4 out of 7
places during my last grep.

    Subject: Neverending module_param() bugs
    [X] drivers/acpi/sbs.c:101:module_param(capacity_mode, int, CAPACITY_UNIT);
    [X] drivers/acpi/sbs.c:102:module_param(update_mode, int, UPDATE_MODE);
    [ ] drivers/acpi/sbs.c:103:module_param(update_info_mode, int, UPDATE_INFO_MODE);
    [ ] drivers/acpi/sbs.c:104:module_param(update_time, int, UPDATE_TIME);
    [ ] drivers/acpi/sbs.c:105:module_param(update_time2, int, UPDATE_TIME2);
    [X] drivers/char/watchdog/sbc8360.c:203:module_param(timeout, int, 27);
    [X] drivers/media/video/tuner-simple.c:13:module_param(offset, int, 0666);

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-07 08:39:34 -08:00
..
acpi [PATCH] slab: remove kmem_cache_t 2006-12-07 08:39:25 -08:00
asm-alpha
asm-arm
asm-arm26 [PATCH] slab: remove kmem_cache_t 2006-12-07 08:39:25 -08:00
asm-avr32
asm-cris
asm-frv
asm-generic
asm-h8300
asm-i386 [PATCH] swsusp: Support i386 systems with PAE or without PSE 2006-12-07 08:39:28 -08:00
asm-ia64 [PATCH] numa node ids are int, page_to_nid and zone_to_nid should return int 2006-12-07 08:39:23 -08:00
asm-m32r
asm-m68k
asm-m68knommu
asm-mips
asm-parisc
asm-powerpc [PATCH] slab: remove kmem_cache_t 2006-12-07 08:39:25 -08:00
asm-ppc
asm-s390
asm-sh
asm-sh64
asm-sparc
asm-sparc64 [PATCH] slab: remove kmem_cache_t 2006-12-07 08:39:25 -08:00
asm-um
asm-v850 [PATCH] fix v850 compilation 2006-12-07 08:39:29 -08:00
asm-x86_64
asm-xtensa
crypto
keys
linux [PATCH] Compile-time check re world-writeable module params 2006-12-07 08:39:34 -08:00
math-emu
media
mtd
net [PATCH] lockdep: annotate nfs/nfsd in-kernel sockets 2006-12-07 08:39:30 -08:00
pcmcia
rdma
rxrpc
scsi [PATCH] slab: remove kmem_cache_t 2006-12-07 08:39:25 -08:00
sound
video
Kbuild