FAILED: patch "[PATCH] ext4: avoid potential buffer over-read in" failed to apply to 5.10-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 8ecb790ea8c3fc69e77bace57f14cf0d7c177bd8
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2025101635-unbuckled-masses-9441@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 8ecb790ea8c3fc69e77bace57f14cf0d7c177bd8 Mon Sep 17 00:00:00 2001
From: Theodore Ts'o <[email protected]>
Date: Tue, 16 Sep 2025 23:22:47 -0400
Subject: [PATCH] ext4: avoid potential buffer over-read in
parse_apply_sb_mount_options()
Unlike other strings in the ext4 superblock, we rely on tune2fs to make sure s_mount_opts is NUL terminated. Harden parse_apply_sb_mount_options() by treating s_mount_opts as a potential __nonstring.
Message-ID: <[email protected]>
fs/ext4/super.c +5 -12
@@ -2469,7 +2469,7 @@ static int parse_apply_sb_mount_options(struct super_block *sb, struct ext4_fs_context *m_ctx) {struct ext4_sb_info *sbi =EXT4_SB (sb); -char *s_mount_opts =NULL ; +char s_mount_opts[65 ];struct ext4_fs_context *s_ctx =NULL ;struct fs_context *fc =NULL ;int ret = -ENOMEM ;
@@ -2477,15 +2477,11 @@ static int parse_apply_sb_mount_options(struct super_block *sb,if (!sbi->s_es->s_mount_opts[0 ])return 0 ; - s_mount_opts =kstrndup (sbi->s_es->s_mount_opts, -sizeof (sbi->s_es->s_mount_opts), -GFP_KERNEL ); -if (!s_mount_opts) -return ret; +strscpy_pad (s_mount_opts, sbi->s_es->s_mount_opts); fc =kzalloc (sizeof (struct fs_context ),GFP_KERNEL );if (!fc) - goto out_free; +return -ENOMEM ; s_ctx =kzalloc (sizeof (struct ext4_fs_context ),GFP_KERNEL );if (!s_ctx)
@@ -2517,11 +2513,8 @@ static int parse_apply_sb_mount_options(struct super_block *sb, ret =0 ; out_free: -if (fc) { -ext4_fc_free (fc); -kfree (fc); - } -kfree (s_mount_opts); +ext4_fc_free (fc); +kfree (fc);return ret; }
Sasha Levin
maintainerPATCH 1/1 ext4: avoid potential buffer over-read in parse_apply_sb_mount_options()
From: Theodore Ts'o <[email protected]>
[ Upstream commit 8ecb790ea8c3fc69e77bace57f14cf0d7c177bd8 ]
Unlike other strings in the ext4 superblock, we rely on tune2fs to make sure s_mount_opts is NUL terminated. Harden parse_apply_sb_mount_options() by treating s_mount_opts as a potential __nonstring.
Message-ID: <[email protected]>
--- fs/ext4/super.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
fs/ext4/super.c +4 -6
@@ -4282,18 +4282,16 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) }if (sbi->s_es->s_mount_opts[0 ]) { -char *s_mount_opts =kstrndup (sbi->s_es->s_mount_opts, -sizeof (sbi->s_es->s_mount_opts), -GFP_KERNEL ); -if (!s_mount_opts) - goto failed_mount; +char s_mount_opts[65 ]; + +strscpy_pad (s_mount_opts, sbi->s_es->s_mount_opts, +sizeof (s_mount_opts));if (!parse_options (s_mount_opts, sb, &journal_devnum, &journal_ioprio,0 )) {ext4_msg (sb,KERN_WARNING ,"failed to parse options in superblock: %s" , s_mount_opts); } -kfree (s_mount_opts); } sbi->s_def_mount_opt = sbi->s_mount_opt; if (!parse_options((char *) data, sb, &journal_devnum,
Signature · 1 line
2.51.0