The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] ext4: fix reserved group initialization
@ 2026-08-11  2:18 guzebing
  2026-08-11  2:50 ` Ritesh Harjani
  0 siblings, 1 reply; 3+ messages in thread
From: guzebing @ 2026-08-11  2:18 UTC (permalink / raw)
  To: tytso
  Cc: adilger.kernel, libaokun, jack, ojaswin, ritesh.list, yi.zhang,
	linux-ext4, linux-kernel, guzebing

ext4 initializes the in-memory reserved uid and gid from the on-disk
default reserved id fields during mount. The s_resgid assignment
accidentally uses ext4_get_resuid(), so the reserved group is initialized
from the reserved uid instead of the reserved gid.

As a result, members of the configured reserved group can be denied access
to reserved blocks, while members of a group whose gid matches the
reserved uid can be incorrectly allowed to use them.

Initialize s_resgid with ext4_get_resgid() instead.

Fixes: 12c84dd4d308 ("ext4: add support for 32-bit default reserved uid and gid values")
Signed-off-by: guzebing <guzebing1612@gmail.com>
---
 fs/ext4/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 245f67d10ded3..63de62a75a543 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5369,7 +5369,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
 	ext4_set_def_opts(sb, es);
 
 	sbi->s_resuid = make_kuid(&init_user_ns, ext4_get_resuid(es));
-	sbi->s_resgid = make_kgid(&init_user_ns, ext4_get_resuid(es));
+	sbi->s_resgid = make_kgid(&init_user_ns, ext4_get_resgid(es));
 	sbi->s_commit_interval = JBD2_DEFAULT_MAX_COMMIT_AGE * HZ;
 	sbi->s_min_batch_time = EXT4_DEF_MIN_BATCH_TIME;
 	sbi->s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME;

base-commit: 06cf61899d6498b33e4b7c87d99d5bd471ccc375
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ext4: fix reserved group initialization
  2026-08-11  2:18 [PATCH] ext4: fix reserved group initialization guzebing
@ 2026-08-11  2:50 ` Ritesh Harjani
  2026-08-11  8:09   ` guzebing
  0 siblings, 1 reply; 3+ messages in thread
From: Ritesh Harjani @ 2026-08-11  2:50 UTC (permalink / raw)
  To: guzebing, tytso
  Cc: adilger.kernel, libaokun, jack, ojaswin, yi.zhang, linux-ext4,
	linux-kernel, guzebing

guzebing <guzebing1612@gmail.com> writes:

> ext4 initializes the in-memory reserved uid and gid from the on-disk
> default reserved id fields during mount. The s_resgid assignment
> accidentally uses ext4_get_resuid(), so the reserved group is initialized
> from the reserved uid instead of the reserved gid.
>
> As a result, members of the configured reserved group can be denied access
> to reserved blocks, while members of a group whose gid matches the
> reserved uid can be incorrectly allowed to use them.
>
> Initialize s_resgid with ext4_get_resgid() instead.
>
> Fixes: 12c84dd4d308 ("ext4: add support for 32-bit default reserved uid and gid values")
> Signed-off-by: guzebing <guzebing1612@gmail.com>

This was posted before [1] and looks it already landed in ext4's dev
branch [2].

[1]: https://lore.kernel.org/all/20260727104103.28916-1-liujiazi@amazon.com/
[2]: https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git/commit/?h=dev&id=c87abbab6147dcc5aa1fd8f2a61734d58d8b99ec

-ritesh

> ---
>  fs/ext4/super.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 245f67d10ded3..63de62a75a543 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -5369,7 +5369,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
>  	ext4_set_def_opts(sb, es);
>  
>  	sbi->s_resuid = make_kuid(&init_user_ns, ext4_get_resuid(es));
> -	sbi->s_resgid = make_kgid(&init_user_ns, ext4_get_resuid(es));
> +	sbi->s_resgid = make_kgid(&init_user_ns, ext4_get_resgid(es));
>  	sbi->s_commit_interval = JBD2_DEFAULT_MAX_COMMIT_AGE * HZ;
>  	sbi->s_min_batch_time = EXT4_DEF_MIN_BATCH_TIME;
>  	sbi->s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME;
>
> base-commit: 06cf61899d6498b33e4b7c87d99d5bd471ccc375
> -- 
> 2.20.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ext4: fix reserved group initialization
  2026-08-11  2:50 ` Ritesh Harjani
@ 2026-08-11  8:09   ` guzebing
  0 siblings, 0 replies; 3+ messages in thread
From: guzebing @ 2026-08-11  8:09 UTC (permalink / raw)
  To: Ritesh Harjani (IBM), tytso
  Cc: adilger.kernel, libaokun, jack, ojaswin, yi.zhang, linux-ext4,
	linux-kernel



On 8/11/26 10:50 AM, Ritesh Harjani (IBM) wrote:
> This was posted before [1] and looks it already landed in ext4's dev
> branch [2].

Thanks for pointing this out. I missed the earlier submission and did
not notice that the fix had already been applied to the ext4 dev branch.
Please disregard this patch.

Sorry for the noise.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-08-11  8:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-11  2:18 [PATCH] ext4: fix reserved group initialization guzebing
2026-08-11  2:50 ` Ritesh Harjani
2026-08-11  8:09   ` guzebing

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox