kernel-ark/drivers/md
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
..
persistent-data dm persistent data: remove redundant value_size arg from value_ptr 2012-03-28 18:41:25 +01:00
bitmap.c md updates for 3.4 2012-03-22 12:29:50 -07:00
bitmap.h md/bitmap: discard CHUNK_BLOCK_SHIFT macro 2012-03-19 12:46:41 +11:00
dm-bio-record.h
dm-bufio.c dm-bufio.c: there's no need to include linux/version.h 2012-02-03 22:38:12 +01:00
dm-bufio.h dm: add bufio 2011-10-31 20:19:09 +00:00
dm-crypt.c dm: reject trailing characters in sccanf input 2012-03-28 18:41:26 +01:00
dm-delay.c dm: reject trailing characters in sccanf input 2012-03-28 18:41:26 +01:00
dm-exception-store.c dm exception store: fix init error path 2012-03-28 18:41:22 +01:00
dm-exception-store.h
dm-flakey.c dm: reject trailing characters in sccanf input 2012-03-28 18:41:26 +01:00
dm-io.c dm io: fix discard support 2012-03-07 19:09:37 +00:00
dm-ioctl.c dm: reject trailing characters in sccanf input 2012-03-28 18:41:26 +01:00
dm-kcopyd.c dm kcopyd: add dm_kcopyd_zero to zero an area 2011-10-31 20:18:58 +00:00
dm-linear.c dm: reject trailing characters in sccanf input 2012-03-28 18:41:26 +01:00
dm-log-userspace-base.c Merge branch 'modsplit-Oct31_2011' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux 2011-11-06 19:44:47 -08:00
dm-log-userspace-transfer.c
dm-log-userspace-transfer.h
dm-log.c dm: reject trailing characters in sccanf input 2012-03-28 18:41:26 +01:00
dm-mpath.c dm: reject trailing characters in sccanf input 2012-03-28 18:41:26 +01:00
dm-mpath.h
dm-path-selector.c md: Add module.h to all files using it implicitly 2011-10-31 19:31:18 -04:00
dm-path-selector.h
dm-queue-length.c dm: reject trailing characters in sccanf input 2012-03-28 18:41:26 +01:00
dm-raid1.c dm: reject trailing characters in sccanf input 2012-03-28 18:41:26 +01:00
dm-raid.c dm raid: handle failed devices during start up 2012-03-28 18:41:26 +01:00
dm-region-hash.c
dm-round-robin.c dm: reject trailing characters in sccanf input 2012-03-28 18:41:26 +01:00
dm-service-time.c dm: reject trailing characters in sccanf input 2012-03-28 18:41:26 +01:00
dm-snap-persistent.c md: Add in export.h for files using EXPORT_SYMBOL 2011-10-31 19:31:19 -04:00
dm-snap-transient.c md: Add in export.h for files using EXPORT_SYMBOL 2011-10-31 19:31:19 -04:00
dm-snap.c
dm-stripe.c dm: reject trailing characters in sccanf input 2012-03-28 18:41:26 +01:00
dm-sysfs.c
dm-table.c dm: reject trailing characters in sccanf input 2012-03-28 18:41:26 +01:00
dm-target.c
dm-thin-metadata.c dm thin metadata: pass correct space map to dm_sm_root_size 2012-03-28 18:41:25 +01:00
dm-thin-metadata.h dm: add thin provisioning target 2011-10-31 20:21:18 +00:00
dm-thin.c dm thin: correct comments 2012-03-28 18:41:24 +01:00
dm-uevent.c md: Add in export.h for files using EXPORT_SYMBOL 2011-10-31 19:31:19 -04:00
dm-uevent.h
dm-zero.c
dm.c dm: clear bi_end_io on remapping failure 2012-03-28 18:41:25 +01:00
dm.h dm table: add immutable feature 2011-10-31 20:19:04 +00:00
faulty.c md: tidy up rdev_for_each usage. 2012-03-19 12:46:39 +11:00
Kconfig dm raid: no longer experimental 2012-03-28 18:41:24 +01:00
linear.c md: add proper merge_bvec handling to RAID0 and Linear. 2012-03-19 12:46:39 +11:00
linear.h
Makefile dm: add thin provisioning target 2011-10-31 20:21:18 +00:00
md.c md: Add judgement bb->unacked_exist in function md_ack_all_badblocks(). 2012-03-19 12:46:42 +11:00
md.h md/raid10: handle merge_bvec_fn in member devices. 2012-03-19 12:46:39 +11:00
multipath.c md: tidy up rdev_for_each usage. 2012-03-19 12:46:39 +11:00
multipath.h
raid0.c md: add proper merge_bvec handling to RAID0 and Linear. 2012-03-19 12:46:39 +11:00
raid0.h md: add proper merge_bvec handling to RAID0 and Linear. 2012-03-19 12:46:39 +11:00
raid1.c md/raid1: handle merge_bvec_fn in member devices. 2012-03-19 12:46:39 +11:00
raid1.h md/raid1: Allocate spare to store replacement devices and their bios. 2011-12-23 10:17:56 +11:00
raid5.c md: tidy up rdev_for_each usage. 2012-03-19 12:46:39 +11:00
raid5.h md/raid5: detect and handle replacements during recovery. 2011-12-23 10:17:53 +11:00
raid10.c md/raid10 - support resizing some RAID10 arrays. 2012-03-19 12:46:40 +11:00
raid10.h md/raid10: prepare data structures for handling replacement. 2011-12-23 10:17:54 +11:00