]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ext4: check if mount_opts is NUL-terminated in ext4_ioctl_set_tune_sb()
authorFedor Pchelkin <pchelkin@ispras.ru>
Sat, 1 Nov 2025 16:04:29 +0000 (19:04 +0300)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 26 Nov 2025 22:05:39 +0000 (17:05 -0500)
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
fs/ext4/ioctl.c

index 366a9b615bf085b6a1a0d25fece1d92d3b4c01a2..7ce0fc40aec2fb91c948845f37e16c9aa2c59c3d 100644 (file)
@@ -1394,6 +1394,10 @@ static int ext4_ioctl_set_tune_sb(struct file *filp,
        if (copy_from_user(&params, in, sizeof(params)))
                return -EFAULT;
 
+       if (strnlen(params.mount_opts, sizeof(params.mount_opts)) ==
+           sizeof(params.mount_opts))
+               return -E2BIG;
+
        if ((params.set_flags & ~TUNE_OPS_SUPPORTED) != 0)
                return -EOPNOTSUPP;