mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-24 01:41:39 +00:00
Btrfs: Don't trust the superblock label and simply printk("%s") it
Someone who is root or capable(CAP_SYS_ADMIN) could corrupt the superblock and make Btrfs printk("%s") crash while holding the uuid_mutex since nobody forces a limit on the string. Since the uuid_mutex is significant, the system would be unusable afterwards. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de> Reviewed-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
This commit is contained in:
parent
109f2365f1
commit
d03f918ab9
1 changed files with 5 additions and 2 deletions
|
@ -764,10 +764,13 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
|
||||||
devid = btrfs_stack_device_id(&disk_super->dev_item);
|
devid = btrfs_stack_device_id(&disk_super->dev_item);
|
||||||
transid = btrfs_super_generation(disk_super);
|
transid = btrfs_super_generation(disk_super);
|
||||||
total_devices = btrfs_super_num_devices(disk_super);
|
total_devices = btrfs_super_num_devices(disk_super);
|
||||||
if (disk_super->label[0])
|
if (disk_super->label[0]) {
|
||||||
|
if (disk_super->label[BTRFS_LABEL_SIZE - 1])
|
||||||
|
disk_super->label[BTRFS_LABEL_SIZE - 1] = '\0';
|
||||||
printk(KERN_INFO "device label %s ", disk_super->label);
|
printk(KERN_INFO "device label %s ", disk_super->label);
|
||||||
else
|
} else {
|
||||||
printk(KERN_INFO "device fsid %pU ", disk_super->fsid);
|
printk(KERN_INFO "device fsid %pU ", disk_super->fsid);
|
||||||
|
}
|
||||||
printk(KERN_CONT "devid %llu transid %llu %s\n",
|
printk(KERN_CONT "devid %llu transid %llu %s\n",
|
||||||
(unsigned long long)devid, (unsigned long long)transid, path);
|
(unsigned long long)devid, (unsigned long long)transid, path);
|
||||||
ret = device_list_add(path, disk_super, devid, fs_devices_ret);
|
ret = device_list_add(path, disk_super, devid, fs_devices_ret);
|
||||||
|
|
Loading…
Reference in a new issue