mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [BUG] WARNING in kernfs_remove_by_name_ns (fs/kernfs/dir.c:1784, v7.4-rc3)
@ 2026-11-18 12:37 Zheng Zheng
  2026-11-18 13:54 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Zheng Zheng @ 2026-11-18 12:37 UTC (permalink / raw)
  To: dsterba, mason
  Cc: gregkh, tj, linux-btrfs, driver-core, linux-kernel, syzkaller-bugs

Hi David, Chris, Greg, Tejun,

We found a reproducible WARNING in the kernfs/sysfs removal path on
v7.4-rc3 with syzkaller. It is triggered while enabling Btrfs quotas and is
stable on fresh VMs.

The archive and reproducer are here:

  https://github.com/Zheng-zheng-codes/kernfs-remove-by-name-ns-warning
  commit 1d8c9a81d3f812c9ea320afba737bb4be8643ed4

Warning
-------

The warning is preceded by a kobject allocation failure for the Btrfs
`qgroups` sysfs kobject:

  kobject: kobject_add_internal failed for qgroups (error: -12 parent:
d1a4d035-71e5-4764-8138-3b7234c5bdf5)
  ------------[ cut here ]------------
  kernfs: can not remove 'enabled', no directory
  WARNING: fs/kernfs/dir.c:1784 at
kernfs_remove_by_name_ns+0x10b/0x120 fs/kernfs/dir.c:1784, CPU#1:
syz.7.1656/40887
  Modules linked in: crc32c_cryptoapi(E) cifs(E) smbdirect(E)
rdma_cm(E) iw_cm(E) ib_cm(E) nbd(E) ext2(E) smc(E) ib_core(E)
dm_multipath(E)
  CPU: 1 UID: 0 PID: 40887 Comm: syz.7.1656 Tainted: G            EL
   7.4.0-rc3-kernsight-kasan #1 PREEMPT(full)
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1
04/01/2014
  RIP: 0010:kernfs_remove_by_name_ns+0x10e/0x120 fs/kernfs/dir.c:1784
  RSP: 0018:ffa00000064479c0 EFLAGS: 00010293
  Call Trace:
   <TASK>
   kernfs_remove_by_name include/linux/kernfs.h:644 [inline]
   remove_files+0x9b/0x1c0 fs/sysfs/group.c:28
   sysfs_remove_group+0x90/0x1b0 fs/sysfs/group.c:328
   sysfs_remove_groups fs/sysfs/group.c:352 [inline]
   sysfs_remove_groups+0x65/0xb0 fs/sysfs/group.c:344
   __kobject_del+0x89/0x220 lib/kobject.c:595
   kobject_del lib/kobject.c:627 [inline]
   kobject_del+0x40/0x60 lib/kobject.c:619
   btrfs_sysfs_del_qgroups+0x156/0x230 fs/btrfs/sysfs.c:2463
   btrfs_sysfs_add_qgroups+0x1c2/0x230 fs/btrfs/sysfs.c:2502
   btrfs_quota_enable+0x2e7/0x1ce0 fs/btrfs/qgroup.c:1034
   btrfs_ioctl_quota_ctl fs/btrfs/ioctl.c:3605 [inline]
   btrfs_ioctl+0x46d4/0x5e10 fs/btrfs/ioctl.c:5663
   __x64_sys_ioctl+0x194/0x210 fs/ioctl.c:584
   do_syscall_64+0x132/0x7c0 arch/x86/entry/syscall_64.c:89
   entry_SYSCALL_64_after_hwframe+0x77/0x7f
   </TASK>

Important annotations
--------------------

- The first line is the Btrfs qgroups kobject add failure with `-ENOMEM`
  (`error: -12`). This `-ENOMEM` is triggered by the reproducer's `failslab`
  fault injection, not by a real memory shortage. The warning is then emitted
  from the cleanup path trying to remove the `enabled` file from a sysfs group
  that was never fully created.
- The call path is:
  `BTRFS_IOC_QUOTA_CTL` -> `btrfs_quota_enable()` ->
  `btrfs_sysfs_add_qgroups()` -> `btrfs_sysfs_del_qgroups()` ->
  `sysfs_remove_groups()` -> `remove_files()` -> `kernfs_remove_by_name()`.
- `kernfs_remove_by_name_ns()` warns when the target node cannot be found;
  here it cannot find `enabled` under the qgroups directory.
- The warning becomes a panic because the test kernel boots with
  `panic_on_warn=1`. This may be a cleanup-path warning after an injected
  allocation failure rather than memory corruption; we have not confirmed a
  root cause or a fix.
- The warning is user-triggerable through Btrfs quota control, but we are not
  claiming it is a security issue.

How to reproduce
----------------

The recipe reproduces on a fresh, unmodified VM; no state snapshot is needed.

  git clone https://github.com/Zheng-zheng-codes/kernfs-remove-by-name-ns-warning
  cd kernfs-remove-by-name-ns-warning

  # boot the v7.4-rc3 kernel with the supplied config and guest image

  # in the guest, as root:
  syz-execprog -procs=8 -threaded -repeat=0 \
      -executor ./syz-executor reproducer/repro.kernsight.prog

`-repeat=0` repeats until the warning fires; the external runs hit in 43 s
and 45 s. The recipe has 76 entries (75 replay programs followed by the
testcase).

Verification:

- Main Kernsight pipeline: `confirmed=true`, `status=verified`,
  2026-11-18T05:11:34Z, 75 replay programs, fresh-VM 2/2.
- Independent external fresh-VM verification: 2/2, target hit after 43 s and
  45 s; serial logs are in `external-verify/serial-1.log` and
  `external-verify/serial-2.log`.
- C reproducer: not generated; the syzkaller recipe is the primary
  reproducer.

Kernel/guest details:

  kernel: v7.4-rc3, bzImage sha256
    0c16409f8aec508ac44a63e631c2bd352536401f3fd0856df1d839fb953a1882
  guest: Debian trixie x86_64, 6 GiB RAM, 4 vCPU, QEMU/KVM
  boot: oops=panic panic_on_warn=1
  config: CONFIG_KASAN=y, CONFIG_PROVE_LOCKING=y, CONFIG_BTRFS_FS=y

Thanks,
Zheng

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-18 13:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 12:37 [BUG] WARNING in kernfs_remove_by_name_ns (fs/kernfs/dir.c:1784, v7.4-rc3) Zheng Zheng
2026-11-18 13:54 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®