mirror of
https://github.com/torvalds/linux.git
synced 2024-11-27 14:41:39 +00:00
bcachefs: chardev: fix an integer overflow (32 bit only)
On 32 bit systems, "sizeof(*arg) + replica_entries_bytes" can have an integer overflow leading to memory corruption. Use size_add() to prevent this. Fixes: b44dd3797034 ("bcachefs: Redo filesystem usage ioctls") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
301e0237ca
commit
4ba985b84d
@ -421,7 +421,7 @@ static long bch2_ioctl_fs_usage(struct bch_fs *c,
|
||||
if (get_user(replica_entries_bytes, &user_arg->replica_entries_bytes))
|
||||
return -EFAULT;
|
||||
|
||||
arg = kzalloc(sizeof(*arg) + replica_entries_bytes, GFP_KERNEL);
|
||||
arg = kzalloc(size_add(sizeof(*arg), replica_entries_bytes), GFP_KERNEL);
|
||||
if (!arg)
|
||||
return -ENOMEM;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user