syzbot
general protection fault in lookup_open
Status:
upstream: reported C repro on 2026/11/14 12:09
Subsystems:
squashfs
Labels:
prio:normal
[Documentation on labels]
Reported-by: syzbot+0b7a8fb8279a59e8a188@syzkaller.appspotmail.com
First crash: 10h56m, last: 46m
✨ AI-generated root cause summary:
In fs/squashfs/namei.c:squashfs_lookup(), sanity checks using squashfs_dir_space() jump directly to label read_failure instead of data_error upon detecting that a directory entry extends beyond inode size. Jumping to read_failure bypasses the assignment of err = -EIO, leaving err set to either an uninitialized value or a positive value returned by a prior successful call to squashfs_read_metadata() (such as sizeof(struct squashfs_dir_entry) == 8). Consequently, squashfs_lookup() returns ERR_PTR(8), which IS_ERR() does not recognize as an error pointer; VFS lookup_open() subsequently dereferences dentry->d_inode at address 0x8 + 0x68 = 0x70, triggering a near-NULL pointer dereference crash.
▶
▼
✨ Full AI root cause analysis
Root Cause Analysis
Involved Files, Functions, and Structures
- Source file:
fs/squashfs/namei.c
- Functions involved:
squashfs_lookup() (fs/squashfs/namei.c), finish_lookup() and lookup_open() (fs/namei.c)
- Structures involved:
struct squashfs_dir_entry, struct squashfs_dir_header, struct dentry (d_inode at offset 0x68 / 104 bytes)
Technical Mechanism
-
Error Handling Flaw in squashfs_lookup() (fs/squashfs/namei.c):
In squashfs_lookup(), directory entries are read in a loop. Three sanity checks verify whether the directory header and entries fit within the remaining directory space using squashfs_dir_space():
/* Line 205 */
if (!squashfs_dir_space(dir, length, sizeof(dirh)))
goto read_failure;
...
/* Line 224 */
if (!squashfs_dir_space(dir, length, sizeof(*dire)))
goto read_failure;
...
/* Line 239 */
if (!squashfs_dir_space(dir, length, size))
goto read_failure;
All three checks jump directly to label read_failure:
data_error:
err = -EIO;
read_failure:
ERROR("Unable to read directory block [%llx:%x]\n",
squashfs_i(dir)->start, squashfs_i(dir)->offset);
failed:
kfree(dire);
return ERR_PTR(err);
-
Unset / Positive err Value:
Unlike data_error:, which initializes err = -EIO; and falls through to read_failure:, jumping directly to read_failure: skips setting err.
- On success, preceding calls to
squashfs_read_metadata() return the number of bytes read (e.g. sizeof(*dire) == 8 or sizeof(dirh) == 12).
- Thus, if
!squashfs_dir_space(dir, length, size) fails at line 239, err retains the value returned by squashfs_read_metadata() at line 227, which is 8.
squashfs_lookup() then returns ERR_PTR(err), which evaluates to ERR_PTR(8) or (void *)0x8.
-
VFS Error Pointer Invariant Violation:
- In Linux VFS, error pointers are encoded in the range
[-MAX_ERRNO, -1], i.e., 0xfffffffffffff001 through 0xffffffffffffffff.
- In
finish_lookup() (fs/namei.c):
res = dir->i_op->lookup(dir, dentry, flags);
d_lookup_done(dentry);
if (unlikely(res)) {
dput(dentry);
return res;
}
Because res is (struct dentry *)0x8 (non-NULL), finish_lookup() drops the lookup dentry and returns (struct dentry *)0x8.
- In
lookup_open() (fs/namei.c:4644-4648):
dentry = finish_lookup(dir_inode, dentry, nd->flags | shared_flag);
if (IS_ERR(dentry))
goto out;
if (dentry->d_inode || !(op->open_flag & O_CREAT)) {
IS_ERR((void *)0x8) evaluates to false. lookup_open() treats dentry as a valid pointer to a struct dentry and reads dentry->d_inode.
-
Crash Manifestation:
- The field
d_inode resides at offset 0x68 (104 bytes) in struct dentry.
- Accessing
((struct dentry *)0x8)->d_inode attempts to read address 0x8 + 0x68 = 0x70.
- Under KASAN, shadow memory address calculation
(0x70 >> 3) + 0xdffffc0000000000 = 0xdffffc000000000e triggers a general protection fault (#GP) due to accessing a non-canonical address.
- In non-KASAN environments, reading address
0x70 (within unmapped page 0) immediately triggers an unhandled kernel page fault, resulting in a kernel oops/panic.
Suggested Fix
Change goto read_failure; to goto data_error; on all three !squashfs_dir_space(...) checks in fs/squashfs/namei.c so that err is properly set to -EIO before jumping to read_failure.
Sample crash report:
loop0: detected capacity change from 0 to 8
SQUASHFS error: Unable to read directory block [0:26]
Oops: general protection fault, probably for non-canonical address 0xdffffc000000000d: 0000 [#1] SMP KASAN PTI
KASAN: null-ptr-deref in range [0x0000000000000068-0x000000000000006f]
CPU: 1 UID: 0 PID: 5645 Comm: syz-executor126 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
RIP: 0010:lookup_open+0x890/0x16e0 fs/namei.c:4648
Code: 09 00 00 e8 a2 60 68 ff 49 81 ff 01 f0 ff ff 0f 83 2a ff ff ff 4d 8d 77 68 4c 89 f0 48 c1 e8 03 48 b9 00 00 00 00 00 fc ff df <80> 3c 08 00 74 08 4c 89 f7 e8 92 54 e8 ff 49 83 3e 00 74 07 e8 67
RSP: 0018:ffffc900039579c0 EFLAGS: 00010203
RAX: 000000000000000d RBX: 0000000000000040 RCX: dffffc0000000000
RDX: 0000000000000000 RSI: 0000000000000004 RDI: 00000000ffffffff
RBP: 00000000ffffffe2 R08: ffff8880134403fb R09: 1ffff1100268807f
R10: dffffc0000000000 R11: ffffed1002688080 R12: 1ffff110026f064c
R13: ffffc90003957e00 R14: 000000000000006e R15: 0000000000000006
FS: 0000555559c4d400(0000) GS:ffff8881234cd000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000020000000b400 CR3: 0000000071a58000 CR4: 00000000003526f0
Call Trace:
<TASK>
open_last_lookups fs/namei.c:4880 [inline]
path_openat+0x7a5/0x20e0 fs/namei.c:5119
do_file_open+0x23e/0x4a0 fs/namei.c:5151
do_sys_openat2+0x115/0x200 fs/open.c:1492
do_sys_open fs/open.c:1498 [inline]
__do_sys_openat fs/open.c:1838 [inline]
__se_sys_openat fs/open.c:1833 [inline]
__x64_sys_openat+0x138/0x170 fs/open.c:1833
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:0x00007fc862573909
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:00007fff58fa7d68 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fc862573909
RDX: 000000000000275a RSI: 000020000000b400 RDI: 00000000ffffff9c
RBP: 0000000000000001 R08: 0000000000000000 R09: 0000555559c4e580
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fff58fa7d90
R13: 0000000000000002 R14: 431bde82d7b634db R15: 00007fc8625d304b
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:lookup_open+0x890/0x16e0 fs/namei.c:4648
Code: 09 00 00 e8 a2 60 68 ff 49 81 ff 01 f0 ff ff 0f 83 2a ff ff ff 4d 8d 77 68 4c 89 f0 48 c1 e8 03 48 b9 00 00 00 00 00 fc ff df <80> 3c 08 00 74 08 4c 89 f7 e8 92 54 e8 ff 49 83 3e 00 74 07 e8 67
RSP: 0018:ffffc900039579c0 EFLAGS: 00010203
RAX: 000000000000000d RBX: 0000000000000040 RCX: dffffc0000000000
RDX: 0000000000000000 RSI: 0000000000000004 RDI: 00000000ffffffff
RBP: 00000000ffffffe2 R08: ffff8880134403fb R09: 1ffff1100268807f
R10: dffffc0000000000 R11: ffffed1002688080 R12: 1ffff110026f064c
R13: ffffc90003957e00 R14: 000000000000006e R15: 0000000000000006
FS: 0000555559c4d400(0000) GS:ffff8881233cd000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000557377da1760 CR3: 0000000071a58000 CR4: 00000000003526f0
----------------
Code disassembly (best guess), 1 bytes skipped:
0: 00 00 add %al,(%rax)
2: e8 a2 60 68 ff call 0xff6860a9
7: 49 81 ff 01 f0 ff ff cmp $0xfffffffffffff001,%r15
e: 0f 83 2a ff ff ff jae 0xffffff3e
14: 4d 8d 77 68 lea 0x68(%r15),%r14
18: 4c 89 f0 mov %r14,%rax
1b: 48 c1 e8 03 shr $0x3,%rax
1f: 48 b9 00 00 00 00 00 movabs $0xdffffc0000000000,%rcx
26: fc ff df
* 29: 80 3c 08 00 cmpb $0x0,(%rax,%rcx,1) <-- trapping instruction
2d: 74 08 je 0x37
2f: 4c 89 f7 mov %r14,%rdi
32: e8 92 54 e8 ff call 0xffe854c9
37: 49 83 3e 00 cmpq $0x0,(%r14)
3b: 74 07 je 0x44
3d: e8 .byte 0xe8
3e: 67 addr32
* Struck through repros no longer work on HEAD.