kernel-ark/drivers
Mikulas Patocka 31998ef193 dm: reject trailing characters in sccanf input
Device mapper uses sscanf to convert arguments to numbers. The problem is that
the way we use it ignores additional unmatched characters in the scanned string.

For example, this `if (sscanf(string, "%d", &number) == 1)' will match a number,
but also it will match number with some garbage appended, like "123abc".

As a result, device mapper accepts garbage after some numbers. For example
the command `dmsetup create vg1-new --table "0 16384 linear 254:1bla 34816bla"'
will pass without an error.

This patch fixes all sscanf uses in device mapper. It appends "%c" with
a pointer to a dummy character variable to every sscanf statement.

The construct `if (sscanf(string, "%d%c", &number, &dummy) == 1)' succeeds
only if string is a null-terminated number (optionally preceded by some
whitespace characters). If there is some character appended after the number,
sscanf matches "%c", writes the character to the dummy variable and returns 2.
We check the return value for 1 and consequently reject numbers with some
garbage appended.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Acked-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
2012-03-28 18:41:26 +01:00
..
accessibility vt:tackle kbd_table 2012-03-08 10:50:35 -08:00
acpi
amba
ata 1) AHCI regression fix. A recent "make driver conform to spec" change 2012-03-22 20:22:30 -07:00
atm eni: fix driver remove function and driver probe error path. 2012-03-16 23:13:20 -07:00
auxdisplay
base Things are really quieting down with the regmap API, while we're still 2012-03-22 20:33:14 -07:00
bcma bcma: silence PMU warning for BCM4331 2012-03-07 13:56:37 -05:00
block Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc 2012-03-21 18:55:10 -07:00
bluetooth Bluetooth: Adding USB device 13d3:3375 as an Atheros AR3012. 2012-03-08 02:16:24 -03:00
cdrom powerpc: Remove some of the legacy iSeries specific device drivers 2012-03-16 09:28:05 +11:00
char Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux 2012-03-22 13:08:22 -07:00
clk
clocksource Power management updates for 3.4 2012-03-21 10:15:51 -07:00
connector
cpufreq
cpuidle Merge branch 'perf/urgent' into perf/core 2012-03-05 09:20:08 +01:00
crypto Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux 2012-03-22 18:15:32 -07:00
dca
devfreq PM / devfreq: add relation of recommended frequency. 2012-03-17 21:51:34 +01:00
dio
dma Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2012-03-20 21:12:50 -07:00
edac edac: remove the second argument of k[un]map_atomic() 2012-03-20 21:48:17 +08:00
eisa
firewire IEEE 1394 (FireWire) subsystem updates post v3.3: 2012-03-22 20:31:15 -07:00
firmware
gpio Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc 2012-03-21 18:55:10 -07:00
gpu Merge branch 'drm-nouveau-destage' of git://people.freedesktop.org/~airlied/linux 2012-03-22 13:27:02 -07:00
hid Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2012-03-22 20:20:18 -07:00
hv Tools: hv: Support enumeration from all the pools 2012-03-16 13:36:04 -07:00
hwmon hwmon changes for v3.4 2012-03-21 10:37:25 -07:00
hwspinlock
i2c Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux 2012-03-22 13:08:22 -07:00
ide ide: remove the second argument of k[un]map_atomic() 2012-03-20 21:48:17 +08:00
idle drivers/idle/intel_idle.c: fix confusing code identation 2012-03-21 17:54:54 -07:00
ieee802154
infiniband Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending 2012-03-22 12:38:04 -07:00
input Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2012-03-22 20:20:18 -07:00
iommu Merge branch 'x86-debug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-03-22 09:30:39 -07:00
isdn Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2012-03-20 21:04:47 -07:00
leds Linux 3.3-rc7 2012-03-14 09:48:16 +01:00
lguest
macintosh Core device tree changes for Linux v3.4 2012-03-21 10:30:03 -07:00
mca
md dm: reject trailing characters in sccanf input 2012-03-28 18:41:26 +01:00
media Merge branch 'kmap_atomic' of git://github.com/congwang/linux 2012-03-21 09:40:26 -07:00
memstick memstick: remove the second argument of k[un]map_atomic() 2012-03-20 21:48:19 +08:00
message
mfd Things are really quieting down with the regmap API, while we're still 2012-03-22 20:33:14 -07:00
misc Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc 2012-03-21 18:55:10 -07:00
mmc Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2012-03-21 13:36:41 -07:00
mtd Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc 2012-03-21 18:55:10 -07:00
net Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2012-03-21 13:36:41 -07:00
nfc NFC: Remove the rf mode parameter from the DEP link up routine 2012-03-06 15:16:23 -05:00
nubus
of Core device tree changes for Linux v3.4 2012-03-21 10:30:03 -07:00
oprofile tidy up after d_make_root() conversion 2012-03-20 21:29:37 -04:00
parisc
parport
pci Features: 2012-03-22 20:16:14 -07:00
pcmcia Merge 3.3-rc6 into driver-core-next 2012-03-09 12:35:53 -08:00
pinctrl pinctrl: support pinconfig on the U300 2012-03-12 22:49:03 +01:00
platform Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-03-22 09:43:22 -07:00
pnp
power Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2012-03-20 21:12:50 -07:00
pps pps: class_create() returns an ERR_PTR, not NULL 2012-03-05 15:49:43 -08:00
ps3
ptp phc: Update author's email address. 2012-03-17 01:41:43 -07:00
rapidio rapidio/tsi721: fix bug in register offset definitions 2012-03-15 17:03:03 -07:00
regulator regulator: Updates for 3.4 2012-03-21 10:34:56 -07:00
rtc Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-03-20 10:32:09 -07:00
s390 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux 2012-03-22 18:15:32 -07:00
sbus
scsi SCSI updates on 20120319 2012-03-22 12:55:29 -07:00
sfi
sh
sn
spi SPI changes for v3.4. 2012-03-21 10:32:00 -07:00
ssb Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2012-03-20 21:04:47 -07:00
staging Cleanups: rename of flush to invalidate, moving reporting of statistics 2012-03-22 19:52:47 -07:00
target Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending 2012-03-22 12:38:04 -07:00
tc
thermal
tty Pinctrl updates for v3.4: 2012-03-22 20:25:50 -07:00
uio
usb Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2012-03-21 13:36:41 -07:00
uwb
vhost vhost: remove the second argument of k[un]map_atomic() 2012-03-20 21:48:21 +08:00
video fbdev updates for 3.4 2012-03-22 20:43:40 -07:00
virt
virtio
vlynq
w1 DS2781 Maxim Stand-Alone Fuel Gauge battery and w1 slave drivers 2012-03-08 11:15:33 -08:00
watchdog Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc 2012-03-21 18:55:10 -07:00
xen Features: 2012-03-22 20:16:14 -07:00
zorro
Kconfig
Makefile