* [PATCH] ext2: Set the superblock UUID
@ 2026-11-23 4:48 Peng Hao
2026-11-23 4:54 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Peng Hao @ 2026-11-23 4:48 UTC (permalink / raw)
To: jack; +Cc: linux-ext4
ext2_fill_super() never sets sb->s_uuid, so everything that uses the
filesystem UUID through the VFS sees a null UUID on ext2:
- IMA/EVM policy rules with fsuuid= never match;
- EVM HMACs that include the UUID (EVM_ATTR_FSUUID) don't bind to the
filesystem;
- FS_IOC_GETFSUUID fails with -ENOTTY;
- overlayfs can't tell lower layers on different ext2 filesystems apart
and falls back to xino=off,index=off,nfs_export=off.
This was found with the BPF selftest test_ima, which creates an ext2
image, adds a "measure func=BPRM_CHECK fsuuid=<uuid>" rule and expects
a binary executed from that image to be measured. It only passes when
ext2 images are mounted by ext4 (CONFIG_EXT4_USE_FOR_EXT2), which sets
the UUID. With CONFIG_EXT2_FS=y nothing is measured:
test_test_ima:FAIL:num_samples_or_err unexpected num_samples_or_err: actual 0 != expected 1
Set the UUID from the on-disk superblock the same way ext4 does.
Signed-off-by: Peng Hao <flyingpeng@tencent.com>
---
fs/ext2/super.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index a40f530872a4..5e36007b3ffd 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -1007,6 +1007,7 @@ static int ext2_fill_super(struct super_block *sb, struct fs_context *fc)
sb->s_max_links = EXT2_LINK_MAX;
sb->s_time_min = S32_MIN;
sb->s_time_max = S32_MAX;
+ super_set_uuid(sb, es->s_uuid, sizeof(es->s_uuid));
if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV) {
sbi->s_inode_size = EXT2_GOOD_OLD_INODE_SIZE;
--
2.43.7
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] ext2: Set the superblock UUID
2026-11-23 4:48 [PATCH] ext2: Set the superblock UUID Peng Hao
@ 2026-11-23 4:54 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-23 4:54 UTC (permalink / raw)
To: Peng Hao; +Cc: linux-ext4, tytso
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] ext2: integer underflow in ext2_get_inode() when s_first_ino is
0 [1]
--
commit b9543efa7f637c4ab3ed734748dff30bc4e4d9aa
Author: Peng Hao <flyingpenghao@gmail.com>
ext2: Set the superblock UUID
This commit populates sb->s_uuid from the on-disk ext2 superblock in
ext2_fill_super() via super_set_uuid().
> diff --git a/fs/ext2/super.c b/fs/ext2/super.c
> index 54a6c26d0388a..0c6edc68a94e2 100644
> --- a/fs/ext2/super.c
> +++ b/fs/ext2/super.c
> @@ -1010,6 +1010,7 @@ static int ext2_fill_super(struct super_block *sb, struct fs_context *fc)
> sb->s_max_links = EXT2_LINK_MAX;
> sb->s_time_min = S32_MIN;
> sb->s_time_max = S32_MAX;
> + super_set_uuid(sb, es->s_uuid, sizeof(es->s_uuid));
>
> if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV) {
> sbi->s_inode_size = EXT2_GOOD_OLD_INODE_SIZE;
[Severity: High]
This problem wasn't introduced by this patch, but can loading
sbi->s_first_ino from es->s_first_ino in the else branch right below cause
an integer underflow in ext2_get_inode() [1]?
fs/ext2/super.c:ext2_fill_super() {
...
if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV) {
sbi->s_inode_size = EXT2_GOOD_OLD_INODE_SIZE;
sbi->s_first_ino = EXT2_GOOD_OLD_FIRST_INO;
} else {
sbi->s_inode_size = le16_to_cpu(es->s_inode_size);
sbi->s_first_ino = le32_to_cpu(es->s_first_ino);
...
}
fs/ext2/inode.c:ext2_get_inode() {
...
if ((ino != EXT2_ROOT_INO && ino < EXT2_FIRST_INO(sb)) ||
ino > le32_to_cpu(EXT2_SB(sb)->s_es->s_inodes_count))
goto Einval;
block_group = (ino - 1) / EXT2_INODES_PER_GROUP(sb);
gdp = ext2_get_group_desc(sb, block_group, NULL);
...
}
If a corrupted filesystem image has es->s_first_ino == 0 (or >= 0x80000000,
which sign-extends the signed int sbi->s_first_ino), looking up ino 0 via
open_by_handle_at() -> ext2_fh_to_dentry() -> ext2_nfs_get_inode() ->
ext2_iget() -> ext2_get_inode() passes the ino < EXT2_FIRST_INO(sb) check.
Computing ino - 1 then underflows unsigned ino_t to ULONG_MAX, triggering a
WARN(1) in ext2_get_group_desc() or reading an unintended group descriptor
if 32-bit truncation of block_group wraps below s_groups_count.
[1] https://sashiko.dev/#/bug/linux-5ea0eb49-c55e-4623-9285-ee790480d577
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123044826.93953-1-flyingpeng@tencent.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-23 4:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 4:48 [PATCH] ext2: Set the superblock UUID Peng Hao
2026-11-23 4:54 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox