WARNING in jfs_rmdir (2)

Status: moderation: reported on 2026/11/21 00:54
Subsystems: jfs
Labels: prio:normal
[Documentation on labels]
Reported-by: syzbot+ca606ed5452b9947a34d@syzkaller.appspotmail.com
First crash: 1h55m, last: 1h55m
✨ AI cause bisection: inconclusive (AI job)
✨ AI-generated root cause summary:

When JFS loads an inode from disk in diRead()/copy_from_dinode(), it only checks that di_nlink != 0 and copies di_nlink verbatim without verifying that a directory inode (S_ISDIR) has a valid link count (>= 2 and consistent with child subdirectories). Consequently, on a corrupted JFS image where a parent directory dip has an insufficient on-disk di_nlink (such as 1 while containing subdirectories), removing a subdirectory via jfs_rmdir() (or moving one via jfs_rename()) drops dip->i_nlink to 0 while dip remains live. A subsequent jfs_rmdir() on another child directory unconditionally calls inode_dec_link_count(dip) -> drop_nlink(dip) without checking dip->i_nlink, triggering WARN_ON(inode->i_nlink == 0) at fs/inode.c:408 and underflowing dip->__i_nlink.

▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit d0f871bfb831:

Root Cause Analysis

The warning WARN_ON(inode->i_nlink == 0) at fs/inode.c:408 in drop_nlink() is triggered from jfs_rmdir() (fs/jfs/namei.c:395) when decrementing the link count of the parent directory (dip) whose i_nlink has already reached 0.

Technical Mechanism

  1. Missing directory link-count validation on disk read (fs/jfs/jfs_imap.c):

    • When JFS reads an on-disk struct dinode in diRead() (fs/jfs/jfs_imap.c:380), it only checks le32_to_cpu(dp->di_nlink) == 0 (returning -ESTALE).
    • copy_from_dinode() (fs/jfs/jfs_imap.c:3065) then copies dip->di_nlink directly into the VFS inode via set_nlink(ip, le32_to_cpu(dip->di_nlink)).
    • Neither diRead() nor copy_from_dinode() validates that a directory inode (S_ISDIR(ip->i_mode)) has di_nlink >= 2, nor is di_nlink guaranteed to match the actual number of child subdirectories present in the directory's dtree.
  2. Unchecked inode_dec_link_count(dip) in jfs_rmdir() (fs/jfs/namei.c):

    • In jfs_rmdir(struct inode *dip, struct dentry *dentry) (fs/jfs/namei.c:334-442), after deleting the child directory entry via dtDelete(), line 395 unconditionally executes:
      inode_set_mtime_to_ts(dip, inode_set_ctime_current(dip));
      inode_dec_link_count(dip);
      
    • inode_dec_link_count(dip) (include/linux/fs.h:2276) calls drop_nlink(dip) (fs/inode.c:406-412), which checks WARN_ON(inode->i_nlink == 0) and decrements inode->__i_nlink--.
    • Note that jfs_rename() (fs/jfs/namei.c:1248-1249) similarly calls drop_nlink(old_dir) without checking old_dir->i_nlink when moving or overwriting a subdirectory.

Trigger Sequence & Violated Invariant

  • Invariant violated: A live directory containing k subdirectories must have i_nlink >= 2 + k (accounting for its parent entry, ., and each child directory's .. entry), and drop_nlink() requires inode->i_nlink > 0.
  • How it is triggered: On a corrupted JFS image where a directory dip has an on-disk di_nlink smaller than 2 + k (for example, di_nlink == 1 with two subdirectories, or di_nlink == 2 with two subdirectories):
    1. Removing a first subdirectory via jfs_rmdir() (or moving it out via jfs_rename()) drops dip->i_nlink to 0 while dip remains a live, non-S_DEAD directory in the VFS tree.
    2. Removing a second subdirectory inside dip via unlinkat(..., AT_REMOVEDIR) -> vfs_rmdir() -> jfs_rmdir() reaches inode_dec_link_count(dip) -> drop_nlink(dip) with dip->i_nlink == 0, triggering WARN_ON(inode->i_nlink == 0) at fs/inode.c:408 and wrapping dip->__i_nlink to UINT_MAX.

Relevant Locations

  • fs/jfs/jfs_imap.c: diRead() (line 380), copy_from_dinode() (line 3065) — missing S_ISDIR minimum link-count check (di_nlink >= 2).
  • fs/jfs/namei.c: jfs_rmdir() (line 395) — unconditional inode_dec_link_count(dip) without validating dip->i_nlink > 0 (and jfs_rename() line 1249 similarly calls drop_nlink(old_dir) unchecked).
  • fs/inode.c: drop_nlink() (line 408) — WARN_ON(inode->i_nlink == 0) firing site.
▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
008b561f assessment-security DenialOfService: ✅ Exploitable: ❌ FilesystemTrigger: ✅ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ❌ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ WARNING in jfs_rmdir (2) 2026/11/20 23:53 2026/11/20 23:53 2026/11/21 00:54 60a1d40d
836f9b83 bisect-cause IsRelease: ✅ ❓ WARNING in jfs_rmdir (2) 2026/11/20 23:53 2026/11/20 23:53 2026/11/21 01:10 60a1d40d
▶ ▼ Similar bugs (1)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream WARNING in jfs_rmdir prio:high jfs -1 1 132d 128d 0/29 auto-obsoleted due to no activity on 2026/10/19 15:46

Sample crash report:
------------[ cut here ]------------
inode->i_nlink == 0
WARNING: fs/inode.c:408 at drop_nlink+0xc5/0x110 fs/inode.c:408, CPU#0: syz-executor/5603
Modules linked in:
CPU: 0 UID: 0 PID: 5603 Comm: syz-executor Not tainted syzkaller #0 PREEMPT_{RT,(full)} 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
RIP: 0010:drop_nlink+0xc5/0x110 fs/inode.c:408
Code: 68 09 00 00 be 08 00 00 00 e8 97 2a e9 ff f0 48 ff 83 68 09 00 00 5b 41 5c 41 5e 41 5f 5d e9 92 8b 29 09 cc e8 cc 72 75 ff 90 <0f> 0b 90 eb 81 44 89 f1 80 e1 07 80 c1 03 38 c1 0f 8c 5b ff ff ff
RSP: 0018:ffffc9000529fc30 EFLAGS: 00010293
RAX: ffffffff82528194 RBX: ffff8880678164d0 RCX: ffff88803564ddc0
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: dffffc0000000000 R11: fffffbfff21ab838 R12: 1ffff1100cf02ca3
R13: dffffc0000000000 R14: ffff888067816518 R15: dffffc0000000000
FS:  000055559535d500(0000) GS:ffff888124704000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000555595390ac8 CR3: 00000000414ec000 CR4: 00000000003526f0
Call Trace:
 <TASK>
 inode_dec_link_count include/linux/fs.h:2276 [inline]
 jfs_rmdir+0x416/0x850 fs/jfs/namei.c:395
 vfs_rmdir+0x3e9/0x700 fs/namei.c:5533
 filename_rmdir+0x276/0x510 fs/namei.c:5590
 __do_sys_unlinkat fs/namei.c:5765 [inline]
 __se_sys_unlinkat+0x71/0x1a0 fs/namei.c:5758
 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:0x7ff7bfd68677
Code: 77 01 c3 48 c7 c2 e8 ff ff ff f7 d8 64 89 02 b8 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 b8 07 01 00 00 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:00007fff92aabc68 EFLAGS: 00000207 ORIG_RAX: 0000000000000107
RAX: ffffffffffffffda RBX: 0000000000000065 RCX: 00007ff7bfd68677
RDX: 0000000000000200 RSI: 00007fff92aace10 RDI: 00000000ffffff9c
RBP: 00007ff7bfdf751b R08: 0000000000008580 R09: 0000000000000001
R10: 0000000000000000 R11: 0000000000000207 R12: 00007fff92aace10
R13: 00007ff7bfdf751b R14: 0000000000022252 R15: 00007fff92aaefd0
 </TASK>

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/20 23:53 upstream d0f871bfb831 b2c69459 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs WARNING in jfs_rmdir
* Struck through repros no longer work on HEAD.