kernel-fxtec-pro1x/include
Yi Yang 06b2a76d25 Add new string functions strict_strto* and convert kernel params to use them
Currently, for every sysfs node, the callers will be responsible for
implementing store operation, so many many callers are doing duplicate
things to validate input, they have the same mistakes because they are
calling simple_strtol/ul/ll/uul, especially for module params, they are
just numeric, but you can echo such values as 0x1234xxx, 07777888 and
1234aaa, for these cases, module params store operation just ignores
succesive invalid char and converts prefix part to a numeric although input
is acctually invalid.

This patch tries to fix the aforementioned issues and implements
strict_strtox serial functions, kernel/params.c uses them to strictly
validate input, so module params will reject such values as 0x1234xxxx and
returns an error:

write error: Invalid argument

Any modules which export numeric sysfs node can use strict_strtox instead of
simple_strtox to reject any invalid input.

Here are some test results:

Before applying this patch:

[root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
4096
[root@yangyi-dev /]# echo 0x1000 > /sys/module/e1000/parameters/copybreak
[root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
4096
[root@yangyi-dev /]# echo 0x1000g > /sys/module/e1000/parameters/copybreak
[root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
4096
[root@yangyi-dev /]# echo 0x1000gggggggg > /sys/module/e1000/parameters/copybreak
[root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
4096
[root@yangyi-dev /]# echo 010000 > /sys/module/e1000/parameters/copybreak
[root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
4096
[root@yangyi-dev /]# echo 0100008 > /sys/module/e1000/parameters/copybreak
[root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
4096
[root@yangyi-dev /]# echo 010000aaaaa > /sys/module/e1000/parameters/copybreak
[root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
4096
[root@yangyi-dev /]#

After applying this patch:

[root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
4096
[root@yangyi-dev /]# echo 0x1000 > /sys/module/e1000/parameters/copybreak
[root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
4096
[root@yangyi-dev /]# echo 0x1000g > /sys/module/e1000/parameters/copybreak
-bash: echo: write error: Invalid argument
[root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
4096
[root@yangyi-dev /]# echo 0x1000gggggggg > /sys/module/e1000/parameters/copybreak
-bash: echo: write error: Invalid argument
[root@yangyi-dev /]# echo 010000 > /sys/module/e1000/parameters/copybreak
[root@yangyi-dev /]# echo 0100008 > /sys/module/e1000/parameters/copybreak
-bash: echo: write error: Invalid argument
[root@yangyi-dev /]# echo 010000aaaaa > /sys/module/e1000/parameters/copybreak
-bash: echo: write error: Invalid argument
[root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
4096
[root@yangyi-dev /]# echo -n 4096 > /sys/module/e1000/parameters/copybreak
[root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
4096
[root@yangyi-dev /]#

[akpm@linux-foundation.org: fix compiler warnings]
[akpm@linux-foundation.org: fix off-by-one found by tiwai@suse.de]
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Cc: Greg KH <greg@kroah.com>
Cc: "Randy.Dunlap" <rdunlap@xenotime.net>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-08 09:22:41 -08:00
..
acpi Merge branches 'release' and 'fluff' into release 2008-02-07 03:38:22 -05:00
asm-alpha avoid overflows in kernel/time.c 2008-02-08 09:22:39 -08:00
asm-arm asm-*/posix_types.h: scrub __GLIBC__ 2008-02-08 09:22:34 -08:00
asm-avr32 Basic PWM driver for AVR32 and AT91 2008-02-08 09:22:38 -08:00
asm-blackfin asm-*/posix_types.h: scrub __GLIBC__ 2008-02-08 09:22:34 -08:00
asm-cris avoid overflows in kernel/time.c 2008-02-08 09:22:39 -08:00
asm-frv avoid overflows in kernel/time.c 2008-02-08 09:22:39 -08:00
asm-generic asm-generic: remove fastcall 2008-02-08 09:22:31 -08:00
asm-h8300 avoid overflows in kernel/time.c 2008-02-08 09:22:39 -08:00
asm-ia64 aout: move STACK_TOP[_MAX] to asm/processor.h 2008-02-08 09:22:29 -08:00
asm-m32r avoid overflows in kernel/time.c 2008-02-08 09:22:39 -08:00
asm-m68k avoid overflows in kernel/time.c 2008-02-08 09:22:39 -08:00
asm-m68knommu avoid overflows in kernel/time.c 2008-02-08 09:22:39 -08:00
asm-mips asm-*/posix_types.h: scrub __GLIBC__ 2008-02-08 09:22:34 -08:00
asm-mn10300 mn10300: add the MN10300/AM33 architecture to the kernel 2008-02-08 09:22:30 -08:00
asm-parisc asm-*/posix_types.h: scrub __GLIBC__ 2008-02-08 09:22:34 -08:00
asm-powerpc asm-*/posix_types.h: scrub __GLIBC__ 2008-02-08 09:22:34 -08:00
asm-ppc Add cmpxchg_local to ppc 2008-02-07 08:42:32 -08:00
asm-s390 aout: move STACK_TOP[_MAX] to asm/processor.h 2008-02-08 09:22:29 -08:00
asm-sh aout: move STACK_TOP[_MAX] to asm/processor.h 2008-02-08 09:22:29 -08:00
asm-sparc avoid overflows in kernel/time.c 2008-02-08 09:22:39 -08:00
asm-sparc64 asm-*/posix_types.h: scrub __GLIBC__ 2008-02-08 09:22:34 -08:00
asm-um aout: suppress A.OUT library support if !CONFIG_ARCH_SUPPORTS_AOUT 2008-02-08 09:22:30 -08:00
asm-v850 avoid overflows in kernel/time.c 2008-02-08 09:22:39 -08:00
asm-x86 asm-*/posix_types.h: scrub __GLIBC__ 2008-02-08 09:22:34 -08:00
asm-xtensa avoid overflows in kernel/time.c 2008-02-08 09:22:39 -08:00
crypto
keys
linux Add new string functions strict_strto* and convert kernel params to use them 2008-02-08 09:22:41 -08:00
math-emu
media include/media/: Spelling fixes 2008-02-03 17:19:47 +02:00
mtd Merge git://git.infradead.org/~dedekind/ubi-2.6 2008-02-03 22:07:40 +11:00
net 9p: add support for sticky bit 2008-02-06 19:25:06 -06:00
pcmcia pcmcia: replace kio_addr_t with unsigned int everywhere 2008-02-05 09:44:08 -08:00
rdma
rxrpc
scsi [SCSI] Small cleanups for scsi_host.h 2008-02-07 18:02:43 -06:00
sound [ALSA] version 1.0.16rc2 2008-01-31 17:40:18 +01:00
video atmel_lcdfb: backlight control 2008-02-06 10:41:16 -08:00
xen x86: page.h: make pte_t a union to always include 2008-01-30 13:32:57 +01:00
Kbuild