[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251101160430.222297-2-pchelkin@ispras.ru>
Date: Sat, 1 Nov 2025 19:04:29 +0300
From: Fedor Pchelkin <pchelkin@...ras.ru>
To: "Theodore Ts'o" <tytso@....edu>,
Jan Kara <jack@...e.cz>,
linux-ext4@...r.kernel.org
Cc: Fedor Pchelkin <pchelkin@...ras.ru>,
Andreas Dilger <adilger.kernel@...ger.ca>,
"Darrick J. Wong" <djwong@...nel.org>,
linux-kernel@...r.kernel.org,
lvc-project@...uxtesting.org
Subject: [PATCH v2 2/2] 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@...ras.ru>
---
v2: check length of mount_opts in superblock tuning ioctl (Jan Kara)
Can't plainly return error at strscpy_pad() call site in
ext4_sb_setparams(), that's a void ext4_update_sb_callback.
v1: https://lore.kernel.org/lkml/20251028130949.599847-1-pchelkin@ispras.ru/T/#u
fs/ext4/ioctl.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index a93a7baae990..3dec26c939fd 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -1394,6 +1394,10 @@ static int ext4_ioctl_set_tune_sb(struct file *filp,
if (copy_from_user(¶ms, 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.51.0
Powered by blists - more mailing lists