[Devel] [PATCH hci-8.2 6/8] ms/ext4: check if mount_opts is NUL-terminated in ext4_ioctl_set_tune_sb()

Denis V. Lunev den at openvz.org
Thu Nov 19 15:03:23 MSK 2026


From: Fedor Pchelkin <pchelkin at ispras.ru>

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 at ispras.ru>
Reviewed-by: Baokun Li <libaokun1 at huawei.com>
Reviewed-by: Jan Kara <jack at suse.cz>
Message-ID: <20251101160430.222297-2-pchelkin at ispras.ru>
Signed-off-by: Theodore Ts'o <tytso at mit.edu>
Cc: stable at kernel.org
(cherry picked from commit 3db63d2c2d1d1e78615dd742568c5a2d55291ad1)

https://virtuozzo.atlassian.net/browse/VSTOR-155988
Feature: fix ms/ext4

Signed-off-by: Denis V. Lunev <den at openvz.org>
---
 fs/ext4/ioctl.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 578a97f4c63d..b9d2d2e1c47c 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -1506,6 +1506,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;
 
-- 
2.55.0



More information about the Devel mailing list