All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: no-reply@sashiko.virtuozzo.com
To: "Denis V. Lunev" <den@openvz.org>,
	ptikhomirov@virtuozzo.com, vasileios.almpanis@virtuozzo.com
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.2 3/8] ms/ext4: add support for 32-bit default reserved uid and gid values
Date: Thu, 19 Nov 2026 12:09:05 +0000	[thread overview]
Message-ID: <010701a1f3b5e155-ccd68eea-e5ed-4194-8875-03f663678965-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261119120325.792064-4-den@openvz.org>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] ext4: ext4_get_resuid()/ext4_get_resgid() shift u16 into int
  sign bit
--

commit da23b39c3b9f8774c5ca33e7852c644658a23aee
Author: Theodore Ts'o <tytso@mit.edu>

ms/ext4: add support for 32-bit default reserved uid and gid values

The patch adds s_def_resuid_hi and s_def_resgid_hi to the ext4 superblock,
carved out of s_reserved[]. It adds ext4_get_resuid() and ext4_get_resgid()
helpers that combine the low and high halves. It then uses the helpers in
_ext4_show_options() and __ext4_fill_super().

> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 3de0fc6e77f2..e9d1b471a8cc 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h

[ ... ]

> +static inline int ext4_get_resuid(struct ext4_super_block *es)
> +{
> +	return le16_to_cpu(es->s_def_resuid) |
> +		le16_to_cpu(es->s_def_resuid_hi) << 16;
> +}
> +
> +static inline int ext4_get_resgid(struct ext4_super_block *es)
> +{
> +	return le16_to_cpu(es->s_def_resgid) |
> +		le16_to_cpu(es->s_def_resgid_hi) << 16;
> +}

[Severity: Low]
Can the shift overflow a signed int here? The u16 high half is promoted
to int, so a value of 0x8000 or more shifts into the sign bit. That is
undefined behaviour, and UBSAN could report it. The helpers also return
int.

In practice the bit pattern survives the conversion to uid_t/gid_t.
Would it be cleaner to return u32 and cast the high half to u32 before
shifting?

> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index bf42593efcea..a6581dee49ed 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c

[ ... ]

> -	sbi->s_resuid = make_kuid(&init_user_ns, le16_to_cpu(es->s_def_resuid));
> -	sbi->s_resgid = make_kgid(&init_user_ns, le16_to_cpu(es->s_def_resgid));
> +	sbi->s_resuid = make_kuid(&init_user_ns, ext4_get_resuid(es));
> +	sbi->s_resgid = make_kgid(&init_user_ns, ext4_get_resuid(es));

[Severity: Medium]
Should the second line call ext4_get_resgid()? As written, s_resgid is
filled from the default resuid, so the default reserved gid is wrong
whenever s_def_resuid and s_def_resgid differ. The resgid= value shown
in /proc/mounts is wrong in the same case.

Carry the trailer below into the next revision and Sashiko will not review this patch again.

Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261119120325.792064-1-den@openvz.org?part=3

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  reply	other threads:[~2026-11-19 12:10 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 12:03 [Devel] [PATCH hci-8.2 0/8] ext4: port the ioctls to set and get superblock parameters Denis V. Lunev
2026-11-19 12:03 ` [Devel] [PATCH hci-8.2 1/8] ms/ext4: avoid potential buffer over-read in parse_apply_sb_mount_options() Denis V. Lunev
2026-11-19 12:07   ` no-reply
2026-11-19 16:49   ` Konstantin Khorenko
2026-11-19 12:03 ` [Devel] [PATCH hci-8.2 2/8] ms/ext4: fix string copying " Denis V. Lunev
2026-11-19 12:08   ` no-reply
2026-11-19 16:49   ` Konstantin Khorenko
2026-11-19 12:03 ` [Devel] [PATCH hci-8.2 3/8] ms/ext4: add support for 32-bit default reserved uid and gid values Denis V. Lunev
2026-11-19 12:09   ` no-reply [this message]
2026-11-19 16:49   ` Konstantin Khorenko
2026-11-19 12:03 ` [Devel] [PATCH hci-8.2 4/8] ms/ext4: fix incorrect function call when initializing s_resgid Denis V. Lunev
2026-11-19 12:08   ` no-reply
2026-11-19 16:49   ` Konstantin Khorenko
2026-11-19 12:03 ` [Devel] [PATCH hci-8.2 5/8] ms/ext4: implemet new ioctls to set and get superblock parameters Denis V. Lunev
2026-11-19 12:13   ` no-reply
2026-11-19 16:49   ` Konstantin Khorenko
2026-11-19 12:03 ` [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
2026-11-19 12:10   ` no-reply
2026-11-19 16:49   ` Konstantin Khorenko
2026-11-19 12:03 ` [Devel] [PATCH hci-8.2 7/8] ms/ext4: fix ext4_tune_sb_params padding Denis V. Lunev
2026-11-19 12:11   ` no-reply
2026-11-19 16:49   ` Konstantin Khorenko
2026-11-19 12:03 ` [Devel] [PATCH hci-8.2 8/8] ms/ext4: only update tune mount options when requested Denis V. Lunev
2026-11-19 12:12   ` no-reply
2026-11-19 16:49   ` Konstantin Khorenko
2026-11-19 16:49 ` [Devel] [PATCH hci-8.2 0/8] ext4: port the ioctls to set and get superblock parameters Konstantin Khorenko
2026-11-19 16:49 ` Konstantin Khorenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=010701a1f3b5e155-ccd68eea-e5ed-4194-8875-03f663678965-000000@eu-central-1.amazonses.com \
    --to=no-reply@sashiko.virtuozzo.com \
    --cc=den@openvz.org \
    --cc=devel@openvz.org \
    --cc=ptikhomirov@virtuozzo.com \
    --cc=vasileios.almpanis@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.