general protection fault in utf8nlookup (2)

Status: upstream: reported C repro on 2026/11/30 02:39
Subsystems: ext4
Labels: prio:low
[Documentation on labels]
Reported-by: syzbot+68178aa1e39c8606392e@syzkaller.appspotmail.com
First crash: 2h12m, last: 29m
✨ AI cause bisection: introduced by (AI job) :
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

✨ 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 AI root cause analysis
Based on kernel commit 4f069ab1ec24:

Root Cause

The crash is a NULL-pointer dereference in utf8nlookup() (fs/unicode/utf8-norm.c:306) caused by an ext4 directory having S_CASEFOLD (IS_CASEFOLDED(dir)) set while dir->i_sb->s_encoding is NULL:

static utf8leaf_t *utf8nlookup(const struct unicode_map *um,
		enum utf8_normalization n, unsigned char *hangul, const char *s,
		size_t len)
{
	utf8trie_t	*trie = um->tables->utf8data + um->ntab[n]->offset;

In the crash report, %r13 (um) is NULL, and 0x18(%r13) is um->tables (offset 0x18 in struct unicode_map), producing the KASAN report at [0x0000000000000018-0x000000000000001f].

Broken Invariant in fs/ext4/ioctl.c

Normally, ext4 enforces the invariant that IS_CASEFOLDED(inode) implies sb->s_encoding != NULL (when CONFIG_UNICODE=y):

  1. At mount time, __ext4_fill_super() (fs/ext4/super.c:5519) calls ext4_encoding_init(sb, es), which loads the UTF-8 map via utf8_load() into sb->s_encoding if ext4_has_feature_casefold(sb) is true (and fails the mount otherwise). generic_set_sb_d_ops(sb) (fs/ext4/super.c:5729) then installs generic_ci_dentry_ops only if sb->s_encoding is non-NULL.
  2. If EXT4_FEATURE_INCOMPAT_CASEFOLD was not set at mount time, sb->s_encoding remains NULL.

However, ext4_ioctl_set_tune_sb() (EXT4_IOC_SET_TUNE_SB_PARAM, fs/ext4/ioctl.c:1535) breaks this invariant on a live mounted filesystem:

  • EXT4_TUNE_SET_INCOMPAT_SUPP (fs/ext4/ioctl.c:1278) includes EXT4_FEATURE_INCOMPAT_CASEFOLD, and ext4_validate_tune_sb_params() (fs/ext4/ioctl.c:1480-1493) explicitly allows enabling EXT4_FEATURE_INCOMPAT_CASEFOLD (defaulting params->encoding = EXT4_ENC_UTF8_12_1 and params->encoding_flags = 0).
  • ext4_update_superblocks_fn(sb, ext4_sb_setparams, &params) updates the superblock buffer sbi->s_es (es->s_feature_incompat |= EXT4_FEATURE_INCOMPAT_CASEFOLD, es->s_encoding, es->s_encoding_flags).
  • ext4_ioctl_set_tune_sb() never initializes sb->s_encoding or sb->s_encoding_flags (i.e., it never calls ext4_encoding_init()), nor does it check CONFIG_UNICODE or set sb->s_d_op (generic_set_sb_d_ops()).

Trigger Path

  1. An ext4 filesystem is mounted without EXT4_FEATURE_INCOMPAT_CASEFOLD, so sb->s_encoding is NULL.
  2. ioctl(..., EXT4_IOC_SET_TUNE_SB_PARAM, ...) enables EXT4_FEATURE_INCOMPAT_CASEFOLD on sbi->s_es, causing ext4_has_feature_casefold(sb) to return true while sb->s_encoding stays NULL.
  3. ext4_ioctl_setflags() (fs/ext4/ioctl.c:631-635) / ext4_fileattr_set() checks only !ext4_has_feature_casefold(sb) (not sb->s_encoding) and therefore allows setting EXT4_CASEFOLD_FL (S_CASEFOLD) on an empty directory (similarly, __ext4_iget() at fs/ext4/inode.c:6674 only checks !ext4_has_feature_casefold(inode->i_sb)).
  4. Any subsequent lookup inside that directory (here triggered by do_mount -> user_path_at -> filename_lookup -> ext4_lookup) reaches:
    • ext4_lookup_entry() (fs/ext4/namei.c:1547)
    • ext4_fname_prepare_lookup() (fs/ext4/crypto.c:54)
    • ext4_fname_setup_ci_filename() (fs/ext4/namei.c:1226), which checks IS_CASEFOLDED(dir) without checking dir->i_sb->s_encoding and calls utf8_casefold(dir->i_sb->s_encoding, iname, buf, EXT4_NAME_LEN) with um == NULL.
    • utf8_casefold() (fs/unicode/utf8-core.c:106-110) initializes u8c->um = NULL in utf8ncursor() and calls utf8byte() -> utf8nlookup(), which dereferences um->tables at NULL + 0x18.

Note that other ext4 casefold paths (such as ext4fs_dirhash() in fs/ext4/hash.c:318-329 and generic_ci_d_hash() / generic_ci_match() in fs/libfs.c) also assume sb->s_encoding != NULL whenever IS_CASEFOLDED(dir) is true.

▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
6527b76a bisect-cause IsRelease: ❌ ❓ general protection fault in utf8nlookup (2) 2026/11/30 01:37 2026/11/30 01:37 2026/11/30 01:42 e1f06033
92204f17 assessment-security DenialOfService: ✅ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ❌ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ general protection fault in utf8nlookup (2) 2026/11/30 00:56 2026/11/30 00:56 2026/11/30 01:47 e1f06033
▶ ▼ Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [ext4?] general protection fault in utf8nlookup (2) 0 (1) 2026/11/30 02:39
▶ ▼ Similar bugs (2)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.6 general protection fault in utf8nlookup origin:upstream missing-backport 2 syz, C error 78 3d18h 490d 0/2 upstream: reported C repro on 2025/07/27 17:37
upstream general protection fault in utf8nlookup ext4 exfat 2 syz, C done done 3 1059d 1166d 25/30 fixed on 2024/02/16 19:40

Sample crash report:
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

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/30 02:39 upstream 4f069ab1ec24 e1f06033 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro (clean fs)] ci2-upstream-fs general protection fault in utf8nlookup
2026/11/30 00:56 upstream 4f069ab1ec24 e1f06033 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs general protection fault in utf8nlookup
* Struck through repros no longer work on HEAD.