Skip to contentSkip to conversation

fs/btrfs: Integer overflow in btrfs_ioctl_resize()

PATCH New Wenliang Fan 1 participant 1 message Dec 20, 2013 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/btrfs: Integer overflow in btrfs_ioctl_resize()

The local variable 'new_size' comes from userspace. If a large number was passed, there would be an integer overflow in the following line:

	new_size = old_size + new_size;
---
 fs/btrfs/ioctl.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/btrfs/ioctl.c +4 -0
index 21da576..92f7707 100644
@@ -1466,6 +1466,10 @@ static noinline int btrfs_ioctl_resize(struct file *file,
 		}
 		new_size = old_size - new_size;
 	} else if (mod > 0) {
+		if (new_size > ULLONG_MAX - old_size) {
+			ret = -EINVAL;
+			goto out_free;
+		}
 		new_size = old_size + new_size;
 	}
 
Signature · 1 line
1.8.5.rc1.28.g7061504