Skip to contentSkip to conversation

btrfs: Null terminate string in scan device ioctl

PATCH New Milan Broz 1 participant 1 message Jun 3, 2011 Btrfs file system

lore
Share & tools
lore

Milan Broz

author
#0 lore raw

PATCH 1/1 btrfs: Null terminate string in scan device ioctl

btrfs_scan_one_device() directly uses vol->name without additional checks so in the case of unterminated string in ioctl it can access memory outside
of btrfs_ioctl_vol_args struct.

Always terminate name string (as the same as other users do already).

---
 fs/btrfs/super.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/btrfs/super.c +2 -0
index 9b2e7e5..2bb1a99 100644
@@ -1148,6 +1148,8 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
 	if (IS_ERR(vol))
 		return PTR_ERR(vol);
 
+	vol->name[BTRFS_PATH_NAME_MAX] = '\0';
+
 	switch (cmd) {
 	case BTRFS_IOC_SCAN_DEV:
 		ret = btrfs_scan_one_device(vol->name, FMODE_READ,
Signature · 1 line
1.7.5.3