syzbot
general protection fault in lookup_open
Status:
moderation: reported on 2026/11/14 02:16
Subsystems:
fs
Labels:
prio:normal
[Documentation on labels]
Reported-by: syzbot+1320c02ec41bae2d27e3@syzkaller.appspotmail.com
First crash: 1h12m, last: now
✨ 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:
loop5: 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 0xdffffc000000000e: 0000 [#1] SMP KASAN PTI
KASAN: null-ptr-deref in range [0x0000000000000070-0x0000000000000077]
CPU: 1 UID: 0 PID: 6882 Comm: syz.5.215 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:ffffc90003b379c0 EFLAGS: 00010202
RAX: 000000000000000e RBX: 0000000000000040 RCX: dffffc0000000000
RDX: ffffc9001be02000 RSI: 00000000000004ea RDI: 00000000000004eb
RBP: 00000000ffffffe2 R08: ffff888077cc68db R09: 1ffff1100ef98d1b
R10: dffffc0000000000 R11: ffffed100ef98d1c R12: 1ffff1100d4c864c
R13: ffffc90003b37e00 R14: 0000000000000070 R15: 0000000000000008
FS: 00007f0bc50016c0(0000) GS:ffff8881234cd000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000001b2f318ff8 CR3: 0000000027730000 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:0x00007f0bc41a94d9
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 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 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f0bc5001028 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 00007f0bc4425fa0 RCX: 00007f0bc41a94d9
RDX: 0000000000101042 RSI: 00002000000002c0 RDI: ffffffffffffff9c
RBP: 00007f0bc423804e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000106 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f0bc4426038 R14: 00007f0bc4425fa0 R15: 00007ffd0fe33908
</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:ffffc90003b379c0 EFLAGS: 00010202
RAX: 000000000000000e RBX: 0000000000000040 RCX: dffffc0000000000
RDX: ffffc9001be02000 RSI: 00000000000004ea RDI: 00000000000004eb
RBP: 00000000ffffffe2 R08: ffff888077cc68db R09: 1ffff1100ef98d1b
R10: dffffc0000000000 R11: ffffed100ef98d1c R12: 1ffff1100d4c864c
R13: ffffc90003b37e00 R14: 0000000000000070 R15: 0000000000000008
FS: 00007f0bc50016c0(0000) GS:ffff8881234cd000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000001b2f318ff8 CR3: 0000000027730000 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.