block: fix buffer overflow when printing partition UUIDs
Tejun Heo authored
commit 05c69d29 upstream.

6d1d8050 "block, partition: add partition_meta_info to hd_struct"
added part_unpack_uuid() which assumes that the passed in buffer has
enough space for sprintfing "%pU" - 37 characters including '\0'.

Unfortunately, b5af921e

 "init: add support for root devices
specified by partition UUID" supplied 33 bytes buffer to the function
leading to the following panic with stackprotector enabled.

  Kernel panic - not syncing: stack-protector: Kernel stack corrupted in: ffffffff81b14c7e

  [<ffffffff815e226b>] panic+0xba/0x1c6
  [<ffffffff81b14c7e>] ? printk_all_partitions+0x259/0x26xb
  [<ffffffff810566bb>] __stack_chk_fail+0x1b/0x20
  [<ffffffff81b15c7e>] printk_all_paritions+0x259/0x26xb
  [<ffffffff81aedfe0>] mount_block_root+0x1bc/0x27f
  [<ffffffff81aee0fa>] mount_root+0x57/0x5b
  [<ffffffff81aee23b>] prepare_namespace+0x13d/0x176
  [<ffffffff8107eec0>] ? release_tgcred.isra.4+0x330/0x30
  [<ffffffff81aedd60>] kernel_init+0x155/0x15a
  [<ffffffff81087b97>] ? schedule_tail+0x27/0xb0
  [<ffffffff815f4d24>] kernel_thread_helper+0x5/0x10
  [<ffffffff81aedc0b>] ? start_kernel+0x3c5/0x3c5
  [<ffffffff815f4d20>] ? gs_change+0x13/0x13

Increase the buffer size, remove the dangerous part_unpack_uuid() and
use snprintf() directly from printk_all_partitions().
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Reported-by: default avatarSzymon Gruszczynski <sz.gruszczynski@googlemail.com>
Cc: Will Drewry <wad@chromium.org>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
19e40444
Name Last commit Last update
..
Kconfig kconfig: rename CONFIG_EMBEDDED to CONFIG_EXPERT
Kconfig.iosched blk-cgroup: config options re-arrangement
Makefile Merge branch 'for-2.6.37/barrier' of git://git.kernel.dk/linux-2.6-block
blk-cgroup.c blk-cgroup: be able to remove the record of unplugged device
blk-cgroup.h cfq-iosched: Make IO merge related stats per cpu
blk-core.c block: initialize request_queue's numa node during
blk-exec.c fix crash in scsi_dispatch_cmd()
blk-flush.c block: hold queue if flush is running for non-queueable flush drive
blk-integrity.c dm: improve block integrity support
blk-ioc.c block: Use hlist_entry() for io_context.cic_list.first
blk-iopoll.c tree-wide: fix assorted typos all over the place
blk-lib.c blkdev: Do not return -EOPNOTSUPP if discard is supported
blk-map.c block: Always check length of all iov entries in blk_rq_map_user_iov()
blk-merge.c block: attempt to merge with existing requests on plug flush
blk-settings.c block: Fix discard topology stacking and reporting
blk-softirq.c generic-ipi: remove CSD_FLAG_WAIT
blk-sysfs.c block: Free queue resources at blk_release_queue()
blk-tag.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
blk-throttle.c block: Add __attribute__((format(printf...) and fix fallout
blk-timeout.c block: ensure jiffies wrap is handled correctly in blk_rq_timed_out_timer
blk.h Merge branch 'for-linus' into for-2.6.40/core
bsg.c bsg: fix sysfs link remove warning
cfq-iosched.c cfq-iosched: fix cfq_cic_link() race confition
cfq.h blk-cgroup: Add unaccounted time to timeslice_used.
compat_ioctl.c BKL: remove extraneous #include <smp_lock.h>
deadline-iosched.c
elevator.c
genhd.c
ioctl.c
noop-iosched.c
scsi_ioctl.c