* [PATCH v2 0/3] ext4: Add support for mounted updates to the superblock via an ioctl
@ 2025-09-17 3:22 Theodore Ts'o via B4 Relay
2025-09-17 3:22 ` [PATCH v2 1/3] ext4: avoid potential buffer over-read in parse_apply_sb_mount_options() Theodore Ts'o via B4 Relay
2025-09-26 21:47 ` [PATCH v2 0/3] ext4: Add support for mounted updates to the superblock via an ioctl Theodore Ts'o
0 siblings, 2 replies; 5+ messages in thread
From: Theodore Ts'o via B4 Relay @ 2025-09-17 3:22 UTC (permalink / raw)
To: tytso; +Cc: linux-ext4, linux-api, stable
This patch series enables a future version of tune2fs to be able to
modify certain parts of the ext4 superblock without to write to the
block device.
The first patch fixes a potential buffer overrun caused by a
maliciously moified superblock. The second patch adds support for
32-bit uid and gid's which can have access to the reserved blocks pool.
The last patch adds the ioctl's which will be used by tune2fs.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
Changes in v2:
- fix bugs that were detected using sparse
- remove tune (unsafe) ability to clear certain compat faatures
- add the ability to set the encoding and encoding flags for case folding
- Link to v1: https://lore.kernel.org/r/20250908-tune2fs-v1-0-e3a6929f3355@mit.edu
---
Theodore Ts'o (3):
ext4: avoid potential buffer over-read in parse_apply_sb_mount_options()
ext4: add support for 32-bit default reserved uid and gid values
ext4: implemet new ioctls to set and get superblock parameters
fs/ext4/ext4.h | 16 +++-
fs/ext4/ioctl.c | 312 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
fs/ext4/super.c | 25 +++----
include/uapi/linux/ext4.h | 53 +++++++++++++
4 files changed, 382 insertions(+), 24 deletions(-)
---
base-commit: b320789d6883cc00ac78ce83bccbfe7ed58afcf0
change-id: 20250830-tune2fs-3376beb72403
Best regards,
--
Theodore Ts'o <tytso@mit.edu>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/3] ext4: avoid potential buffer over-read in parse_apply_sb_mount_options()
2025-09-17 3:22 [PATCH v2 0/3] ext4: Add support for mounted updates to the superblock via an ioctl Theodore Ts'o via B4 Relay
@ 2025-09-17 3:22 ` Theodore Ts'o via B4 Relay
2025-09-17 16:05 ` Jan Kara
2025-09-26 21:47 ` [PATCH v2 0/3] ext4: Add support for mounted updates to the superblock via an ioctl Theodore Ts'o
1 sibling, 1 reply; 5+ messages in thread
From: Theodore Ts'o via B4 Relay @ 2025-09-17 3:22 UTC (permalink / raw)
To: tytso; +Cc: linux-ext4, linux-api, stable
From: Theodore Ts'o <tytso@mit.edu>
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.
Cc: stable@vger.kernel.org
Fixes: 8b67f04ab9de ("ext4: Add mount options in superblock")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
fs/ext4/super.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 699c15db28a82f26809bf68533454a242596f0fd..94c98446c84f9a4614971d246ca7f001de610a8a 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2460,7 +2460,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;
@@ -2468,15 +2468,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)
@@ -2508,11 +2504,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;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/3] ext4: avoid potential buffer over-read in parse_apply_sb_mount_options()
2025-09-17 3:22 ` [PATCH v2 1/3] ext4: avoid potential buffer over-read in parse_apply_sb_mount_options() Theodore Ts'o via B4 Relay
@ 2025-09-17 16:05 ` Jan Kara
2025-09-18 16:55 ` Darrick J. Wong
0 siblings, 1 reply; 5+ messages in thread
From: Jan Kara @ 2025-09-17 16:05 UTC (permalink / raw)
To: tytso; +Cc: linux-ext4, linux-api, stable
On Tue 16-09-25 23:22:47, Theodore Ts'o via B4 Relay wrote:
> From: Theodore Ts'o <tytso@mit.edu>
>
> 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.
>
> Cc: stable@vger.kernel.org
> Fixes: 8b67f04ab9de ("ext4: Add mount options in superblock")
> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/ext4/super.c | 17 +++++------------
> 1 file changed, 5 insertions(+), 12 deletions(-)
>
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 699c15db28a82f26809bf68533454a242596f0fd..94c98446c84f9a4614971d246ca7f001de610a8a 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -2460,7 +2460,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;
> @@ -2468,15 +2468,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)
> @@ -2508,11 +2504,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;
> }
>
>
> --
> 2.51.0
>
>
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/3] ext4: avoid potential buffer over-read in parse_apply_sb_mount_options()
2025-09-17 16:05 ` Jan Kara
@ 2025-09-18 16:55 ` Darrick J. Wong
0 siblings, 0 replies; 5+ messages in thread
From: Darrick J. Wong @ 2025-09-18 16:55 UTC (permalink / raw)
To: Jan Kara; +Cc: tytso, linux-ext4, linux-api, stable
On Wed, Sep 17, 2025 at 06:05:06PM +0200, Jan Kara wrote:
> On Tue 16-09-25 23:22:47, Theodore Ts'o via B4 Relay wrote:
> > From: Theodore Ts'o <tytso@mit.edu>
> >
> > 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.
> >
> > Cc: stable@vger.kernel.org
> > Fixes: 8b67f04ab9de ("ext4: Add mount options in superblock")
> > Signed-off-by: Theodore Ts'o <tytso@mit.edu>
>
> Looks good. Feel free to add:
>
> Reviewed-by: Jan Kara <jack@suse.cz>
Looks fine to me too,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
>
> Honza
>
> > ---
> > fs/ext4/super.c | 17 +++++------------
> > 1 file changed, 5 insertions(+), 12 deletions(-)
> >
> > diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> > index 699c15db28a82f26809bf68533454a242596f0fd..94c98446c84f9a4614971d246ca7f001de610a8a 100644
> > --- a/fs/ext4/super.c
> > +++ b/fs/ext4/super.c
> > @@ -2460,7 +2460,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;
> > @@ -2468,15 +2468,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)
> > @@ -2508,11 +2504,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;
> > }
> >
> >
> > --
> > 2.51.0
> >
> >
> >
> --
> Jan Kara <jack@suse.com>
> SUSE Labs, CR
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/3] ext4: Add support for mounted updates to the superblock via an ioctl
2025-09-17 3:22 [PATCH v2 0/3] ext4: Add support for mounted updates to the superblock via an ioctl Theodore Ts'o via B4 Relay
2025-09-17 3:22 ` [PATCH v2 1/3] ext4: avoid potential buffer over-read in parse_apply_sb_mount_options() Theodore Ts'o via B4 Relay
@ 2025-09-26 21:47 ` Theodore Ts'o
1 sibling, 0 replies; 5+ messages in thread
From: Theodore Ts'o @ 2025-09-26 21:47 UTC (permalink / raw)
To: Theodore Ts'o; +Cc: linux-ext4, linux-api, stable
On Tue, 16 Sep 2025 23:22:46 -0400, Theodore Ts'o wrote:
> This patch series enables a future version of tune2fs to be able to
> modify certain parts of the ext4 superblock without to write to the
> block device.
>
> The first patch fixes a potential buffer overrun caused by a
> maliciously moified superblock. The second patch adds support for
> 32-bit uid and gid's which can have access to the reserved blocks pool.
> The last patch adds the ioctl's which will be used by tune2fs.
>
> [...]
Applied, thanks!
[1/3] ext4: avoid potential buffer over-read in parse_apply_sb_mount_options()
commit: 8ecb790ea8c3fc69e77bace57f14cf0d7c177bd8
[2/3] ext4: add support for 32-bit default reserved uid and gid values
commit: 12c84dd4d308551568d85203fd6ed2685e861fda
[3/3] ext4: implemet new ioctls to set and get superblock parameters
commit: 04a91570ac67760301e5458d65eaf1342ecca314
Best regards,
--
Theodore Ts'o <tytso@mit.edu>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-09-26 21:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-17 3:22 [PATCH v2 0/3] ext4: Add support for mounted updates to the superblock via an ioctl Theodore Ts'o via B4 Relay
2025-09-17 3:22 ` [PATCH v2 1/3] ext4: avoid potential buffer over-read in parse_apply_sb_mount_options() Theodore Ts'o via B4 Relay
2025-09-17 16:05 ` Jan Kara
2025-09-18 16:55 ` Darrick J. Wong
2025-09-26 21:47 ` [PATCH v2 0/3] ext4: Add support for mounted updates to the superblock via an ioctl Theodore Ts'o
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox