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=" 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 --- fs/ext2/super.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 8a4412231394..b4df4123313d 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