* [syzbot] [ext4?] general protection fault in utf8nlookup (2)
@ 2026-11-30 2:39 syzbot
2026-11-30 11:05 ` [PATCH] ext4: Add validity checks for the casefold feature Edward Adam Davis
0 siblings, 1 reply; 6+ messages in thread
From: syzbot @ 2026-11-30 2:39 UTC (permalink / raw)
To: djwong, jack, krisman, linux-ext4, linux-fsdevel, linux-kernel,
syzkaller-bugs, tytso
Hello,
syzbot found the following issue on:
HEAD commit: 4f069ab1ec24 Merge tag 'scsi-fixes' of git://git.kernel.or..
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=136c28e9580000
kernel config: https://syzkaller.appspot.com/x/.config?x=fc1834b4a2e3ba54
dashboard link: https://syzkaller.appspot.com/bug?extid=68178aa1e39c8606392e
compiler: Debian clang version 22.1.8 (1~deb13u5), Debian LLD 22.1.8
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1626c3bd580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14ee707e580000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/66ff8e791620/disk-4f069ab1.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/35a2aede79e4/vmlinux-4f069ab1.xz
kernel image: https://storage.googleapis.com/syzbot-assets/408f236d215b/bzImage-4f069ab1.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/2f066f5ff899/mount_0.gz
fsck result: OK (log: https://syzkaller.appspot.com/x/fsck.log?x=163a0611580000)
The issue was bisected by AI to:
commit 04a91570ac67760301e5458d65eaf1342ecca314
Author: Theodore Ts'o <tytso@mit.edu>
Date: Wed Sep 17 03:22:49 2025 +0000
ext4: implemet new ioctls to set and get superblock parameters
reasoning: https://syzkaller.appspot.com/ai_job?id=6527b76a-ea78-44f2-b547-71ab4018729e
AI-generated root cause summary:
ext4_ioctl_set_tune_sb() (EXT4_IOC_SET_TUNE_SB_PARAM) permits enabling
EXT4_FEATURE_INCOMPAT_CASEFOLD on an already-mounted ext4 filesystem via
ext4_sb_setparams(), setting es->s_feature_incompat, es->s_encoding, and
es->s_encoding_flags without initializing sb->s_encoding (which is normally only
loaded at mount time by ext4_encoding_init()). Because
ext4_has_feature_casefold(sb) then returns true while sb->s_encoding remains
NULL, EXT4_CASEFOLD_FL (S_CASEFOLD) can be enabled on a directory via
ext4_ioctl_setflags() (or accepted for an on-disk inode by __ext4_iget()).
Subsequent lookups on that directory enter ext4_fname_setup_ci_filename(), which
passes the NULL dir->i_sb->s_encoding to utf8_casefold(), leading to a
NULL-pointer dereference of um->tables (offset 0x18) in utf8nlookup().
full analysis: https://syzkaller.appspot.com/x/ai_root_cause?x=68178aa1e39c8606392e
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+68178aa1e39c8606392e@syzkaller.appspotmail.com
The bisection result may be wrong.
If you agree with it, please also add:
Fixes: 04a91570ac67 ("ext4: implemet new ioctls to set and get superblock parameters")
EXT4-fs (loop0): mounted filesystem 00000000-0000-0000-0000-000000000000 r/w without journal. Quota mode: none.
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000003: 0000 [#1] SMP KASAN PTI
KASAN: null-ptr-deref in range [0x0000000000000018-0x000000000000001f]
CPU: 0 UID: 0 PID: 5619 Comm: syz-executor296 Not tainted syzkaller #0 PREEMPT_{RT,(full)}
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
RIP: 0010:utf8nlookup+0x39/0xa60 fs/unicode/utf8-norm.c:306
Code: 89 44 24 10 49 89 ce 48 89 14 24 89 f5 49 89 fd 49 bf 00 00 00 00 00 fc ff df e8 32 07 c9 fe 49 8d 5d 18 48 89 d8 48 c1 e8 03 <42> 80 3c 38 00 74 08 48 89 df e8 98 07 3d ff 48 8b 1b 48 83 c3 30
RSP: 0018:ffffc90004cbf568 EFLAGS: 00010206
RAX: 0000000000000003 RBX: 0000000000000018 RCX: ffff88801cbb8000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000001 R08: 0000000000000005 R09: 0000000000000000
R10: ffffc90004cbf6f8 R11: fffff52000997ee2 R12: dffffc0000000000
R13: 0000000000000000 R14: ffff8880400838d0 R15: dffffc0000000000
FS: 000055555c16c4c0(0000) GS:ffff8881246fa000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 00000000387ec000 CR4: 00000000003526f0
Call Trace:
<TASK>
utf8byte+0x342/0x13b0 fs/unicode/utf8-norm.c:-1
utf8_casefold+0x145/0x260 fs/unicode/utf8-core.c:110
ext4_fname_setup_ci_filename+0x23c/0x460 fs/ext4/namei.c:1226
ext4_fname_prepare_lookup+0x32e/0x4f0 fs/ext4/crypto.c:54
ext4_lookup_entry fs/ext4/namei.c:1547 [inline]
ext4_lookup+0x129/0x710 fs/ext4/namei.c:1619
__lookup_slow+0x1fb/0x2f0 fs/namei.c:1925
lookup_slow+0x59/0x80 fs/namei.c:1942
walk_component fs/namei.c:2288 [inline]
lookup_last fs/namei.c:2795 [inline]
path_lookupat+0x3f5/0x8c0 fs/namei.c:2819
filename_lookup+0x265/0x5d0 fs/namei.c:2848
user_path_at+0x40/0x160 fs/namei.c:3647
do_mount fs/namespace.c:4347 [inline]
__do_sys_mount fs/namespace.c:4563 [inline]
__se_sys_mount+0x2dc/0x420 fs/namespace.c:4540
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x171/0x540 arch/x86/entry/syscall_64.c:89
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fc021bf6249
Code: c0 79 93 eb d5 48 8d 7c 1d 00 eb 99 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 d8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fff02f621b8 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fc021bf6249
RDX: 0000000000000000 RSI: 0000200000004680 RDI: 0000000000000000
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000001202010 R11: 0000000000000246 R12: 00007fff02f62200
R13: 0000000000000002 R14: 431bde82d7b634db R15: 00007fc021c5504b
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:utf8nlookup+0x39/0xa60 fs/unicode/utf8-norm.c:306
Code: 89 44 24 10 49 89 ce 48 89 14 24 89 f5 49 89 fd 49 bf 00 00 00 00 00 fc ff df e8 32 07 c9 fe 49 8d 5d 18 48 89 d8 48 c1 e8 03 <42> 80 3c 38 00 74 08 48 89 df e8 98 07 3d ff 48 8b 1b 48 83 c3 30
RSP: 0018:ffffc90004cbf568 EFLAGS: 00010206
RAX: 0000000000000003 RBX: 0000000000000018 RCX: ffff88801cbb8000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000001 R08: 0000000000000005 R09: 0000000000000000
R10: ffffc90004cbf6f8 R11: fffff52000997ee2 R12: dffffc0000000000
R13: 0000000000000000 R14: ffff8880400838d0 R15: dffffc0000000000
FS: 000055555c16c4c0(0000) GS:ffff8881246fa000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 00000000387ec000 CR4: 00000000003526f0
----------------
Code disassembly (best guess):
0: 89 44 24 10 mov %eax,0x10(%rsp)
4: 49 89 ce mov %rcx,%r14
7: 48 89 14 24 mov %rdx,(%rsp)
b: 89 f5 mov %esi,%ebp
d: 49 89 fd mov %rdi,%r13
10: 49 bf 00 00 00 00 00 movabs $0xdffffc0000000000,%r15
17: fc ff df
1a: e8 32 07 c9 fe call 0xfec90751
1f: 49 8d 5d 18 lea 0x18(%r13),%rbx
23: 48 89 d8 mov %rbx,%rax
26: 48 c1 e8 03 shr $0x3,%rax
* 2a: 42 80 3c 38 00 cmpb $0x0,(%rax,%r15,1) <-- trapping instruction
2f: 74 08 je 0x39
31: 48 89 df mov %rbx,%rdi
34: e8 98 07 3d ff call 0xff3d07d1
39: 48 8b 1b mov (%rbx),%rbx
3c: 48 83 c3 30 add $0x30,%rbx
---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
For information about bisection process see: https://goo.gl/tpsmEJ#ai-bisection
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] ext4: Add validity checks for the casefold feature
2026-11-30 2:39 [syzbot] [ext4?] general protection fault in utf8nlookup (2) syzbot
@ 2026-11-30 11:05 ` Edward Adam Davis
2026-11-30 11:14 ` sashiko-bot
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Edward Adam Davis @ 2026-11-30 11:05 UTC (permalink / raw)
To: syzbot+68178aa1e39c8606392e
Cc: djwong, jack, krisman, linux-ext4, linux-fsdevel, linux-kernel,
syzkaller-bugs, tytso
The EXT4_FEATURE_INCOMPAT_CASEFOLD feature is not enabled during the file
system mount process; consequently, s_encoding is not loaded into the
superblock. When the EXT4_FEATURE_INCOMPAT_CASEFOLD feature is enabled via
EXT4_IOC_SET_TUNE_SB_PARAM, sb->s_encoding is not initialized.
After the EXT4_CASEFOLD_FL flag is set on a dir via ext4_ioctl_setflags(),
the lookup operation performed on that directory triggers a call to the
ext4_fname_setup_ci_filename() function. This function passes the NULL
value of dir->i_sb->s_encoding to utf8_casefold(), which subsequently leads
to a null-ptr-deref of um->tables within utf8nlookup().
Added validity checks related to casefold feature to prevent referencing
an uninitialized encoding.
Fixes: 04a91570ac67 ("ext4: implemet new ioctls to set and get superblock parameters")
Reported-by: syzbot+68178aa1e39c8606392e@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=68178aa1e39c8606392e
Signed-off-by: Edward Adam Davis <eadavis@sina.com>
---
fs/ext4/ioctl.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 83630cd40712..48d30c529490 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -1464,7 +1464,10 @@ static int ext4_validate_tune_sb_params(struct super_block *sb,
(params->clear_feature_incompat_mask &
~EXT4_TUNE_CLEAR_INCOMPAT_SUPP) ||
(params->clear_feature_ro_compat_mask &
- ~EXT4_TUNE_CLEAR_RO_COMPAT_SUPP))
+ ~EXT4_TUNE_CLEAR_RO_COMPAT_SUPP) ||
+ (params->set_feature_incompat_mask &
+ EXT4_FEATURE_INCOMPAT_CASEFOLD &&
+ !sb->s_encoding))
return -EOPNOTSUPP;
/*
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] ext4: Add validity checks for the casefold feature
2026-11-30 11:05 ` [PATCH] ext4: Add validity checks for the casefold feature Edward Adam Davis
@ 2026-11-30 11:14 ` sashiko-bot
2026-11-30 16:32 ` kernel test robot
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-11-30 11:14 UTC (permalink / raw)
To: Edward Adam Davis; +Cc: linux-ext4, tytso
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] ext4: build failure in ext4_validate_tune_sb_params() when
!CONFIG_UNICODE
- [High] ext4: !sb->s_encoding check in ext4_validate_tune_sb_params()
breaks casefold
--
commit b69d2db6559fe89244b924e5c930a3c0e5ee3784
Author: Edward Adam Davis <eadavis@sina.com>
ext4: Add validity checks for the casefold feature
This commit rejects setting EXT4_FEATURE_INCOMPAT_CASEFOLD in
ext4_validate_tune_sb_params() when sb->s_encoding is not initialized.
> diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
> index 83630cd40712c..48d30c5294908 100644
> --- a/fs/ext4/ioctl.c
> +++ b/fs/ext4/ioctl.c
> @@ -1464,7 +1464,10 @@ static int ext4_validate_tune_sb_params(struct super_block *sb,
> (params->clear_feature_incompat_mask &
> ~EXT4_TUNE_CLEAR_INCOMPAT_SUPP) ||
> (params->clear_feature_ro_compat_mask &
> - ~EXT4_TUNE_CLEAR_RO_COMPAT_SUPP))
> + ~EXT4_TUNE_CLEAR_RO_COMPAT_SUPP) ||
> + (params->set_feature_incompat_mask &
> + EXT4_FEATURE_INCOMPAT_CASEFOLD &&
> + !sb->s_encoding))
> return -EOPNOTSUPP;
>
> /*
[Severity: High]
Does accessing sb->s_encoding directly break the build when
CONFIG_UNICODE is disabled? struct super_block only defines s_encoding
under #if IS_ENABLED(CONFIG_UNICODE), and CONFIG_EXT4_FS does not depend
on CONFIG_UNICODE.
[Severity: High]
Does requiring sb->s_encoding here make it impossible to ever enable
EXT4_FEATURE_INCOMPAT_CASEFOLD via EXT4_IOC_SET_TUNE_SB_PARAM?
At mount time, ext4_encoding_init() only populates sb->s_encoding if
EXT4_FEATURE_INCOMPAT_CASEFOLD is already set in the superblock:
fs/ext4/super.c:ext4_encoding_init() {
if (!ext4_has_feature_casefold(sb) || sb->s_encoding)
return 0;
When the feature is not yet set, sb->s_encoding is NULL and this check
returns -EOPNOTSUPP. When the feature was already set at mount time,
ext4_validate_tune_sb_params() clears already-enabled features from
params->set_feature_incompat_mask right below, so the enabling_casefold
branch and the EXT4_TUNE_FL_ENCODING handling become unreachable dead
code (and test_validate_tune_sb_params() in fs/ext4/ioctl-test.c fails).
If EXT4_IOC_SET_TUNE_SB_PARAM is meant to write the feature to the
superblock for subsequent mounts without loading sb->s_encoding online,
should ext4_ioctl_setflags() check sb_has_encoding(sb) alongside
ext4_has_feature_casefold(sb) before allowing EXT4_CASEFOLD_FL to be set
on a directory?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130110526.116017-1-eadavis@sina.com?part=1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ext4: Add validity checks for the casefold feature
2026-11-30 11:05 ` [PATCH] ext4: Add validity checks for the casefold feature Edward Adam Davis
2026-11-30 11:14 ` sashiko-bot
@ 2026-11-30 16:32 ` kernel test robot
2026-11-30 16:35 ` Gabriel Krisman Bertazi
2026-11-30 16:44 ` kernel test robot
3 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2026-11-30 16:32 UTC (permalink / raw)
To: Edward Adam Davis, syzbot+68178aa1e39c8606392e
Cc: oe-kbuild-all, djwong, jack, krisman, linux-ext4, linux-fsdevel,
linux-kernel, syzkaller-bugs, tytso
Hi Edward,
kernel test robot noticed the following build errors:
[auto build test ERROR on tytso-ext4/dev]
[also build test ERROR on linus/master v7.4-rc5 next-20261127]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Edward-Adam-Davis/ext4-Add-validity-checks-for-the-casefold-feature/20261130-190526
base: https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
patch link: https://lore.kernel.org/r/20261130110526.116017-1-eadavis%40sina.com
patch subject: [PATCH] ext4: Add validity checks for the casefold feature
config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20261201/20261201001916.FMgZboPW-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261201/20261201001916.FMgZboPW-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261201001916.FMgZboPW-lkp@intel.com/
All errors (new ones prefixed by >>):
fs/ext4/ioctl.c: In function 'ext4_validate_tune_sb_params':
>> fs/ext4/ioctl.c:1470:25: error: 'struct super_block' has no member named 's_encoding'
1470 | !sb->s_encoding))
| ^~
vim +1470 fs/ext4/ioctl.c
1404
1405 static int ext4_validate_tune_sb_params(struct super_block *sb,
1406 struct ext4_tune_sb_params *params)
1407 {
1408 struct ext4_sb_info *sbi = EXT4_SB(sb);
1409 struct ext4_super_block *es = sbi->s_es;
1410 int enabling_casefold = 0;
1411
1412 if (strnlen(params->mount_opts, sizeof(params->mount_opts)) ==
1413 sizeof(params->mount_opts))
1414 return -E2BIG;
1415
1416 if ((params->set_flags & ~TUNE_OPS_SUPPORTED) != 0)
1417 return -EOPNOTSUPP;
1418
1419 if ((params->set_flags & EXT4_TUNE_FL_ERRORS_BEHAVIOR) &&
1420 (params->errors_behavior > EXT4_ERRORS_PANIC))
1421 return -EINVAL;
1422
1423 if ((params->set_flags & EXT4_TUNE_FL_RESERVED_BLOCKS) &&
1424 (params->reserved_blocks > ext4_blocks_count(sbi->s_es) / 2))
1425 return -EINVAL;
1426 if ((params->set_flags & EXT4_TUNE_FL_DEF_HASH_ALG) &&
1427 ((params->def_hash_alg > DX_HASH_LAST) ||
1428 (params->def_hash_alg == DX_HASH_SIPHASH)))
1429 return -EINVAL;
1430 if ((params->set_flags & EXT4_TUNE_FL_FEATURES) &&
1431 (params->set_flags & EXT4_TUNE_FL_EDIT_FEATURES))
1432 return -EINVAL;
1433
1434 if (params->set_flags & EXT4_TUNE_FL_FEATURES) {
1435 params->set_feature_compat_mask =
1436 params->feature_compat &
1437 ~le32_to_cpu(es->s_feature_compat);
1438 params->set_feature_incompat_mask =
1439 params->feature_incompat &
1440 ~le32_to_cpu(es->s_feature_incompat);
1441 params->set_feature_ro_compat_mask =
1442 params->feature_ro_compat &
1443 ~le32_to_cpu(es->s_feature_ro_compat);
1444 params->clear_feature_compat_mask =
1445 ~params->feature_compat &
1446 le32_to_cpu(es->s_feature_compat);
1447 params->clear_feature_incompat_mask =
1448 ~params->feature_incompat &
1449 le32_to_cpu(es->s_feature_incompat);
1450 params->clear_feature_ro_compat_mask =
1451 ~params->feature_ro_compat &
1452 le32_to_cpu(es->s_feature_ro_compat);
1453 params->set_flags |= EXT4_TUNE_FL_EDIT_FEATURES;
1454 }
1455 if (params->set_flags & EXT4_TUNE_FL_EDIT_FEATURES) {
1456 if ((params->set_feature_compat_mask &
1457 ~EXT4_TUNE_SET_COMPAT_SUPP) ||
1458 (params->set_feature_incompat_mask &
1459 ~EXT4_TUNE_SET_INCOMPAT_SUPP) ||
1460 (params->set_feature_ro_compat_mask &
1461 ~EXT4_TUNE_SET_RO_COMPAT_SUPP) ||
1462 (params->clear_feature_compat_mask &
1463 ~EXT4_TUNE_CLEAR_COMPAT_SUPP) ||
1464 (params->clear_feature_incompat_mask &
1465 ~EXT4_TUNE_CLEAR_INCOMPAT_SUPP) ||
1466 (params->clear_feature_ro_compat_mask &
1467 ~EXT4_TUNE_CLEAR_RO_COMPAT_SUPP) ||
1468 (params->set_feature_incompat_mask &
1469 EXT4_FEATURE_INCOMPAT_CASEFOLD &&
> 1470 !sb->s_encoding))
1471 return -EOPNOTSUPP;
1472
1473 /*
1474 * Filter out the features that are already set from
1475 * the set_mask.
1476 */
1477 params->set_feature_compat_mask &=
1478 ~le32_to_cpu(es->s_feature_compat);
1479 params->set_feature_incompat_mask &=
1480 ~le32_to_cpu(es->s_feature_incompat);
1481 params->set_feature_ro_compat_mask &=
1482 ~le32_to_cpu(es->s_feature_ro_compat);
1483 if (params->set_feature_incompat_mask &
1484 EXT4_FEATURE_INCOMPAT_CASEFOLD) {
1485 enabling_casefold = 1;
1486 if (!(params->set_flags & EXT4_TUNE_FL_ENCODING)) {
1487 params->encoding = EXT4_ENC_UTF8_12_1;
1488 params->set_flags |= EXT4_TUNE_FL_ENCODING;
1489 }
1490 if (!(params->set_flags &
1491 EXT4_TUNE_FL_ENCODING_FLAGS)) {
1492 params->encoding_flags = 0;
1493 params->set_flags |=
1494 EXT4_TUNE_FL_ENCODING_FLAGS;
1495 }
1496 }
1497 if (params->set_feature_compat_mask &
1498 EXT4_FEATURE_COMPAT_DIR_INDEX) {
1499 uuid_t uu;
1500
1501 memcpy(&uu, sbi->s_hash_seed, UUID_SIZE);
1502 if (uuid_is_null(&uu))
1503 generate_random_uuid((char *)&sbi->s_hash_seed);
1504 if (params->set_flags & EXT4_TUNE_FL_DEF_HASH_ALG)
1505 sbi->s_def_hash_version = params->def_hash_alg;
1506 else if (sbi->s_def_hash_version == 0)
1507 sbi->s_def_hash_version = DX_HASH_HALF_MD4;
1508 if (!(es->s_flags &
1509 cpu_to_le32(EXT2_FLAGS_UNSIGNED_HASH)) &&
1510 !(es->s_flags &
1511 cpu_to_le32(EXT2_FLAGS_SIGNED_HASH))) {
1512 #ifdef __CHAR_UNSIGNED__
1513 sbi->s_hash_unsigned = 3;
1514 #else
1515 sbi->s_hash_unsigned = 0;
1516 #endif
1517 }
1518 }
1519 }
1520 if (params->set_flags & EXT4_TUNE_FL_ENCODING) {
1521 if (!enabling_casefold)
1522 return -EINVAL;
1523 if (params->encoding == 0)
1524 params->encoding = EXT4_ENC_UTF8_12_1;
1525 else if (params->encoding != EXT4_ENC_UTF8_12_1)
1526 return -EINVAL;
1527 }
1528 if (params->set_flags & EXT4_TUNE_FL_ENCODING_FLAGS) {
1529 if (!enabling_casefold)
1530 return -EINVAL;
1531 if (params->encoding_flags & ~SB_ENC_SUPP_MASK)
1532 return -EINVAL;
1533 }
1534
1535 return 0;
1536 }
1537
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ext4: Add validity checks for the casefold feature
2026-11-30 11:05 ` [PATCH] ext4: Add validity checks for the casefold feature Edward Adam Davis
2026-11-30 11:14 ` sashiko-bot
2026-11-30 16:32 ` kernel test robot
@ 2026-11-30 16:35 ` Gabriel Krisman Bertazi
2026-11-30 16:44 ` kernel test robot
3 siblings, 0 replies; 6+ messages in thread
From: Gabriel Krisman Bertazi @ 2026-11-30 16:35 UTC (permalink / raw)
To: Edward Adam Davis, syzbot+68178aa1e39c8606392e
Cc: djwong, jack, linux-ext4, linux-fsdevel, linux-kernel,
syzkaller-bugs, tytso
Edward Adam Davis <eadavis@sina.com> writes:
> The EXT4_FEATURE_INCOMPAT_CASEFOLD feature is not enabled during the file
> system mount process; consequently, s_encoding is not loaded into the
> superblock. When the EXT4_FEATURE_INCOMPAT_CASEFOLD feature is enabled via
> EXT4_IOC_SET_TUNE_SB_PARAM, sb->s_encoding is not initialized.
> After the EXT4_CASEFOLD_FL flag is set on a dir via ext4_ioctl_setflags(),
> the lookup operation performed on that directory triggers a call to the
> ext4_fname_setup_ci_filename() function. This function passes the NULL
> value of dir->i_sb->s_encoding to utf8_casefold(), which subsequently leads
> to a null-ptr-deref of um->tables within utf8nlookup().
>
> Added validity checks related to casefold feature to prevent referencing
> an uninitialized encoding.
Yeah, I don't think we can really have FEATURE_INCOMPAT_CASEFOLD
correctly enabled at runtime via SET_TUNE_SB_PARAM and working
immediately, because we cannot safely overwrite d->d_ops of all existing
dentries. Even if we start setting ->d_ops for newer dentries after
setting this flag, or somehow when flipping +F, we need vfs support when
instantiating negative dentries and ugh.
I also don't know if people really need to set FEATURE_INCOMPAT_CASEFOLD
at runtime, but if the need exists, it should be after a umount-mount to
ensures the tree is completely pruned from the cache.
Either way if we disable it, like this patch suggests, GET_TUNE_SB_PARAM
should be changed too to not say it is supported.
--
Gabriel Krisman Bertazi
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ext4: Add validity checks for the casefold feature
2026-11-30 11:05 ` [PATCH] ext4: Add validity checks for the casefold feature Edward Adam Davis
` (2 preceding siblings ...)
2026-11-30 16:35 ` Gabriel Krisman Bertazi
@ 2026-11-30 16:44 ` kernel test robot
3 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2026-11-30 16:44 UTC (permalink / raw)
To: Edward Adam Davis, syzbot+68178aa1e39c8606392e
Cc: llvm, oe-kbuild-all, djwong, jack, krisman, linux-ext4,
linux-fsdevel, linux-kernel, syzkaller-bugs, tytso
Hi Edward,
kernel test robot noticed the following build errors:
[auto build test ERROR on tytso-ext4/dev]
[also build test ERROR on linus/master v7.4-rc5 next-20261127]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Edward-Adam-Davis/ext4-Add-validity-checks-for-the-casefold-feature/20261130-190526
base: https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
patch link: https://lore.kernel.org/r/20261130110526.116017-1-eadavis%40sina.com
patch subject: [PATCH] ext4: Add validity checks for the casefold feature
config: um-x86_64_defconfig (https://download.01.org/0day-ci/archive/20261201/20261201003713.BSu5NSdv-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project ed93dc8f7a98c7dfdbf6f203bf72e6e9a82cde3e)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261201/20261201003713.BSu5NSdv-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261201003713.BSu5NSdv-lkp@intel.com/
All errors (new ones prefixed by >>):
>> fs/ext4/ioctl.c:1470:13: error: no member named 's_encoding' in 'struct super_block'
1470 | !sb->s_encoding))
| ~~ ^
1 error generated.
vim +1470 fs/ext4/ioctl.c
1404
1405 static int ext4_validate_tune_sb_params(struct super_block *sb,
1406 struct ext4_tune_sb_params *params)
1407 {
1408 struct ext4_sb_info *sbi = EXT4_SB(sb);
1409 struct ext4_super_block *es = sbi->s_es;
1410 int enabling_casefold = 0;
1411
1412 if (strnlen(params->mount_opts, sizeof(params->mount_opts)) ==
1413 sizeof(params->mount_opts))
1414 return -E2BIG;
1415
1416 if ((params->set_flags & ~TUNE_OPS_SUPPORTED) != 0)
1417 return -EOPNOTSUPP;
1418
1419 if ((params->set_flags & EXT4_TUNE_FL_ERRORS_BEHAVIOR) &&
1420 (params->errors_behavior > EXT4_ERRORS_PANIC))
1421 return -EINVAL;
1422
1423 if ((params->set_flags & EXT4_TUNE_FL_RESERVED_BLOCKS) &&
1424 (params->reserved_blocks > ext4_blocks_count(sbi->s_es) / 2))
1425 return -EINVAL;
1426 if ((params->set_flags & EXT4_TUNE_FL_DEF_HASH_ALG) &&
1427 ((params->def_hash_alg > DX_HASH_LAST) ||
1428 (params->def_hash_alg == DX_HASH_SIPHASH)))
1429 return -EINVAL;
1430 if ((params->set_flags & EXT4_TUNE_FL_FEATURES) &&
1431 (params->set_flags & EXT4_TUNE_FL_EDIT_FEATURES))
1432 return -EINVAL;
1433
1434 if (params->set_flags & EXT4_TUNE_FL_FEATURES) {
1435 params->set_feature_compat_mask =
1436 params->feature_compat &
1437 ~le32_to_cpu(es->s_feature_compat);
1438 params->set_feature_incompat_mask =
1439 params->feature_incompat &
1440 ~le32_to_cpu(es->s_feature_incompat);
1441 params->set_feature_ro_compat_mask =
1442 params->feature_ro_compat &
1443 ~le32_to_cpu(es->s_feature_ro_compat);
1444 params->clear_feature_compat_mask =
1445 ~params->feature_compat &
1446 le32_to_cpu(es->s_feature_compat);
1447 params->clear_feature_incompat_mask =
1448 ~params->feature_incompat &
1449 le32_to_cpu(es->s_feature_incompat);
1450 params->clear_feature_ro_compat_mask =
1451 ~params->feature_ro_compat &
1452 le32_to_cpu(es->s_feature_ro_compat);
1453 params->set_flags |= EXT4_TUNE_FL_EDIT_FEATURES;
1454 }
1455 if (params->set_flags & EXT4_TUNE_FL_EDIT_FEATURES) {
1456 if ((params->set_feature_compat_mask &
1457 ~EXT4_TUNE_SET_COMPAT_SUPP) ||
1458 (params->set_feature_incompat_mask &
1459 ~EXT4_TUNE_SET_INCOMPAT_SUPP) ||
1460 (params->set_feature_ro_compat_mask &
1461 ~EXT4_TUNE_SET_RO_COMPAT_SUPP) ||
1462 (params->clear_feature_compat_mask &
1463 ~EXT4_TUNE_CLEAR_COMPAT_SUPP) ||
1464 (params->clear_feature_incompat_mask &
1465 ~EXT4_TUNE_CLEAR_INCOMPAT_SUPP) ||
1466 (params->clear_feature_ro_compat_mask &
1467 ~EXT4_TUNE_CLEAR_RO_COMPAT_SUPP) ||
1468 (params->set_feature_incompat_mask &
1469 EXT4_FEATURE_INCOMPAT_CASEFOLD &&
> 1470 !sb->s_encoding))
1471 return -EOPNOTSUPP;
1472
1473 /*
1474 * Filter out the features that are already set from
1475 * the set_mask.
1476 */
1477 params->set_feature_compat_mask &=
1478 ~le32_to_cpu(es->s_feature_compat);
1479 params->set_feature_incompat_mask &=
1480 ~le32_to_cpu(es->s_feature_incompat);
1481 params->set_feature_ro_compat_mask &=
1482 ~le32_to_cpu(es->s_feature_ro_compat);
1483 if (params->set_feature_incompat_mask &
1484 EXT4_FEATURE_INCOMPAT_CASEFOLD) {
1485 enabling_casefold = 1;
1486 if (!(params->set_flags & EXT4_TUNE_FL_ENCODING)) {
1487 params->encoding = EXT4_ENC_UTF8_12_1;
1488 params->set_flags |= EXT4_TUNE_FL_ENCODING;
1489 }
1490 if (!(params->set_flags &
1491 EXT4_TUNE_FL_ENCODING_FLAGS)) {
1492 params->encoding_flags = 0;
1493 params->set_flags |=
1494 EXT4_TUNE_FL_ENCODING_FLAGS;
1495 }
1496 }
1497 if (params->set_feature_compat_mask &
1498 EXT4_FEATURE_COMPAT_DIR_INDEX) {
1499 uuid_t uu;
1500
1501 memcpy(&uu, sbi->s_hash_seed, UUID_SIZE);
1502 if (uuid_is_null(&uu))
1503 generate_random_uuid((char *)&sbi->s_hash_seed);
1504 if (params->set_flags & EXT4_TUNE_FL_DEF_HASH_ALG)
1505 sbi->s_def_hash_version = params->def_hash_alg;
1506 else if (sbi->s_def_hash_version == 0)
1507 sbi->s_def_hash_version = DX_HASH_HALF_MD4;
1508 if (!(es->s_flags &
1509 cpu_to_le32(EXT2_FLAGS_UNSIGNED_HASH)) &&
1510 !(es->s_flags &
1511 cpu_to_le32(EXT2_FLAGS_SIGNED_HASH))) {
1512 #ifdef __CHAR_UNSIGNED__
1513 sbi->s_hash_unsigned = 3;
1514 #else
1515 sbi->s_hash_unsigned = 0;
1516 #endif
1517 }
1518 }
1519 }
1520 if (params->set_flags & EXT4_TUNE_FL_ENCODING) {
1521 if (!enabling_casefold)
1522 return -EINVAL;
1523 if (params->encoding == 0)
1524 params->encoding = EXT4_ENC_UTF8_12_1;
1525 else if (params->encoding != EXT4_ENC_UTF8_12_1)
1526 return -EINVAL;
1527 }
1528 if (params->set_flags & EXT4_TUNE_FL_ENCODING_FLAGS) {
1529 if (!enabling_casefold)
1530 return -EINVAL;
1531 if (params->encoding_flags & ~SB_ENC_SUPP_MASK)
1532 return -EINVAL;
1533 }
1534
1535 return 0;
1536 }
1537
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-30 16:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 2:39 [syzbot] [ext4?] general protection fault in utf8nlookup (2) syzbot
2026-11-30 11:05 ` [PATCH] ext4: Add validity checks for the casefold feature Edward Adam Davis
2026-11-30 11:14 ` sashiko-bot
2026-11-30 16:32 ` kernel test robot
2026-11-30 16:35 ` Gabriel Krisman Bertazi
2026-11-30 16:44 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox