Skip to content

Commit 3db63d2

Browse files
pchelkin91tytso
authored andcommitted
ext4: check if mount_opts is NUL-terminated in ext4_ioctl_set_tune_sb()
params.mount_opts may come as potentially non-NUL-term string. Userspace is expected to pass a NUL-term string. Add an extra check to ensure this holds true. Note that further code utilizes strscpy_pad() so this is just for proper informing the user of incorrect data being provided. Found by Linux Verification Center (linuxtesting.org). Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru> Reviewed-by: Baokun Li <libaokun1@huawei.com> Reviewed-by: Jan Kara <jack@suse.cz> Message-ID: <20251101160430.222297-2-pchelkin@ispras.ru> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@kernel.org
1 parent ee5a977 commit 3db63d2

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

fs/ext4/ioctl.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,10 @@ static int ext4_ioctl_set_tune_sb(struct file *filp,
13941394
if (copy_from_user(&params, in, sizeof(params)))
13951395
return -EFAULT;
13961396

1397+
if (strnlen(params.mount_opts, sizeof(params.mount_opts)) ==
1398+
sizeof(params.mount_opts))
1399+
return -E2BIG;
1400+
13971401
if ((params.set_flags & ~TUNE_OPS_SUPPORTED) != 0)
13981402
return -EOPNOTSUPP;
13991403

0 commit comments

Comments
 (0)