Skip to content

Commit ffc8b30

Browse files
keestorvalds
authored andcommitted
block: do not pass disk names as format strings
Disk names may contain arbitrary strings, so they must not be interpreted as format strings. It seems that only md allows arbitrary strings to be used for disk names, but this could allow for a local memory corruption from uid 0 into ring 0. CVE-2013-2851 Signed-off-by: Kees Cook <keescook@chromium.org> Cc: Jens Axboe <axboe@kernel.dk> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 542db01 commit ffc8b30

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

‎block/genhd.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ static void register_disk(struct gendisk *disk)
512512

513513
ddev->parent = disk->driverfs_dev;
514514

515-
dev_set_name(ddev, disk->disk_name);
515+
dev_set_name(ddev, "%s", disk->disk_name);
516516

517517
/* delay uevents, until we scanned partition table */
518518
dev_set_uevent_suppress(ddev, 1);

‎drivers/block/nbd.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,8 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
714714
else
715715
blk_queue_flush(nbd->disk->queue, 0);
716716

717-
thread = kthread_create(nbd_thread, nbd, nbd->disk->disk_name);
717+
thread = kthread_create(nbd_thread, nbd, "%s",
718+
nbd->disk->disk_name);
718719
if (IS_ERR(thread)) {
719720
mutex_lock(&nbd->tx_lock);
720721
return PTR_ERR(thread);

‎drivers/scsi/osd/osd_uld.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ static int osd_probe(struct device *dev)
485485
oud->class_dev.class = &osd_uld_class;
486486
oud->class_dev.parent = dev;
487487
oud->class_dev.release = __remove;
488-
error = dev_set_name(&oud->class_dev, disk->disk_name);
488+
error = dev_set_name(&oud->class_dev, "%s", disk->disk_name);
489489
if (error) {
490490
OSD_ERR("dev_set_name failed => %d\n", error);
491491
goto err_put_cdev;

0 commit comments

Comments
 (0)