| 0/0 |
2026/11/24 01:09 |
flow |
bisect-cause |
2m
Results: map[BisectReasoning:I could not identify a specific commit that introduced this bug with confidence, so `CandidateCommits` has been left empty (`[]`).
### Root Cause Verification
Inspecting the source tree at commit `f802b6558eb81bd5888d761a0cdc8afe5fd8c941` confirms the findings in the root cause analysis:
1. **Fault location (`lib/rbtree.c:365-366`, `lib/rbtree.c:445`):**
During `cleanup_net` teardown (`unregister_netdevice_many_notify()` -> `netdev_unregister_kobject()` -> `remove_queue_kobjects()` -> `net_rx_queue_update_kobjects()`), `kernfs_unlink_sibling()` (`fs/kernfs/dir.c:449`) calls `rb_erase(&kn->rb, &kn_parent->dir.children)` for `bond0`'s `rx-0` directory (`0x8c5db688`) under `queues` (`0x8c6d03c8`).
In `____rb_erase_color()`, after Case 1 right-rotation sets `sibling->__rb_parent_color` (`r2 = 0x8c5db3d9`) on `sibling` (`r3 = 0x8c5db278`, which is `&sibling_kn->rb` at offset 16 of `struct kernfs_node` `0x8c5db268` in `kernfs_node_cache`, size 88 bytes), `tmp1 = sibling->rb_left` loads `[r3, #8]` (offset 24 of `0x8c5db268`), yielding `r0 = 0x00000021`. `rb_is_black(tmp1)` then faults trying to read `tmp1->__rb_parent_color` (`ldr r2, [r0]`).
2. **Why `0x00000021` cannot come from `rbtree` or `kernfs` logic:**
- In `struct kernfs_node` (`include/linux/kernfs.h:199`) and `struct rb_node`, `rb` starts at offset 16 (128 bits) and `rb_left` is at offset 8 (64 bits) within `rb`, placing `rb.rb_left` at byte offset 24. No other field or union in `struct kernfs_node` overlaps offset 24.
- `lib/rbtree.c` only ever stores `NULL` or a 4-byte-aligned `struct rb_node *` in `rb_left`; color bits (`RB_BLACK == 1`) are only encoded in `__rb_parent_color` (offset 0 of `struct rb_node`).
- All accesses and mutations to `dir.children` and `kn->rb` (`kernfs_link_sibling()`, `kernfs_unlink_sibling()`, `__kernfs_remove()`, `kernfs_rename_ns()`) are serialized by `down_write(&root->kernfs_rwsem)`.
- `sysfs_init()` (`fs/sysfs/mount.c:89`) creates `sysfs_root` without `KERNFS_ROOT_CREATE_DEACTIVATED`, so every sysfs node is activated in `kernfs_add_one()` (`fs/kernfs/dir.c:878-879`) via `kernfs_activate_one()` and is only deactivated (`KN_DEACTIVATED_BIAS`) and unlinked in `__kernfs_remove()` before `kernfs_put()`. A premature `kernfs_put()` freeing `0x8c5db268` while still active and linked in `queues->dir.children` would have triggered `WARN_ONCE(1, "kernfs_put: ... released with incorrect active_ref ...")` (`fs/kernfs/dir.c:604-607`), setting `TAINT_WARN` (`W`), which is not present (`Tainted: [L]=SOFTLOCKUP`).
### Git History Examined and Ruled Out
I inspected recent commits across all subsystems in the call trace to check for newly introduced races, lifetime bugs, or corruption paths:
- **`net/core/net-sysfs.c`:**
- `a9d60b086944` ("net-sysfs: release queue trackers before allowing reuse"): Reorders `netdev_tracker_free()` before `memset(kobj, 0, sizeof(*kobj))` in `rx_queue_release()` / `netdev_queue_release()` with `smp_mb()` barriers. Only affects `struct netdev_rx_queue` / `struct netdev_queue` (`kmalloc-cg-512`), not `kernfs_node_cache` sibling nodes.
- `e3b2cf6e5dba` ("kernfs: pass struct ns_common instead of const void * for namespace tags"): Type-safe conversion from `const void *` to `const struct ns_common *` for namespace tags; does not alter `rb` tree manipulation, locking, or `kernfs_node` lifetime.
- **`fs/kernfs/` and `fs/sysfs/`:**
- `4424f06120fd` ("kernfs: activate a new node without dropping kernfs_rwsem"): Calls `kernfs_activate_one()` while still holding `kernfs_rwsem` write lock in `kernfs_add_one()`. Tightens locking rather than loosening it.
- `8b64f32fee95` ("kernfs: allocate the new name outside kernfs_rwsem") and `09452e5114bd` ("kernfs: free the old name outside kernfs_rwsem"): Move `kstrdup_const()` / `kfree_rcu_mightsleep()` of `kn->name` outside `kernfs_rwsem` in `kernfs_rename_ns()`, without changing `kernfs_unlink_sibling()` / `kernfs_link_sibling()` or `rb` locking.
- `ef179363b043` ("kernfs: avoid READ_ONCE() on a kgid_t in kernfs_new_node()"): No functional change.
- `237557b8a81a` ("sysfs: don't remove existing directory on update failure"): Prevents removing existing directories on `sysfs_update_group()` failure; unrelated to netdev queue teardown.
- **`net/core/dev.c`:**
- `c164a431a646` ("net: wait for in-flight device unregistrations before netns dismantle"): Adds `dev_unreg_pending` wait in `default_device_exit_batch()`.
- `241dec6f9ab7` ("net: stop defer_count outliving the deferred-free list"): Fixes `sdn->defer_count` accounting for skb deferred frees.
### Conclusion
Because `0x8c5db268` is a live `struct kernfs_node` in `queues->dir.children` whose `rb.rb_left` field (offset 24) was corrupted to `0x00000021` by external slab memory corruption (such as a use-after-free from an object in a slab cache merged with the 88-byte `kernfs_node_cache`, an out-of-bounds write from an adjacent slab object on page `0x8c5db000`, or a wild write during the prior workload), the offending writer is not present in the crash trace and cannot be attributed to a specific commit without KASAN/SLUB debug instrumentation or a reproducer. Commits:<nil> IsRelease:false KernelCommit:f802b6558eb81bd5888d761a0cdc8afe5fd8c941]
|
| 1/1 |
2026/11/24 01:09 |
action |
use-crash-commit |
0m
Results: map[KernelCommit:f802b6558eb81bd5888d761a0cdc8afe5fd8c941]
|
| 2/1 |
2026/11/24 01:09 |
action |
syz-repro-to-c-repro |
0m
Results:
|
| 3/1 |
2026/11/24 01:09 |
action |
kernel-checkouter |
0m
Results: map[KernelSrc:/app/workdir/cache/src/6ebb13b200c4a5ae6f9969ff728f01884ea3c327/data]
|
| 4/1 |
2026/11/24 01:09 |
action |
kernel-builder |
0m
Results: map[KernelObj:/app/workdir/cache/build/cac1f711b1eff46feebdc588789eb4e25cd2431d/data]
|
| 5/1 |
2026/11/24 01:09 |
action |
codesearch-prepare |
0m
Results: map[Index:codesearch-index]
|
| 6/1 |
2026/11/24 01:09 |
agent |
cause-finder |
2m
Model:
Results: map[CandidateCommits:<nil>]
Instruction:
You are an experienced Linux kernel developer tasked with identifying the commit
that introduced a kernel bug (cause bisection).
Your investigation strategy:
1. Establish the root cause first.
A root cause analysis of the bug is provided; verify its key claims against the actual
source code before relying on it.
Identify the specific functions, structs, invariants, or lines of code where the buggy
logic resides.
2. Use git tools (git-blame, git-log, git-show) to trace the history
of the affected functions and lines.
3. Trace past pure refactorings, code movements, formatting changes, or variable renames
to find the commit that actually introduced the buggy logic or broke an existing invariant.
4. Do NOT blame commits that merely added debugging or sanitizer checks (WARN_ON, BUG_ON,
KASAN/KMSAN/LOCKDEP annotations) that exposed an older bug, unless the check itself is
incorrect and is the bug.
5. Do NOT return a merge commit unless the bug was introduced by the merge conflict
resolution itself; otherwise identify the underlying non-merge commit.
6. Verify your hypothesis by inspecting the full commit diff with git-show and
confirming how the change introduced the exact condition described in the root cause.
Output rules:
- Returning a SINGLE commit in CandidateCommits (a 1-element list) is the expected norm
and is strongly preferred. A single commit gives maintainers a clear, directly actionable
result, whereas returning extra commits dilutes the report and notifies additional commit
authors unnecessarily.
- Once you identify the primary commit that introduced (or fixed) the bug, return ONLY that
commit in CandidateCommits. Do NOT include secondary or "contributing" commits such as
earlier background/foundation commits, preparatory or follow-up commits in the same
series, later refactorings, incomplete fix attempts, or commits that merely exposed or
enabled the code path (e.g. new callers, default config changes, or sanitizer/debug checks).
Mention those related commits in your text reply for context instead.
- Returning more than one commit (at most 3) is the rare exception, not the norm. Only return
multiple commits when:
1. There is genuine, unresolvable ambiguity between 2-3 equally plausible candidates after
thorough investigation, OR
2. The bug was strictly and inseparably introduced (or fixed) by 2-3 commits together, with
no single primary commit.
In those rare cases, order CandidateCommits by relevance with the most important/likely
commit FIRST.
- If you cannot determine the commit with confidence, return an empty CandidateCommits list
rather than guessing.
- Your text reply must provide a clear bisection log explaining the root cause of the bug,
the git history you traced, the commits you examined (with their hashes and titles), why
you ruled out other commits, and how you reached your conclusion.
Don't make assumptions about the kernel source code (it may be different from what you assume it is).
Extensively use the provided code access tools (codesearch-*, git-*, grepper, etc)
to examine the actual source code, and confirm any assumptions.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
During execution, you may receive periodic guidance in <supervisor_advice> tags;
use it to refine your investigation or wrap up once you have sufficient evidence.
Prompt:
The crash is:
bond0 (unregistering): (slave bond_slave_0): Releasing backup interface
bond0 (unregistering): (slave bond_slave_1): Releasing backup interface
bond0 (unregistering): Released all slaves
8<--- cut here ---
Unable to handle kernel NULL pointer dereference at virtual address 00000021 when read
[00000021] *pgd=80000080004003, *pmd=00000000
Internal error: Oops: 205 [#1] SMP ARM
Modules linked in:
CPU: 1 UID: 0 PID: 14157 Comm: kworker/u8:12 Tainted: G L syzkaller #0 PREEMPT
Tainted: [L]=SOFTLOCKUP
Hardware name: ARM-Versatile Express
Workqueue: netns cleanup_net
PC is at ____rb_erase_color lib/rbtree.c:366 [inline]
PC is at rb_erase+0x168/0x3dc lib/rbtree.c:445
LR is at 0x0
pc : [<81c05e08>] lr : [<00000000>] psr: 20000113
sp : e0379c70 ip : 8c5db3d8 fp : e0379c84
r10: 000000c0 r9 : 8c6d03c8 r8 : 86ef9248
r7 : 83c1d9c0 r6 : 8c6d03c8 r5 : 8c5db698 r4 : 8c5db688
r3 : 8c5db278 r2 : 8c5db3d9 r1 : 8c6d03f4 r0 : 00000021
Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none
Control: 30c5387d Table: 85ee9ac0 DAC: 00000000
Register r0 information: non-paged memory
Register r1 information: slab kernfs_node_cache start 8c6d03c8 pointer offset 44 size 88
Register r2 information: slab kernfs_node_cache start 8c5db3c8 pointer offset 17 size 88
Register r3 information: slab kernfs_node_cache start 8c5db268 pointer offset 16 size 88
Register r4 information: slab kernfs_node_cache start 8c5db688 pointer offset 0 size 88
Register r5 information: slab kernfs_node_cache start 8c5db688 pointer offset 16 size 88
Register r6 information: slab kernfs_node_cache start 8c6d03c8 pointer offset 0 size 88
Register r7 information: slab kmalloc-192 start 83c1d9c0 pointer offset 0 size 192
Register r8 information: slab kmalloc-cg-512 start 86ef9200 pointer offset 72 size 512
Register r9 information: slab kernfs_node_cache start 8c6d03c8 pointer offset 0 size 88
Register r10 information: non-paged memory
Register r11 information: 2-page vmalloc region starting at 0xe0378000 allocated at kernel_clone+0xc4/0x440 kernel/fork.c:2798
Register r12 information: slab kernfs_node_cache start 8c5db3c8 pointer offset 16 size 88
Process kworker/u8:12 (pid: 14157, stack limit = 0xe0378000)
Stack: (0xe0379c70 to 0xe037a000)
9c60: 8c5db688 8c5db698 e0379ca4 e0379c88
9c80: 806b538c 81c05cac 8c5db688 8c5db688 83c1da28 86e3428c e0379ccc e0379ca8
9ca0: 806b6040 806b5304 8c5db688 83c1da00 83c1da28 86e3428c 86ef9248 00000000
9cc0: e0379cec e0379cd0 806b7b08 806b5f30 86ef9248 8c5db688 8707b440 86e3428c
9ce0: e0379d04 e0379cf0 806bb03c 806b7a94 86ef9248 8c5db688 e0379d24 e0379d08
9d00: 81bee248 806baff4 86ef9248 8207fe6c 8707b440 86e3428c e0379d54 e0379d28
9d20: 81bee094 81bee214 00000000 875fb000 e0379d54 ffffffff 86ef9200 00000000
9d40: 875fb000 86ef9248 e0379d9c e0379d58 8175adc0 81bedf58 878b9e40 00000000
9d60: 00000000 81712ed0 e0379da4 00000000 81808c68 875fb000 875fb400 00000002
9d80: 878b9e40 00000000 00000000 81712ed0 e0379dbc e0379da0 8175b160 8175ac14
9da0: 875fb000 e0379e50 00000000 878b9e40 e0379e3c e0379dc0 81713f44 8175b124
9dc0: 00000000 00000000 00000000 00000000 00000000 00000000 835eac40 835eac40
9de0: 00000000 00000000 00000000 85d9e600 8383aa34 838399b4 e0379df8 e0379df8
9e00: 80313ee8 875fb000 00000000 67e59541 81951478 e0379eb0 835ea7cc 835ea7cc
9e20: e0379e88 835ea7cc e0379e50 00000001 e0379e4c e0379e40 817142fc 817137a8
9e40: e0379e8c e0379e50 816f3e94 817142f0 8705810c 875fb10c 00000000 67e59541
9e60: 00000000 83839980 ffffffcc e0379eb0 86fbb028 00000cc0 835ea7b0 86fb9000
9e80: e0379eec e0379e90 816f6538 816f3c8c 81c20eb8 80292300 e0379eec 83839980
9ea0: 86fbb000 81c20e94 00000000 00000000 86fbb028 86fbb028 835ea7a0 67e59541
9ec0: e0379f0c 8d622700 835ea7a0 83c2f200 83c12a00 85d9e600 02000000 83c2f215
9ee0: e0379f4c e0379ef0 80279d64 816f633c 835ea7a4 835ea7a0 8d622730 8d622730
9f00: e0379f34 e0379f10 802759f0 809cbca8 835ea7a0 00000000 00000000 67e59541
9f20: 85d9e600 8d622700 83c12a00 83c12a20 83403d80 85d9e600 8d622730 83c12a00
9f40: e0379f84 e0379f50 8027ad10 80279b78 83403d80 83c12a5c 80283524 8783bb80
9f60: 85d9e600 8027aba4 8d622700 8d2fcf00 e03c9e88 00000000 e0379fac e0379f88
9f80: 80285958 8027abb0 8783bb80 8028583c 00000000 00000000 00000000 00000000
9fa0: 00000000 e0379fb0 80200114 80285848 00000000 00000000 00000000 00000000
9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
9fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000
Call trace:
[<81c05ca0>] (rb_erase) from [<806b538c>] (kernfs_unlink_sibling+0x94/0xa8 fs/kernfs/dir.c:449)
r5:8c5db698 r4:8c5db688
[<806b52f8>] (kernfs_unlink_sibling) from [<806b6040>] (__kernfs_remove.part.0+0x11c/0x230 fs/kernfs/dir.c:1584)
r7:86e3428c r6:83c1da28 r5:8c5db688 r4:8c5db688
[<806b5f24>] (__kernfs_remove.part.0) from [<806b7b08>] (__kernfs_remove fs/kernfs/dir.c:1551 [inline])
[<806b5f24>] (__kernfs_remove.part.0) from [<806b7b08>] (kernfs_remove fs/kernfs/dir.c:1623 [inline])
[<806b5f24>] (__kernfs_remove.part.0) from [<806b7b08>] (kernfs_remove+0x80/0x94 fs/kernfs/dir.c:1612)
r9:00000000 r8:86ef9248 r7:86e3428c r6:83c1da28 r5:83c1da00 r4:8c5db688
[<806b7a88>] (kernfs_remove) from [<806bb03c>] (sysfs_remove_dir+0x54/0x8c fs/sysfs/dir.c:101)
r7:86e3428c r6:8707b440 r5:8c5db688 r4:86ef9248
[<806bafe8>] (sysfs_remove_dir) from [<81bee248>] (__kobject_del+0x40/0xb0 lib/kobject.c:604)
r5:8c5db688 r4:86ef9248
[<81bee208>] (__kobject_del) from [<81bee094>] (kobject_cleanup lib/kobject.c:680 [inline])
[<81bee208>] (__kobject_del) from [<81bee094>] (kobject_release lib/kobject.c:720 [inline])
[<81bee208>] (__kobject_del) from [<81bee094>] (kref_put include/linux/kref.h:65 [inline])
[<81bee208>] (__kobject_del) from [<81bee094>] (kobject_put+0x148/0x258 lib/kobject.c:737)
r7:86e3428c r6:8707b440 r5:8207fe6c r4:86ef9248
[<81bedf4c>] (kobject_put) from [<8175adc0>] (net_rx_queue_update_kobjects+0x1b8/0x280 net/core/net-sysfs.c:1352)
r8:86ef9248 r7:875fb000 r6:00000000 r5:86ef9200 r4:ffffffff
[<8175ac08>] (net_rx_queue_update_kobjects) from [<8175b160>] (remove_queue_kobjects net/core/net-sysfs.c:2189 [inline])
[<8175ac08>] (net_rx_queue_update_kobjects) from [<8175b160>] (netdev_unregister_kobject+0x48/0x104 net/core/net-sysfs.c:2345)
r10:81712ed0 r9:00000000 r8:00000000 r7:878b9e40 r6:00000002 r5:875fb400
r4:875fb000
[<8175b118>] (netdev_unregister_kobject) from [<81713f44>] (unregister_netdevice_many_notify+0x7a8/0xb48 net/core/dev.c:12807)
r7:878b9e40 r6:00000000 r5:e0379e50 r4:875fb000
[<8171379c>] (unregister_netdevice_many_notify) from [<817142fc>] (unregister_netdevice_many+0x18/0x1c net/core/dev.c:12845)
r10:00000001 r9:e0379e50 r8:835ea7cc r7:e0379e88 r6:835ea7cc r5:835ea7cc
r4:e0379eb0
[<817142e4>] (unregister_netdevice_many) from [<816f3e94>] (ops_exit_rtnl_list net/core/net_namespace.c:188 [inline])
[<817142e4>] (unregister_netdevice_many) from [<816f3e94>] (ops_undo_list+0x214/0x238 net/core/net_namespace.c:249)
[<816f3c80>] (ops_undo_list) from [<816f6538>] (cleanup_net+0x208/0x358 net/core/net_namespace.c:713)
r10:86fb9000 r9:835ea7b0 r8:00000cc0 r7:86fbb028 r6:e0379eb0 r5:ffffffcc
r4:83839980
[<816f6330>] (cleanup_net) from [<80279d64>] (process_one_work+0x1f8/0x5cc kernel/workqueue.c:3495)
r10:83c2f215 r9:02000000 r8:85d9e600 r7:83c12a00 r6:83c2f200 r5:835ea7a0
r4:8d622700
[<80279b6c>] (process_one_work) from [<8027ad10>] (process_scheduled_works kernel/workqueue.c:3578 [inline])
[<80279b6c>] (process_one_work) from [<8027ad10>] (worker_thread+0x16c/0x318 kernel/workqueue.c:3659)
r10:83c12a00 r9:8d622730 r8:85d9e600 r7:83403d80 r6:83c12a20 r5:83c12a00
r4:8d622700
[<8027aba4>] (worker_thread) from [<80285958>] (kthread+0x11c/0x154 kernel/kthread.c:436)
r10:00000000 r9:e03c9e88 r8:8d2fcf00 r7:8d622700 r6:8027aba4 r5:85d9e600
r4:8783bb80
[<8028583c>] (kthread) from [<80200114>] (ret_from_fork+0x14/0x20 arch/arm/kernel/entry-common.S:137)
Exception stack(0xe0379fb0 to 0xe0379ff8)
9fa0: 00000000 00000000 00000000 00000000
9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
9fe0: 00000000 00000000 00000000 00000000 00000013 00000000
r9:00000000 r8:00000000 r7:00000000 r6:00000000 r5:8028583c r4:8783bb80
Code: 0a00003b e5930008 e3500000 0a000002 (e5902000)
---[ end trace 0000000000000000 ]---
----------------
Code disassembly (best guess):
0: 0a00003b beq 0xf4
4: e5930008 ldr r0, [r3, #8]
8: e3500000 cmp r0, #0
c: 0a000002 beq 0x1c
* 10: e5902000 ldr r2, [r0] <-- trapping instruction
A previous root cause analysis of this bug (at commit f802b6558eb81bd5888d761a0cdc8afe5fd8c941) concluded:
### Crash Mechanism and Verified State
The crash occurs during asynchronous network namespace teardown in the `netns` workqueue (`cleanup_net()` -> `ops_undo_list()` -> `unregister_netdevice_many()` -> `unregister_netdevice_many_notify()`):
1. After `bond_uninit()` (`drivers/net/bonding/bond_main.c:6071`) releases the slaves of `bond0` (`0x875fb000`), `unregister_netdevice_many_notify()` (`net/core/dev.c:12807`) calls `netdev_unregister_kobject()` (`net/core/net-sysfs.c:2336`) -> `remove_queue_kobjects()` (`net/core/net-sysfs.c:2180`) -> `net_rx_queue_update_kobjects(dev, real_rx, 0)` (`net/core/net-sysfs.c:1325`).
2. For `dev->_rx[0]` (`0x86ef9200`, `kobj` at `0x86ef9248`), `kobject_put(kobj)` triggers `kobject_cleanup()` -> `__kobject_del()` -> `sysfs_remove_dir()` (`fs/sysfs/dir.c:79`) -> `kernfs_remove()` -> `__kernfs_remove()` (`fs/kernfs/dir.c:1536`) -> `kernfs_unlink_sibling()` (`fs/kernfs/dir.c:435`).
3. `kernfs_unlink_sibling()` calls `rb_erase(&kn->rb, &kn_parent->dir.children)` (`fs/kernfs/dir.c:449`) to unlink `bond0`'s `rx-0` directory node (`kn = 0x8c5db688`, `&kn->rb = 0x8c5db698`) from the parent `queues` directory (`kn_parent = 0x8c6d03c8`, `&kn_parent->dir.children = 0x8c6d03f4`).
4. Inside `____rb_erase_color()` (`lib/rbtree.c:353-366`), after Case 1 right-rotation at `parent` (`0x8c5db3d8`, inside `struct kernfs_node` `0x8c5db3c8`):
- `rb_set_parent_color(tmp1, parent, RB_BLACK)` succeeds on `tmp1` (`0x8c5db278`, which is `&sibling_kn->rb` inside `struct kernfs_node` `0x8c5db268` in `kernfs_node_cache`, size 88 bytes), writing `0x8c5db3d9` to `sibling->__rb_parent_color` (offset 16 of `0x8c5db268`).
- At `lib/rbtree.c:365-366` (`tmp1 = sibling->rb_left; if (!tmp1 || rb_is_black(tmp1))`), loading `sibling->rb_left` (`[r3, #8]`, offset 24 of `0x8c5db268`) yields `r0 = 0x00000021`. Dereferencing `tmp1->__rb_parent_color` (`ldr r2, [r0]`) faults at `0x00000021`.
### Invariants Checked and Hypotheses Ruled Out
- **`lib/rbtree.c` corruption:** `rb_left` (offset 8 in `struct rb_node`, offset 24 in `struct kernfs_node`) always stores a 4-byte-aligned `struct rb_node *` or `NULL`; color bits (`RB_BLACK == 1`) are only ever encoded in `__rb_parent_color` (offset 0 in `struct rb_node`, offset 16 in `struct kernfs_node`). Thus `0x00000021` could not be produced by rbtree manipulation logic.
- **`fs/kernfs/dir.c` locking and tree invariants:** Every mutation and traversal of `dir.children` and `kn->rb` (`kernfs_link_sibling()`, `kernfs_unlink_sibling()`, `kernfs_rename_ns()`, `__kernfs_remove()`) is serialized under `down_write(&root->kernfs_rwsem)`. No other field in `struct kernfs_node` (`include/linux/kernfs.h:199`) unions with or aliases offset 24 (`rb.rb_left`).
- **Premature `kernfs_put()` / refcount underflow on `0x8c5db268`:** `sysfs_init()` (`fs/sysfs/mount.c:89`) creates `sysfs_root` without `KERNFS_ROOT_CREATE_DEACTIVATED`, so every sysfs `kernfs_node` is activated immediately in `kernfs_add_one()` (`fs/kernfs/dir.c:878-879`) and only deactivated and unlinked in `__kernfs_remove()`. If `0x8c5db268` had been prematurely freed via `kernfs_put()` (`fs/kernfs/dir.c:587`) while still active and linked in `queues->dir.children`, the check at `fs/kernfs/dir.c:602-608` (`atomic_read(&kn->active) != KN_DEACTIVATED_BIAS`) would have fired `WARN_ONCE(1, "kernfs_put: ... released with incorrect active_ref ...")`, setting `TAINT_WARN` (`W`); however, the report shows `Tainted: G L` (`SOFTLOCKUP` only, no `W`). Moreover, `kernfs_node_cache` (`fs/kernfs/mount.c:472`) has no other runtime `kmem_cache_free()` call sites besides `kernfs_free_rcu()` and the `__kernfs_new_node()` error path (`fs/kernfs/dir.c:728`).
- **`net/core/net-sysfs.c` and `drivers/net/bonding/`:** Queue kobject additions/removals (`net_rx_queue_update_kobjects()`, `netdev_queue_update_kobjects()`, `remove_queue_kobjects()`) are serialized under `rtnl_lock` (and `dev->lock` where applicable). The three nodes observed (`0x8c5db268`, `0x8c5db3c8`, `0x8c5db688`, at offsets `7*88`, `11*88`, `19*88` on slab page `0x8c5db000`) are consistent with live sibling queue `kernfs_node`s belonging to `bond0`.
### Inconclusive Root Cause (External Memory Corruption)
Because `0x8c5db268` was a live `struct kernfs_node` in `queues->dir.children` whose `rb.rb_left` field (offset 24) was overwritten with `0x00000021`, and no local path in `rbtree`, `kernfs`, `sysfs`, `kobject`, `net-sysfs`, or `bonding` writes to offset 24 with an odd/non-pointer value or unlocks `dir.children` races, the crash is a victim of prior external slab memory corruption not captured in the `cleanup_net` trace. Possible mechanisms include:
- A dangling-pointer use-after-free write from an earlier owner of slot `0x8c5db268` in a slab cache merged with `kernfs_node_cache` (created with `sizeof(struct kernfs_node) == 88`, `SLAB_PANIC`, and `CONFIG_SLAB_MERGE_DEFAULT=y`) before `bond0` allocated the node.
- An out-of-bounds write from an adjacent object on page `0x8c5db000` (e.g., `0x8c5db210`), or a wild write during the prior workload (which also triggered `TAINT_SOFTLOCKUP`).
The exact offending allocator/writer cannot be determined from this crash report alone without KASAN/SLUB_DEBUG_ON or a standalone reproducer.
Search for the commit that introduced this bug.
Reply: I could not identify a specific commit that introduced this bug with confidence, so `CandidateCommits` has been left empty (`[]`).
### Root Cause Verification
Inspecting the source tree at commit `f802b6558eb81bd5888d761a0cdc8afe5fd8c941` confirms the findings in the root cause analysis:
1. **Fault location (`lib/rbtree.c:365-366`, `lib/rbtree.c:445`):**
During `cleanup_net` teardown (`unregister_netdevice_many_notify()` -> `netdev_unregister_kobject()` -> `remove_queue_kobjects()` -> `net_rx_queue_update_kobjects()`), `kernfs_unlink_sibling()` (`fs/kernfs/dir.c:449`) calls `rb_erase(&kn->rb, &kn_parent->dir.children)` for `bond0`'s `rx-0` directory (`0x8c5db688`) under `queues` (`0x8c6d03c8`).
In `____rb_erase_color()`, after Case 1 right-rotation sets `sibling->__rb_parent_color` (`r2 = 0x8c5db3d9`) on `sibling` (`r3 = 0x8c5db278`, which is `&sibling_kn->rb` at offset 16 of `struct kernfs_node` `0x8c5db268` in `kernfs_node_cache`, size 88 bytes), `tmp1 = sibling->rb_left` loads `[r3, #8]` (offset 24 of `0x8c5db268`), yielding `r0 = 0x00000021`. `rb_is_black(tmp1)` then faults trying to read `tmp1->__rb_parent_color` (`ldr r2, [r0]`).
2. **Why `0x00000021` cannot come from `rbtree` or `kernfs` logic:**
- In `struct kernfs_node` (`include/linux/kernfs.h:199`) and `struct rb_node`, `rb` starts at offset 16 (128 bits) and `rb_left` is at offset 8 (64 bits) within `rb`, placing `rb.rb_left` at byte offset 24. No other field or union in `struct kernfs_node` overlaps offset 24.
- `lib/rbtree.c` only ever stores `NULL` or a 4-byte-aligned `struct rb_node *` in `rb_left`; color bits (`RB_BLACK == 1`) are only encoded in `__rb_parent_color` (offset 0 of `struct rb_node`).
- All accesses and mutations to `dir.children` and `kn->rb` (`kernfs_link_sibling()`, `kernfs_unlink_sibling()`, `__kernfs_remove()`, `kernfs_rename_ns()`) are serialized by `down_write(&root->kernfs_rwsem)`.
- `sysfs_init()` (`fs/sysfs/mount.c:89`) creates `sysfs_root` without `KERNFS_ROOT_CREATE_DEACTIVATED`, so every sysfs node is activated in `kernfs_add_one()` (`fs/kernfs/dir.c:878-879`) via `kernfs_activate_one()` and is only deactivated (`KN_DEACTIVATED_BIAS`) and unlinked in `__kernfs_remove()` before `kernfs_put()`. A premature `kernfs_put()` freeing `0x8c5db268` while still active and linked in `queues->dir.children` would have triggered `WARN_ONCE(1, "kernfs_put: ... released with incorrect active_ref ...")` (`fs/kernfs/dir.c:604-607`), setting `TAINT_WARN` (`W`), which is not present (`Tainted: [L]=SOFTLOCKUP`).
### Git History Examined and Ruled Out
I inspected recent commits across all subsystems in the call trace to check for newly introduced races, lifetime bugs, or corruption paths:
- **`net/core/net-sysfs.c`:**
- `a9d60b086944` ("net-sysfs: release queue trackers before allowing reuse"): Reorders `netdev_tracker_free()` before `memset(kobj, 0, sizeof(*kobj))` in `rx_queue_release()` / `netdev_queue_release()` with `smp_mb()` barriers. Only affects `struct netdev_rx_queue` / `struct netdev_queue` (`kmalloc-cg-512`), not `kernfs_node_cache` sibling nodes.
- `e3b2cf6e5dba` ("kernfs: pass struct ns_common instead of const void * for namespace tags"): Type-safe conversion from `const void *` to `const struct ns_common *` for namespace tags; does not alter `rb` tree manipulation, locking, or `kernfs_node` lifetime.
- **`fs/kernfs/` and `fs/sysfs/`:**
- `4424f06120fd` ("kernfs: activate a new node without dropping kernfs_rwsem"): Calls `kernfs_activate_one()` while still holding `kernfs_rwsem` write lock in `kernfs_add_one()`. Tightens locking rather than loosening it.
- `8b64f32fee95` ("kernfs: allocate the new name outside kernfs_rwsem") and `09452e5114bd` ("kernfs: free the old name outside kernfs_rwsem"): Move `kstrdup_const()` / `kfree_rcu_mightsleep()` of `kn->name` outside `kernfs_rwsem` in `kernfs_rename_ns()`, without changing `kernfs_unlink_sibling()` / `kernfs_link_sibling()` or `rb` locking.
- `ef179363b043` ("kernfs: avoid READ_ONCE() on a kgid_t in kernfs_new_node()"): No functional change.
- `237557b8a81a` ("sysfs: don't remove existing directory on update failure"): Prevents removing existing directories on `sysfs_update_group()` failure; unrelated to netdev queue teardown.
- **`net/core/dev.c`:**
- `c164a431a646` ("net: wait for in-flight device unregistrations before netns dismantle"): Adds `dev_unreg_pending` wait in `default_device_exit_batch()`.
- `241dec6f9ab7` ("net: stop defer_count outliving the deferred-free list"): Fixes `sdn->defer_count` accounting for skb deferred frees.
### Conclusion
Because `0x8c5db268` is a live `struct kernfs_node` in `queues->dir.children` whose `rb.rb_left` field (offset 24) was corrupted to `0x00000021` by external slab memory corruption (such as a use-after-free from an object in a slab cache merged with the 88-byte `kernfs_node_cache`, an out-of-bounds write from an adjacent slab object on page `0x8c5db000`, or a wild write during the prior workload), the offending writer is not present in the crash trace and cannot be attributed to a specific commit without KASAN/SLUB debug instrumentation or a reproducer.
|
| 7/2 |
2026/11/24 01:09 |
llm |
cause-finder |
0m
Model:
Tokens:
input: 12188
output: 155
thoughts: 193
Thoughts: **My Investigative Process**
My initial step is to meticulously dissect the problem description and the provided root cause analysis. I immediately spot that the analysis labels the root cause as "Inconclusive Root Cause (External Memory Corruption)." This immediately triggers a pause in my thinking. I need to verify this thoroughly. Is it genuinely inconclusive, or is there a specific detail I'm overlooking within the context of `net-sysfs`, `bonding`, `kernfs`, `rbtree`, or perhaps any recent code changes, especially around commit `f802b6558eb81bd5888d761a0cdc8afe5fd8c941`?
To address this, I plan to dive deep into the commit history. I'll begin by examining `f802b6558eb81bd5888d761a0cdc8afe5fd8c941` and other recent commits within the relevant tree. I'll leverage `git-log` and `git-show` for this, and crucially, I will also scrutinize the actual source code referenced in the trace. This detailed code inspection is essential to uncover any subtle clues or dependencies that might have been missed in the initial analysis.
|
| 8/2 |
2026/11/24 01:09 |
tool |
git-show |
0m
Args: map[Commit:f802b6558eb81bd5888d761a0cdc8afe5fd8c941 Stat:true]
Results: map[Output:commit f802b6558eb81bd5888d761a0cdc8afe5fd8c941
Merge: 62b13f41be62 855abf2cf8cd
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date: Sat Nov 21 15:36:04 2026 -0800
Merge tag 'xfs-fixes-7.4-rc4' of git://git.kernel.org:/pub/scm/fs/xfs/xfs-linux
Pull xfs fixes from Carlos Maiolino:
"Mostly this includes fixes for a few races, an ordering problem during
init/teardown of proc/sysfs, missing locks, etc"
* tag 'xfs-fixes-7.4-rc4' of git://git.kernel.org:/pub/scm/fs/xfs/xfs-linux:
xfs: test for realtime and reflink under the pNFS locks
xfs: don't enable DAX on zoned inodes
xfs: restart faults racing with realtime flag changes
xfs: take the MMAPLOCK in xfs_fileattr_set()
xfs: refuse fallocate racing with realtime flag changes
xfs: test for always COW after the dio write checks
xfs: refuse writes to files racing with realtime inode flag changes
xfs: test for reflink after the dio write checks
xfs: properly order xfsstats proc/sysfs init and teardown
xfs: remove unused variable in xrep_tempfile_copyin()
xfs: remove unused variable in xchk_stats_estimate_bufsize()
xfs: fix f_bfree underflow in statfs()
xfs: wait for direct I/O before swapping extents
xfs: break layouts before swapping extents
iomap: don't punch delalloc under a dirty EOF block
xfs: don't change the block map under a dirty folio
xfs: flush the shifted range before changing the file
xfs: don't skip the flush before shifting extents
xfs: always call xfs_update_stable_writes in xfs_ioctl_setattr_xflags
xfs: keep successful near rt allocations
fs/iomap/buffered-io.c | 34 +++++++++++--
fs/xfs/scrub/stats.c | 3 +-
fs/xfs/scrub/tempfile.c | 3 +-
fs/xfs/xfs_bmap_util.c | 30 ++++++++----
fs/xfs/xfs_file.c | 123 ++++++++++++++++++++++++++++++++++++++----------
fs/xfs/xfs_inode.c | 3 +-
fs/xfs/xfs_ioctl.c | 27 ++++++++---
fs/xfs/xfs_iops.c | 4 ++
fs/xfs/xfs_pnfs.c | 32 +++++++------
fs/xfs/xfs_reflink.c | 2 +-
fs/xfs/xfs_rtalloc.c | 6 ++-
fs/xfs/xfs_super.c | 24 +++++-----
12 files changed, 212 insertions(+), 79 deletions(-)
]
|
| 9/2 |
2026/11/24 01:09 |
tool |
git-log |
0m
Error:
Args:
Results:
|
| 10/2 |
2026/11/24 01:09 |
tool |
codesearch-definition-source |
0m
Args: map[Name:kernfs_unlink_sibling]
Results: map[SourceCode: 422: /**
423: * kernfs_unlink_sibling - unlink kernfs_node from sibling rbtree
424: * @kn: kernfs_node of interest
425: *
426: * Try to unlink @kn from its sibling rbtree which starts from
427: * kn->parent->dir.children.
428: *
429: * Return: %true if @kn was actually removed,
430: * %false if @kn wasn't on the rbtree.
431: *
432: * Locking:
433: * kernfs_rwsem held exclusive
434: */
435: static bool kernfs_unlink_sibling(struct kernfs_node *kn)
436: {
437: struct kernfs_node *kn_parent;
438:
439: if (RB_EMPTY_NODE(&kn->rb))
440: return false;
441:
442: kn_parent = kernfs_parent(kn);
443: down_write(&kernfs_root(kn)->kernfs_iattr_rwsem);
444: if (kernfs_type(kn) == KERNFS_DIR)
445: kn_parent->dir.subdirs--;
446: kernfs_inc_rev(kn_parent);
447: up_write(&kernfs_root(kn)->kernfs_iattr_rwsem);
448:
449: rb_erase(&kn->rb, &kn_parent->dir.children);
450: RB_CLEAR_NODE(&kn->rb);
451: return true;
452: }
SourceFile:fs/kernfs/dir.c]
|
| 11/2 |
2026/11/24 01:09 |
tool |
codesearch-definition-source |
0m
Args: map[Name:net_rx_queue_update_kobjects]
Results: map[SourceCode:1324: int
1325: net_rx_queue_update_kobjects(struct net_device *dev, int old_num, int new_num)
1326: {
1327: #ifdef CONFIG_SYSFS
1328: int i;
1329: int error = 0;
1330:
1331: #ifndef CONFIG_RPS
1332: if (!dev->sysfs_rx_queue_group)
1333: return 0;
1334: #endif
1335: for (i = old_num; i < new_num; i++) {
1336: error = rx_queue_add_kobject(dev, i);
1337: if (error) {
1338: new_num = old_num;
1339: break;
1340: }
1341: }
1342:
1343: while (--i >= new_num) {
1344: struct netdev_rx_queue *queue = &dev->_rx[i];
1345: struct kobject *kobj = &queue->kobj;
1346:
1347: if (!check_net(dev_net(dev)))
1348: kobj->uevent_suppress = 1;
1349: if (dev->sysfs_rx_queue_group)
1350: sysfs_remove_group(kobj, dev->sysfs_rx_queue_group);
1351: sysfs_remove_groups(kobj, queue->groups);
1352: kobject_put(kobj);
1353: }
1354:
1355: return error;
1356: #else
1357: return 0;
1358: #endif
1359: }
SourceFile:net/core/net-sysfs.c]
|
| 12/2 |
2026/11/24 01:09 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode:6068: /* Destroy a bonding device.
6069: * Must be under rtnl_lock when this function is called.
6070: */
6071: static void bond_uninit(struct net_device *bond_dev)
6072: {
6073: struct bonding *bond = netdev_priv(bond_dev);
6074: struct list_head *iter;
6075: struct slave *slave;
6076:
6077: bond_netpoll_cleanup(bond_dev);
6078:
6079: /* Release the bonded slaves */
6080: bond_for_each_slave(bond, slave, iter)
6081: __bond_release_one(bond_dev, slave->dev, true, true);
6082: netdev_info(bond_dev, "Released all slaves\n");
6083:
6084: #ifdef CONFIG_XFRM_OFFLOAD
6085: mutex_destroy(&bond->ipsec_lock);
6086: #endif /* CONFIG_XFRM_OFFLOAD */
6087:
6088: bond_set_slave_arr(bond, NULL, NULL);
6089:
6090: list_del_rcu(&bond->bond_list);
6091:
6092: bond_debug_unregister(bond);
6093: }
SourceFile:drivers/net/bonding/bond_main.c]
|
| 13/2 |
2026/11/24 01:09 |
llm |
cause-finder |
0m
Model:
Tokens:
input: 14840
output: 171
thoughts: 221
Thoughts: **Diving Deep into the Network Crash: A Thought Process**
Okay, so I've just encountered a rather perplexing network crash, and my immediate reaction is to meticulously dissect it. My mind immediately jumps to the `net_rx_queue_update_kobjects` function as a potential culprit, and to understand its context, I need to pull in related codebases: `net-sysfs.c`, `net/core/dev.c`, `fs/kernfs/dir.c`, and the `drivers/net/bonding` directory. These all seem to be intricately linked with network device management and the sysfs interface.
A specific detail is nagging at me: a memory address, `0x8c5db268`, that has a value of `0x00000021` at offset 24. This is an oddity, and it strongly suggests a structural misinterpretation or corruption. My immediate hypothesis is that the layout of `struct kernfs_node` is key here. I need to be absolutely sure I understand its precise memory layout, as a deviation from that could easily lead to accessing incorrect data and causing this kind of crash.
Therefore, my next logical steps are to use `codesearch-struct-layout` specifically on `kernfs_node` to get a definitive understanding of its structure. Simultaneously, I'm going to trace the history of changes in the relevant files: `net/core/net-sysfs.c`, `fs/kernfs/` (the entire directory, to be thorough), `net/core/dev.c`, and `drivers/net/bonding/`. Using `git-log` on these paths will allow me to see recent modifications, bug fixes, or refactorings that might have inadvertently introduced this issue or, conversely, provide clues to its resolution. This methodical approach, starting with the immediate evidence and then broadening the scope to related code and its history, is how I'll peel back the layers and uncover the root cause of this network failure.
|
| 14/2 |
2026/11/24 01:09 |
tool |
codesearch-struct-layout |
0m
Args:
Results: map[Fields:[map[Name:count OffsetBits:0 SizeBits:32] map[Name:active OffsetBits:32 SizeBits:32] map[Name:__parent OffsetBits:64 SizeBits:32] map[Name:name OffsetBits:96 SizeBits:32] map[Name:rb OffsetBits:128 SizeBits:96] map[Name:ns OffsetBits:224 SizeBits:32] map[Name:hash OffsetBits:256 SizeBits:32] map[Name:flags OffsetBits:288 SizeBits:16] map[Name:mode OffsetBits:304 SizeBits:16] map[Name: OffsetBits:320 SizeBits:192] map[Name:id OffsetBits:512 SizeBits:64] map[Name:priv OffsetBits:576 SizeBits:32] map[Name:iattr OffsetBits:608 SizeBits:32] map[Name:rcu OffsetBits:640 SizeBits:64]]]
|
| 15/2 |
2026/11/24 01:09 |
tool |
git-log |
0m
Args: map[Count:20 PathPrefix:net/core/net-sysfs.c]
Results: map[Output:24927bdf0f62 net-sysfs: reject a one-entry RPS flow table
4e3b56eb2ed8 net: gro_cells: prevent enabling threaded NAPI on gro_cells
2e65372a2b64 net: Rename dev_isalive() to netif_is_alive().
a9d60b086944 net-sysfs: release queue trackers before allowing reuse
5d074ded6714 net: sysfs: use ops lock for speed and duplex
fc73b71c1bdb net: sysfs: factor out link settings read
0c6c32a8c854 net: add READ_ONCE()/WRITE_ONCE() annotations for dev->num_tc
8e63c9e6179a net: Defer netdev KOBJ_ADD uevent until the device is published
f3c496105472 rtnetlink: use dev_isalive() in rtnl_getlink()
e3b2cf6e5dba kernfs: pass struct ns_common instead of const void * for namespace tags
de69301dc2f6 net-sysfs: switch xps_queue_show() to sysfs_emit()
a435163d3100 net-sysfs: use rps_tag_ptr and remove metadata from rps_dev_flow_table
b2cc61857e3c net-sysfs: remove rcu field from 'struct rps_dev_flow_table'
68b6394a220b net-sysfs: get rid of rps_dev_flow_lock
662ff1aac854 net: Keep ignoring isolated cpuset change
83914de1c1d3 net-sysfs: use check_net()
97bcc5b6f454 net: Prevent RPS table overwrite of active flows
5d4d84618e1a net: s/dev_set_threaded/netif_set_threaded/
af1d017377c1 net: s/dev_get_mac_address/netif_get_mac_address/
ffea11683461 net: s/dev_get_port_parent_id/netif_get_port_parent_id/
]
|
| 16/2 |
2026/11/24 01:09 |
tool |
git-log |
0m
Args: map[Count:20 PathPrefix:fs/kernfs/]
Results: map[Output:ef179363b043 kernfs: avoid READ_ONCE() on a kgid_t in kernfs_new_node()
09452e5114bd kernfs: free the old name outside kernfs_rwsem
8b64f32fee95 kernfs: allocate the new name outside kernfs_rwsem
4424f06120fd kernfs: activate a new node without dropping kernfs_rwsem
2d2a2d7aa987 super: make iterate_supers_type() deletion-safe
e2f0d6d4569d fs: port ->setattr() to pass const mnt_idmap
c3150ded7bc0 fs: port ->getattr() to pass const mnt_idmap
566707035a6e fs: port ->mkdir() to pass const mnt_idmap
8ee61322bb53 fs: port ->rename() to pass const mnt_idmap
16d90b57d843 fs: port xattr to const mnt_idmap
41839e7bd92a fs: port ->permission() to pass const mnt_idmap
341c65579de5 kernfs: don't hold kernfs_rwsem across dir_emit()
45126ed80bb1 kernfs: resume readdir on the full entry key
5ebcb578adee kernfs: don't repeat or skip an entry when readdir resumes
23985e2b1f31 kernfs: don't hold kernfs_rwsem across notification delivery
5ad03af18434 kernfs: allocate the open node outside the open file mutex
81bdc85b4c08 kernfs: fix up the unlocked attribute reads on the creation paths
dc1a0cc95737 kernfs: don't lose IN_DELETE_SELF when decoding a file handle
6034974e3aec kernfs: take kernfs_rename_lock for same-parent renames too
7b15d6cf25e6 kernfs: preserve security xattrs without allocating iattrs
]
|
| 17/2 |
2026/11/24 01:09 |
tool |
git-log |
0m
Args: map[Count:20 PathPrefix:drivers/net/bonding/]
Results: map[Output:297ae1590173 bonding: reject IEEE 802.15.4 and 6LoWPAN devices in bond_enslave
a97809569964 bonding: fix slave_cnt leak on XDP enslave failure
a76ab5e733b4 bonding: fix missing down path on speed/duplex failure after FAIL->UP
9a65b9c2a975 bonding: 3ad: don't set BOND_LINK_FAIL on a slave that is not up
a81513bf5bdf bonding: fix out-of-bounds read of arp_ip_target
9823271dbe1e bonding: 3ad: remove unused TX state
184b5ddf82d4 bonding: fix the program leak when XDP is replaced
00efbbd40bd5 bonding: crypto offload enabled, non-offload slave failover, rekey failed
1746ef2e2df2 bonding: use skb_cow_head() in bond_do_alb_xmit() and rlb_arp_xmit()
af602c7aa5fe bonding: do not clear curr_active_slave prematurely when releasing all slaves
4cef95f72bbd bonding: fix u32 overflow in compute_gap()
e14761563588 bonding: convert unbalanced_load to per-cpu state
70f3995830d3 bonding: alb: fix uninitialized transport header access in alb_determine_nd()
bc93419130bb net: bonding: annotate lockless writes with WRITE_ONCE()
8ccc9bf9afee bonding: initialize err for empty target lists
fd23a7c97317 bonding: fix wrong extack attribute in ARP validate netlink error path
b16bab325801 net: bonding: check register_netdevice_notifier() error in bonding_init()
683c6ba6e58e bonding: alb: re-check primary_is_promisc under RTNL in bond_alb_monitor
1c975de3343c bonding: fix devconf_all NULL dereference when IPv6 is disabled
0e74441edefc net : bonding : Remove TODO comment about retrying setting the MAC
]
|
| 18/2 |
2026/11/24 01:09 |
tool |
codesearch-definition-source |
0m
Args: map[Name:remove_queue_kobjects]
Results: map[SourceCode:2180: static void remove_queue_kobjects(struct net_device *dev)
2181: {
2182: int real_rx = 0, real_tx = 0;
2183:
2184: #ifdef CONFIG_SYSFS
2185: real_rx = dev->real_num_rx_queues;
2186: #endif
2187: real_tx = dev->real_num_tx_queues;
2188:
2189: net_rx_queue_update_kobjects(dev, real_rx, 0);
2190: netdev_queue_update_kobjects(dev, real_tx, 0);
2191:
2192: netdev_lock_ops(dev);
2193: dev->real_num_rx_queues = 0;
2194: dev->real_num_tx_queues = 0;
2195: netdev_unlock_ops(dev);
2196: #ifdef CONFIG_SYSFS
2197: kset_unregister(dev->queues_kset);
2198: #endif
2199: }
SourceFile:net/core/net-sysfs.c]
|
| 19/2 |
2026/11/24 01:09 |
tool |
codesearch-definition-source |
0m
Args: map[Name:netdev_unregister_kobject]
Results: map[SourceCode:2333: /* Delete sysfs entries but hold kobject reference until after all
2334: * netdev references are gone.
2335: */
2336: void netdev_unregister_kobject(struct net_device *ndev)
2337: {
2338: struct device *dev = &ndev->dev;
2339:
2340: if (!check_net(dev_net(ndev)))
2341: dev_set_uevent_suppress(dev, 1);
2342:
2343: kobject_get(&dev->kobj);
2344:
2345: remove_queue_kobjects(ndev);
2346:
2347: pm_runtime_set_memalloc_noio(dev, false);
2348:
2349: device_del(dev);
2350: }
SourceFile:net/core/net-sysfs.c]
|
| 20/2 |
2026/11/24 01:09 |
llm |
cause-finder |
0m
Model:
Tokens:
input: 17800
output: 172
thoughts: 179
Thoughts: **Analysis of Recent Kernel Commits and Their Implications**
My immediate reaction upon encountering the `net/core/net-sysfs.c` commit `a9d60b086944 net-sysfs: release queue trackers before allowing reuse` and the related commits in `fs/kernfs/` (specifically `09452e5114bd`, `8b64f32fee95`, `4424f06120fd`, `ef179363b043`) is that there's a significant architectural change happening, likely related to resource management and object lifecycle within the kernel, particularly concerning network interfaces and their associated sysfs representations.
My instinct is to dive deep into the specifics of *all* these commits. I need to understand precisely what each one is doing. This isn't a superficial overview; I need to trace the exact lines of code that have been added, modified, or removed. To do this effectively, I'll be using `git show` on each of these commit hashes immediately.
Beyond these specific commits, I recognize that changes like these often ripple through other parts of the kernel. Therefore, my next step is to broaden my investigation. I need to perform a thorough `git log` analysis on several key areas:
* **`net/core/dev.c`**: This is the heart of network device handling. Changes in sysfs that affect queue trackers or reuse mechanisms will almost certainly have interactions or dependencies here. I need to see if there are any related code modifications or newly introduced behaviors in how network devices are managed.
* **`lib/rbtree.c`**: The use of red-black trees is common for efficient data management in the kernel. If these commits involve new data structures or modifications to how resources are indexed or accessed, there might be changes in the underlying tree implementations or how they are being used.
* **`lib/kobject.c`**: This library is fundamental to the kernel's object model and the `sysfs` infrastructure. Any changes impacting sysfs object lifecycle, attributes, or population will likely manifest here. I need to check for alterations in how kobjects are created, managed, or destroyed, especially in the context of network-related sysfs entries.
* **`mm/slub.c`**: Given the mention of "queue trackers" and "allowing reuse," memory management is a critical consideration. I need to examine `slub.c` (or potentially other allocators if `slub` isn't the primary focus of the changes) to see if these new resource management strategies have any implications for memory allocation, deallocation patterns, or potential fragmentation.
My goal is to build a comprehensive mental model of how these changes affect the kernel's internal state and observable behavior. By dissecting each commit and then tracing the broader impact across these core subsystems, I can confidently assess the implications for stability, performance, and future development. This is not just about understanding a bug fix or a minor enhancement; it feels like a structural change that requires careful, in-depth scrutiny.
|
| 21/2 |
2026/11/24 01:09 |
tool |
git-show |
0m
Args:
Results: map[Output:commit a9d60b086944155e0e1c2265d739d3455154ab10
Author: Chengfeng Ye <nicoyip.dev@gmail.com>
Date: Thu Oct 1 02:11:06 2026 +0800
net-sysfs: release queue trackers before allowing reuse
An interrupted sysfs_rtnl_lock() can drop the last kobject reference to a
removed TX queue without holding RTNL. netdev_queue_release() clears the
kobject before releasing queue->dev_tracker, allowing the queue to be
re-added while the old release still needs the shared tracker slot:
CPU 0 CPU 1
netdev_queue_release()
memset(kobj, 0, sizeof(*kobj))
netdev_queue_add_kobject()
state_initialized is clear
netdev_hold() installs new tracker
netdev_put() releases the new tracker
With CONFIG_NET_DEV_REFCNT_TRACKER enabled, the old tracker is leaked and
the new lifetime's tracker is released prematurely. A later queue release
then reports a double release. The numeric device references remain
balanced.
The kernel reported:
ref_tracker: reference already released.
ref_tracker: allocated in:
netdev_queue_update_kobjects+0x23d/0x5c0
netif_set_real_num_tx_queues+0x111/0x820
veth_set_channels+0x327/0x930
ethtool_set_channels+0x3ee/0x490
ref_tracker: freed in:
netdev_queue_release+0xbd/0x130
kobject_put+0x1f9/0x280
sysfs_rtnl_lock+0x18b/0x1f0
xps_rxqs_show+0xad/0x250
WARNING: lib/ref_tracker.c:322 at ref_tracker_free+0x49e/0x6d0
Call Trace:
netdev_queue_release+0xbd/0x130
kobject_put+0x1f9/0x280
netdev_queue_update_kobjects+0x3f9/0x5c0
netif_set_real_num_tx_queues+0x111/0x820
veth_set_channels+0x327/0x930
ethtool_set_channels+0x3ee/0x490
RX queues have the same ordering. Their removal and re-addition are
normally serialized by RTNL, but CONFIG_DEBUG_KOBJECT_RELEASE can defer the
release callback to workqueue context and expose the same reuse window.
Release each tracker before clearing its kobject. Pair full memory barriers
on the release and add sides so that an add which observes
state_initialized clear cannot install a new tracker before the old release
has finished accessing the shared tracker slot. Keep the numeric device
reference until after the reset so that the queue storage remains alive
throughout the callback's accesses.
Cc: stable+noautosel@kernel.org # bug in debug instrumentation
Fixes: b0b6fcfa6ad8 ("net-sysfs: remove rtnl_trylock from queue attributes")
Signed-off-by: Chengfeng Ye <nicoyip.dev@gmail.com>
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Reviewed-by: Antoine Tenart <atenart@kernel.org>
Link: https://patch.msgid.link/20260930181106.271547-1-nicoyip.dev@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index fa790e442570..728ff0a68248 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -1170,8 +1170,11 @@ static void rx_queue_release(struct kobject *kobj)
kvfree_rcu_mightsleep(rps_tag_to_table(tag_ptr));
#endif
+ netdev_tracker_free(queue->dev, &queue->dev_tracker);
+ /* Pairs with the smp_mb() in rx_queue_add_kobject(). */
+ smp_mb();
memset(kobj, 0, sizeof(*kobj));
- netdev_put(queue->dev, &queue->dev_tracker);
+ __dev_put(queue->dev);
}
static const struct ns_common *rx_queue_namespace(const struct kobject *kobj)
@@ -1244,6 +1247,9 @@ static int rx_queue_add_kobject(struct net_device *dev, int index)
return -EAGAIN;
}
+ /* Pairs with the smp_mb() in rx_queue_release(). */
+ smp_mb();
+
/* Kobject_put later will trigger rx_queue_release call which
* decreases dev refcount: Take that reference here
*/
@@ -1920,8 +1926,11 @@ static void netdev_queue_release(struct kobject *kobj)
{
struct netdev_queue *queue = to_netdev_queue(kobj);
+ netdev_tracker_free(queue->dev, &queue->dev_tracker);
+ /* Pairs with the smp_mb() in netdev_queue_add_kobject(). */
+ smp_mb();
memset(kobj, 0, sizeof(*kobj));
- netdev_put(queue->dev, &queue->dev_tracker);
+ __dev_put(queue->dev);
}
static const struct ns_common *netdev_queue_namespace(const struct kobject *kobj)
@@ -1981,6 +1990,9 @@ static int netdev_queue_add_kobject(struct net_device *dev, int index)
return -EAGAIN;
}
+ /* Pairs with the smp_mb() in netdev_queue_release(). */
+ smp_mb();
+
/* Kobject_put later will trigger netdev_queue_release call
* which decreases dev refcount: Take that reference here
*/
]
|
| 22/2 |
2026/11/24 01:09 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 4424f06120fda0f63f3d9e9992990d7790d902a4
Author: Shakeel Butt <shakeel.butt@linux.dev>
Date: Sat Sep 12 19:14:51 2026 -0700
kernfs: activate a new node without dropping kernfs_rwsem
kernfs_add_one() links the node in, drops the kernfs_rwsem write lock,
then calls kernfs_activate(), which takes it again. Roots that do not
set KERNFS_ROOT_CREATE_DEACTIVATED, such as sysfs, therefore pay two
write locks for every file, directory and symlink created.
A new node has no children, so kernfs_activate() would walk only that
node. Call kernfs_activate_one() before dropping the lock instead. Its
two WARN_ON_ONCE()s still hold: the node was just linked, and nothing
can have changed its active count yet. This also closes the window
where a node is linked but not yet activated.
lock_stat, creating and destroying five dummy netdevs:
before after
kernfs_rwsem write acquires 1200 830
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Link: https://patch.msgid.link/20260913021453.21507-2-shakeel.butt@linux.dev
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 07abf59f0264..8953e8a07537 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -30,6 +30,8 @@ static char kernfs_pr_cont_buf[PATH_MAX]; /* protected by pr_cont_lock */
#define rb_to_kn(X) rb_entry((X), struct kernfs_node, rb)
+static void kernfs_activate_one(struct kernfs_node *kn);
+
static bool __kernfs_active(struct kernfs_node *kn)
{
return atomic_read(&kn->active) >= 0;
@@ -861,7 +863,6 @@ int kernfs_add_one(struct kernfs_node *kn)
}
up_write(&root->kernfs_iattr_rwsem);
- up_write(&root->kernfs_rwsem);
/*
* Activate the new node unless CREATE_DEACTIVATED is requested.
@@ -869,9 +870,15 @@ int kernfs_add_one(struct kernfs_node *kn)
* activating the node with kernfs_activate(). A node which hasn't
* been activated is not visible to userland and its removal won't
* trigger deactivation.
+ *
+ * @kn has no children yet, so kernfs_activate() would walk only @kn.
+ * Do it here rather than dropping the write lock and taking it again
+ * for every new node.
*/
- if (!(kernfs_root(kn)->flags & KERNFS_ROOT_CREATE_DEACTIVATED))
- kernfs_activate(kn);
+ if (!(root->flags & KERNFS_ROOT_CREATE_DEACTIVATED))
+ kernfs_activate_one(kn);
+
+ up_write(&root->kernfs_rwsem);
return 0;
out_unlock:
]
|
| 23/2 |
2026/11/24 01:09 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 09452e5114bd59ea79e05b5ca4579df898178bfd
Author: Shakeel Butt <shakeel.butt@linux.dev>
Date: Sat Sep 12 19:14:53 2026 -0700
kernfs: free the old name outside kernfs_rwsem
kernfs_rename_ns() frees the replaced name with kfree_rcu_mightsleep()
while still holding the kernfs_rwsem write lock. If the batching
allocation fails, which is what happens under memory pressure,
kvfree_call_rcu() falls back to a full synchronize_rcu() before freeing.
A rename can then wait out a grace period with the write lock held, and
every create, remove and rename in the hierarchy waits with it.
The name is already unpublished by then, so nothing needs the free to
happen under the lock. Move it past the unlock.
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Link: https://patch.msgid.link/20260913021453.21507-4-shakeel.butt@linux.dev
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 3bbdd9a8acc8..41d693114cdc 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -1820,6 +1820,7 @@ int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,
{
struct kernfs_node *old_parent;
const char *dup_name = NULL;
+ const char *put_name = NULL;
struct kernfs_root *root;
const char *old_name;
bool reparent;
@@ -1901,12 +1902,14 @@ int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,
kernfs_link_sibling(kn);
if (new_name && !is_kernel_rodata((unsigned long)old_name))
- kfree_rcu_mightsleep(old_name);
+ put_name = old_name;
error = 0;
out:
up_write(&root->kernfs_rwsem);
kfree_const(dup_name);
+ if (put_name)
+ kfree_rcu_mightsleep(put_name);
return error;
}
]
|
| 24/2 |
2026/11/24 01:09 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 8b64f32fee95a977b137b0dd5050bc68d93f6f60
Author: Shakeel Butt <shakeel.butt@linux.dev>
Date: Sat Sep 12 19:14:52 2026 -0700
kernfs: allocate the new name outside kernfs_rwsem
kernfs_rename_ns() calls kstrdup_const() while holding the kernfs_rwsem
write lock. It is the only GFP_KERNEL allocation under that lock in
kernfs, so a rename can enter reclaim while every create, remove and
rename in the hierarchy waits behind it.
Copy the name before taking the lock and free the copy again if the
rename turns out not to need it. A rename that keeps the name, hits a
collision or finds the node gone now does one extra kstrdup_const();
renames are rare. -ENOMEM is still reported at the same point as
before, so nothing changes about which error a caller sees.
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Link: https://patch.msgid.link/20260913021453.21507-3-shakeel.butt@linux.dev
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 8953e8a07537..3bbdd9a8acc8 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -1819,6 +1819,7 @@ int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,
const char *new_name, const struct ns_common *new_ns)
{
struct kernfs_node *old_parent;
+ const char *dup_name = NULL;
struct kernfs_root *root;
const char *old_name;
bool reparent;
@@ -1828,6 +1829,9 @@ int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,
if (!rcu_access_pointer(kn->__parent))
return -EINVAL;
+ if (new_name)
+ dup_name = kstrdup_const(new_name, GFP_KERNEL);
+
root = kernfs_root(kn);
down_write(&root->kernfs_rwsem);
@@ -1859,9 +1863,10 @@ int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,
/* rename kernfs_node */
if (strcmp(old_name, new_name) != 0) {
error = -ENOMEM;
- new_name = kstrdup_const(new_name, GFP_KERNEL);
- if (!new_name)
+ if (!dup_name)
goto out;
+ new_name = dup_name;
+ dup_name = NULL;
} else {
new_name = NULL;
}
@@ -1901,6 +1906,7 @@ int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,
error = 0;
out:
up_write(&root->kernfs_rwsem);
+ kfree_const(dup_name);
return error;
}
]
|
| 25/2 |
2026/11/24 01:09 |
tool |
git-show |
0m
Args:
Results: map[Output:commit e3b2cf6e5dba416a03152f299d99982dfe1e861d
Author: Christian Brauner <brauner@kernel.org>
Date: Wed Apr 1 12:15:58 2026 +0200
kernfs: pass struct ns_common instead of const void * for namespace tags
kernfs has historically used const void * to pass around namespace tags
used for directory-level namespace filtering. The only current user of
this is sysfs network namespace tagging where struct net pointers are
cast to void *.
Replace all const void * namespace parameters with const struct
ns_common * throughout the kernfs, sysfs, and kobject namespace layers.
This includes the kobj_ns_type_operations callbacks, kobject_namespace(),
and all sysfs/kernfs APIs that accept or return namespace tags.
Passing struct ns_common is needed because various codepaths require
access to the underlying namespace. A struct ns_common can always be
converted back to the concrete namespace type (e.g., struct net) via
container_of() or to_ns_common() in the reverse direction.
This is a preparatory change for switching to ns_id-based directory
iteration to prevent a KASLR pointer leak through the current use of
raw namespace pointers as hash seeds and comparison keys.
Signed-off-by: Christian Brauner <brauner@kernel.org>
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 827fc7adacc7..ffab0a9c8ccb 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -127,7 +127,7 @@ static const struct kobj_type class_ktype = {
};
int class_create_file_ns(const struct class *cls, const struct class_attribute *attr,
- const void *ns)
+ const struct ns_common *ns)
{
struct subsys_private *sp = class_to_subsys(cls);
int error;
@@ -143,7 +143,7 @@ int class_create_file_ns(const struct class *cls, const struct class_attribute *
EXPORT_SYMBOL_GPL(class_create_file_ns);
void class_remove_file_ns(const struct class *cls, const struct class_attribute *attr,
- const void *ns)
+ const struct ns_common *ns)
{
struct subsys_private *sp = class_to_subsys(cls);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 09b98f02f559..0613de0fbe44 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -2570,15 +2570,14 @@ static void device_release(struct kobject *kobj)
kfree(p);
}
-static const void *device_namespace(const struct kobject *kobj)
+static const struct ns_common *device_namespace(const struct kobject *kobj)
{
const struct device *dev = kobj_to_dev(kobj);
- const void *ns = NULL;
if (dev->class && dev->class->namespace)
- ns = dev->class->namespace(dev);
+ return dev->class->namespace(dev);
- return ns;
+ return NULL;
}
static void device_get_ownership(const struct kobject *kobj, kuid_t *uid, kgid_t *gid)
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 558b73940d66..7945614be36d 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -509,12 +509,13 @@ static int ib_device_uevent(const struct device *device,
return 0;
}
-static const void *net_namespace(const struct device *d)
+static const struct ns_common *net_namespace(const struct device *d)
{
const struct ib_core_device *coredev =
container_of(d, struct ib_core_device, dev);
+ struct net *net = read_pnet(&coredev->rdma_net);
- return read_pnet(&coredev->rdma_net);
+ return net ? to_ns_common(net) : NULL;
}
static struct class ib_class = {
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 30339dcabb4d..b58868e1cf11 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -43,6 +43,7 @@
#include <linux/jiffies.h>
#include <linux/lockdep.h>
#include <linux/inet.h>
+#include <net/net_namespace.h>
#include <rdma/ib_cache.h>
#include <linux/atomic.h>
@@ -1048,7 +1049,7 @@ static void srp_remove_target(struct srp_target_port *target)
scsi_remove_host(target->scsi_host);
srp_stop_rport_timers(target->rport);
srp_disconnect_target(target);
- kobj_ns_drop(KOBJ_NS_TYPE_NET, target->net);
+ kobj_ns_drop(KOBJ_NS_TYPE_NET, to_ns_common(target->net));
for (i = 0; i < target->ch_count; i++) {
ch = &target->ch[i];
srp_free_ch_ib(target, ch);
@@ -3713,7 +3714,7 @@ static ssize_t add_target_store(struct device *dev,
target = host_to_target(target_host);
- target->net = kobj_ns_grab_current(KOBJ_NS_TYPE_NET);
+ target->net = to_net_ns(kobj_ns_grab_current(KOBJ_NS_TYPE_NET));
target->io_class = SRP_REV16A_IB_IO_CLASS;
target->scsi_host = target_host;
target->srp_host = host;
@@ -3905,7 +3906,7 @@ static ssize_t add_target_store(struct device *dev,
* earlier in this function.
*/
if (target->state != SRP_TARGET_REMOVED)
- kobj_ns_drop(KOBJ_NS_TYPE_NET, target->net);
+ kobj_ns_drop(KOBJ_NS_TYPE_NET, to_ns_common(target->net));
scsi_host_put(target->scsi_host);
}
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 9a75ad3181ab..eaba44c76a5e 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -808,7 +808,7 @@ int __net_init bond_create_sysfs(struct bond_net *bn)
sysfs_attr_init(&bn->class_attr_bonding_masters.attr);
ret = netdev_class_create_file_ns(&bn->class_attr_bonding_masters,
- bn->net);
+ to_ns_common(bn->net));
/* Permit multiple loads of the module by ignoring failures to
* create the bonding_masters sysfs file. Bonding devices
* created by second or subsequent loads of the module will
@@ -835,7 +835,7 @@ int __net_init bond_create_sysfs(struct bond_net *bn)
/* Remove /sys/class/net/bonding_masters. */
void __net_exit bond_destroy_sysfs(struct bond_net *bn)
{
- netdev_class_remove_file_ns(&bn->class_attr_bonding_masters, bn->net);
+ netdev_class_remove_file_ns(&bn->class_attr_bonding_masters, to_ns_common(bn->net));
}
/* Initialize sysfs for each bond. This sets up and registers
diff --git a/drivers/net/ipvlan/ipvtap.c b/drivers/net/ipvlan/ipvtap.c
index edd13916831a..2d6bbddd1edd 100644
--- a/drivers/net/ipvlan/ipvtap.c
+++ b/drivers/net/ipvlan/ipvtap.c
@@ -30,10 +30,11 @@
static dev_t ipvtap_major;
static struct cdev ipvtap_cdev;
-static const void *ipvtap_net_namespace(const struct device *d)
+static const struct ns_common *ipvtap_net_namespace(const struct device *d)
{
const struct net_device *dev = to_net_dev(d->parent);
- return dev_net(dev);
+
+ return to_ns_common(dev_net(dev));
}
static struct class ipvtap_class = {
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index b391a0f740a3..cc975dfb7380 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -35,10 +35,11 @@ struct macvtap_dev {
*/
static dev_t macvtap_major;
-static const void *macvtap_net_namespace(const struct device *d)
+static const struct ns_common *macvtap_net_namespace(const struct device *d)
{
const struct net_device *dev = to_net_dev(d->parent);
- return dev_net(dev);
+
+ return to_ns_common(dev_net(dev));
}
static struct class macvtap_class = {
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 8d40c4b1db9f..be262145ae08 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -313,7 +313,8 @@ struct kernfs_node *kernfs_get_parent(struct kernfs_node *kn)
*
* Return: 31-bit hash of ns + name (so it fits in an off_t)
*/
-static unsigned int kernfs_name_hash(const char *name, const void *ns)
+static unsigned int kernfs_name_hash(const char *name,
+ const struct ns_common *ns)
{
unsigned long hash = init_name_hash(ns);
unsigned int len = strlen(name);
@@ -330,7 +331,7 @@ static unsigned int kernfs_name_hash(const char *name, const void *ns)
}
static int kernfs_name_compare(unsigned int hash, const char *name,
- const void *ns, const struct kernfs_node *kn)
+ const struct ns_common *ns, const struct kernfs_node *kn)
{
if (hash < kn->hash)
return -1;
@@ -856,7 +857,7 @@ int kernfs_add_one(struct kernfs_node *kn)
*/
static struct kernfs_node *kernfs_find_ns(struct kernfs_node *parent,
const unsigned char *name,
- const void *ns)
+ const struct ns_common *ns)
{
struct rb_node *node = parent->dir.children.rb_node;
bool has_ns = kernfs_ns_enabled(parent);
@@ -889,7 +890,7 @@ static struct kernfs_node *kernfs_find_ns(struct kernfs_node *parent,
static struct kernfs_node *kernfs_walk_ns(struct kernfs_node *parent,
const unsigned char *path,
- const void *ns)
+ const struct ns_common *ns)
{
ssize_t len;
char *p, *name;
@@ -930,7 +931,8 @@ static struct kernfs_node *kernfs_walk_ns(struct kernfs_node *parent,
* Return: pointer to the found kernfs_node on success, %NULL on failure.
*/
struct kernfs_node *kernfs_find_and_get_ns(struct kernfs_node *parent,
- const char *name, const void *ns)
+ const char *name,
+ const struct ns_common *ns)
{
struct kernfs_node *kn;
struct kernfs_root *root = kernfs_root(parent);
@@ -956,7 +958,8 @@ EXPORT_SYMBOL_GPL(kernfs_find_and_get_ns);
* Return: pointer to the found kernfs_node on success, %NULL on failure.
*/
struct kernfs_node *kernfs_walk_and_get_ns(struct kernfs_node *parent,
- const char *path, const void *ns)
+ const char *path,
+ const struct ns_common *ns)
{
struct kernfs_node *kn;
struct kernfs_root *root = kernfs_root(parent);
@@ -1079,7 +1082,8 @@ struct kernfs_node *kernfs_root_to_node(struct kernfs_root *root)
struct kernfs_node *kernfs_create_dir_ns(struct kernfs_node *parent,
const char *name, umode_t mode,
kuid_t uid, kgid_t gid,
- void *priv, const void *ns)
+ void *priv,
+ const struct ns_common *ns)
{
struct kernfs_node *kn;
int rc;
@@ -1221,7 +1225,7 @@ static struct dentry *kernfs_iop_lookup(struct inode *dir,
struct kernfs_node *kn;
struct kernfs_root *root;
struct inode *inode = NULL;
- const void *ns = NULL;
+ const struct ns_common *ns = NULL;
root = kernfs_root(parent);
down_read(&root->kernfs_rwsem);
@@ -1702,7 +1706,7 @@ bool kernfs_remove_self(struct kernfs_node *kn)
* Return: %0 on success, -ENOENT if such entry doesn't exist.
*/
int kernfs_remove_by_name_ns(struct kernfs_node *parent, const char *name,
- const void *ns)
+ const struct ns_common *ns)
{
struct kernfs_node *kn;
struct kernfs_root *root;
@@ -1741,7 +1745,7 @@ int kernfs_remove_by_name_ns(struct kernfs_node *parent, const char *name,
* Return: %0 on success, -errno on failure.
*/
int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,
- const char *new_name, const void *new_ns)
+ const char *new_name, const struct ns_common *new_ns)
{
struct kernfs_node *old_parent;
struct kernfs_root *root;
@@ -1832,7 +1836,7 @@ static int kernfs_dir_fop_release(struct inode *inode, struct file *filp)
return 0;
}
-static struct kernfs_node *kernfs_dir_pos(const void *ns,
+static struct kernfs_node *kernfs_dir_pos(const struct ns_common *ns,
struct kernfs_node *parent, loff_t hash, struct kernfs_node *pos)
{
if (pos) {
@@ -1867,7 +1871,7 @@ static struct kernfs_node *kernfs_dir_pos(const void *ns,
return pos;
}
-static struct kernfs_node *kernfs_dir_next_pos(const void *ns,
+static struct kernfs_node *kernfs_dir_next_pos(const struct ns_common *ns,
struct kernfs_node *parent, ino_t ino, struct kernfs_node *pos)
{
pos = kernfs_dir_pos(ns, parent, ino, pos);
@@ -1889,7 +1893,7 @@ static int kernfs_fop_readdir(struct file *file, struct dir_context *ctx)
struct kernfs_node *parent = kernfs_dentry_node(dentry);
struct kernfs_node *pos = file->private_data;
struct kernfs_root *root;
- const void *ns = NULL;
+ const struct ns_common *ns = NULL;
if (!dir_emit_dots(file, ctx))
return 0;
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
index e32406d62c0d..1163aa769738 100644
--- a/fs/kernfs/file.c
+++ b/fs/kernfs/file.c
@@ -1045,7 +1045,7 @@ struct kernfs_node *__kernfs_create_file(struct kernfs_node *parent,
umode_t mode, kuid_t uid, kgid_t gid,
loff_t size,
const struct kernfs_ops *ops,
- void *priv, const void *ns,
+ void *priv, const struct ns_common *ns,
struct lock_class_key *key)
{
struct kernfs_node *kn;
diff --git a/fs/kernfs/kernfs-internal.h b/fs/kernfs/kernfs-internal.h
index 6061b6f70d2a..b1fd9622a5e3 100644
--- a/fs/kernfs/kernfs-internal.h
+++ b/fs/kernfs/kernfs-internal.h
@@ -97,7 +97,7 @@ struct kernfs_super_info {
* instance. If multiple tags become necessary, make the following
* an array and compare kernfs_node tag against every entry.
*/
- const void *ns;
+ const struct ns_common *ns;
/* anchored at kernfs_root->supers, protected by kernfs_rwsem */
struct list_head node;
diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c
index 048f00b73b71..6e3217b6e481 100644
--- a/fs/kernfs/mount.c
+++ b/fs/kernfs/mount.c
@@ -345,7 +345,7 @@ static int kernfs_set_super(struct super_block *sb, struct fs_context *fc)
*
* Return: the namespace tag associated with kernfs super_block @sb.
*/
-const void *kernfs_super_ns(struct super_block *sb)
+const struct ns_common *kernfs_super_ns(struct super_block *sb)
{
struct kernfs_super_info *info = kernfs_info(sb);
diff --git a/fs/nfs/sysfs.c b/fs/nfs/sysfs.c
index 7d8921f524a6..1da4f707f9ef 100644
--- a/fs/nfs/sysfs.c
+++ b/fs/nfs/sysfs.c
@@ -11,6 +11,7 @@
#include <linux/netdevice.h>
#include <linux/string.h>
#include <linux/nfs_fs.h>
+#include <net/net_namespace.h>
#include <linux/rcupdate.h>
#include <linux/lockd/lockd.h>
@@ -127,9 +128,10 @@ static void nfs_netns_client_release(struct kobject *kobj)
kfree(rcu_dereference_raw(c->identifier));
}
-static const void *nfs_netns_client_namespace(const struct kobject *kobj)
+static const struct ns_common *nfs_netns_client_namespace(const struct kobject *kobj)
{
- return container_of(kobj, struct nfs_netns_client, kobject)->net;
+ return to_ns_common(container_of(kobj, struct nfs_netns_client,
+ kobject)->net);
}
static struct kobj_attribute nfs_netns_client_id = __ATTR(identifier,
@@ -156,9 +158,10 @@ static void nfs_netns_object_release(struct kobject *kobj)
kfree(c);
}
-static const void *nfs_netns_namespace(const struct kobject *kobj)
+static const struct ns_common *nfs_netns_namespace(const struct kobject *kobj)
{
- return container_of(kobj, struct nfs_netns_client, nfs_net_kobj)->net;
+ return to_ns_common(container_of(kobj, struct nfs_netns_client,
+ nfs_net_kobj)->net);
}
static struct kobj_type nfs_netns_object_type = {
@@ -350,9 +353,10 @@ static void nfs_sysfs_sb_release(struct kobject *kobj)
/* no-op: why? see lib/kobject.c kobject_cleanup() */
}
-static const void *nfs_netns_server_namespace(const struct kobject *kobj)
+static const struct ns_common *nfs_netns_server_namespace(const struct kobject *kobj)
{
- return container_of(kobj, struct nfs_server, kobj)->nfs_client->cl_net;
+ return to_ns_common(container_of(kobj, struct nfs_server,
+ kobj)->nfs_client->cl_net);
}
static struct kobj_type nfs_sb_ktype = {
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 94e12efd92f2..ffdcd4153c58 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -37,7 +37,7 @@ void sysfs_warn_dup(struct kernfs_node *parent, const char *name)
* @kobj: object we're creating directory for
* @ns: the namespace tag to use
*/
-int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
+int sysfs_create_dir_ns(struct kobject *kobj, const struct ns_common *ns)
{
struct kernfs_node *parent, *kn;
kuid_t uid;
@@ -103,7 +103,7 @@ void sysfs_remove_dir(struct kobject *kobj)
}
int sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name,
- const void *new_ns)
+ const struct ns_common *new_ns)
{
struct kernfs_node *parent;
int ret;
@@ -115,7 +115,7 @@ int sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name,
}
int sysfs_move_dir_ns(struct kobject *kobj, struct kobject *new_parent_kobj,
- const void *new_ns)
+ const struct ns_common *new_ns)
{
struct kernfs_node *kn = kobj->sd;
struct kernfs_node *new_parent;
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index a8176c875f55..5709cede1d75 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -272,7 +272,7 @@ static const struct kernfs_ops sysfs_bin_kfops_mmap = {
int sysfs_add_file_mode_ns(struct kernfs_node *parent,
const struct attribute *attr, umode_t mode, kuid_t uid,
- kgid_t gid, const void *ns)
+ kgid_t gid, const struct ns_common *ns)
{
struct kobject *kobj = parent->priv;
const struct sysfs_ops *sysfs_ops = kobj->ktype->sysfs_ops;
@@ -322,7 +322,7 @@ int sysfs_add_file_mode_ns(struct kernfs_node *parent,
int sysfs_add_bin_file_mode_ns(struct kernfs_node *parent,
const struct bin_attribute *battr, umode_t mode, size_t size,
- kuid_t uid, kgid_t gid, const void *ns)
+ kuid_t uid, kgid_t gid, const struct ns_common *ns)
{
const struct attribute *attr = &battr->attr;
struct lock_class_key *key = NULL;
@@ -362,7 +362,7 @@ int sysfs_add_bin_file_mode_ns(struct kernfs_node *parent,
* @ns: namespace the new file should belong to
*/
int sysfs_create_file_ns(struct kobject *kobj, const struct attribute *attr,
- const void *ns)
+ const struct ns_common *ns)
{
kuid_t uid;
kgid_t gid;
@@ -505,7 +505,7 @@ EXPORT_SYMBOL_GPL(sysfs_unbreak_active_protection);
* Hash the attribute name and namespace tag and kill the victim.
*/
void sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr,
- const void *ns)
+ const struct ns_common *ns)
{
struct kernfs_node *parent = kobj->sd;
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index e65c60158a04..b199e8ff79b1 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -55,7 +55,7 @@ static const struct fs_context_operations sysfs_fs_context_ops = {
static int sysfs_init_fs_context(struct fs_context *fc)
{
struct kernfs_fs_context *kfc;
- struct net *netns;
+ struct ns_common *ns;
if (!(fc->sb_flags & SB_KERNMOUNT)) {
if (!kobj_ns_current_may_mount(KOBJ_NS_TYPE_NET))
@@ -66,12 +66,14 @@ static int sysfs_init_fs_context(struct fs_context *fc)
if (!kfc)
return -ENOMEM;
- kfc->ns_tag = netns = kobj_ns_grab_current(KOBJ_NS_TYPE_NET);
+ kfc->ns_tag = ns = kobj_ns_grab_current(KOBJ_NS_TYPE_NET);
kfc->root = sysfs_root;
kfc->magic = SYSFS_MAGIC;
fc->fs_private = kfc;
fc->ops = &sysfs_fs_context_ops;
- if (netns) {
+ if (ns) {
+ struct net *netns = to_net_ns(ns);
+
put_user_ns(fc->user_ns);
fc->user_ns = get_user_ns(netns->user_ns);
}
@@ -81,7 +83,7 @@ static int sysfs_init_fs_context(struct fs_context *fc)
static void sysfs_kill_sb(struct super_block *sb)
{
- void *ns = (void *)kernfs_super_ns(sb);
+ struct ns_common *ns = (struct ns_common *)kernfs_super_ns(sb);
kernfs_kill_sb(sb);
kobj_ns_drop(KOBJ_NS_TYPE_NET, ns);
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
index 5603530a1a52..5f9c05fb1394 100644
--- a/fs/sysfs/symlink.c
+++ b/fs/sysfs/symlink.c
@@ -121,7 +121,7 @@ EXPORT_SYMBOL_GPL(sysfs_create_link_nowarn);
void sysfs_delete_link(struct kobject *kobj, struct kobject *targ,
const char *name)
{
- const void *ns = NULL;
+ const struct ns_common *ns = NULL;
/*
* We don't own @target and it may be removed at any time.
@@ -164,10 +164,11 @@ EXPORT_SYMBOL_GPL(sysfs_remove_link);
* A helper function for the common rename symlink idiom.
*/
int sysfs_rename_link_ns(struct kobject *kobj, struct kobject *targ,
- const char *old, const char *new, const void *new_ns)
+ const char *old, const char *new,
+ const struct ns_common *new_ns)
{
struct kernfs_node *parent, *kn = NULL;
- const void *old_ns = NULL;
+ const struct ns_common *old_ns = NULL;
int result;
if (!kobj)
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 8e012f25e1c0..f4583dcafcd1 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -29,10 +29,10 @@ void sysfs_warn_dup(struct kernfs_node *parent, const char *name);
*/
int sysfs_add_file_mode_ns(struct kernfs_node *parent,
const struct attribute *attr, umode_t amode, kuid_t uid,
- kgid_t gid, const void *ns);
+ kgid_t gid, const struct ns_common *ns);
int sysfs_add_bin_file_mode_ns(struct kernfs_node *parent,
const struct bin_attribute *battr, umode_t mode, size_t size,
- kuid_t uid, kgid_t gid, const void *ns);
+ kuid_t uid, kgid_t gid, const struct ns_common *ns);
/*
* symlink.c
diff --git a/include/linux/device/class.h b/include/linux/device/class.h
index 65880e60c720..021da0d61796 100644
--- a/include/linux/device/class.h
+++ b/include/linux/device/class.h
@@ -62,7 +62,7 @@ struct class {
int (*shutdown_pre)(struct device *dev);
const struct kobj_ns_type_operations *ns_type;
- const void *(*namespace)(const struct device *dev);
+ const struct ns_common *(*namespace)(const struct device *dev);
void (*get_ownership)(const struct device *dev, kuid_t *uid, kgid_t *gid);
@@ -180,9 +180,9 @@ struct class_attribute {
struct class_attribute class_attr_##_name = __ATTR_WO(_name)
int __must_check class_create_file_ns(const struct class *class, const struct class_attribute *attr,
- const void *ns);
+ const struct ns_common *ns);
void class_remove_file_ns(const struct class *class, const struct class_attribute *attr,
- const void *ns);
+ const struct ns_common *ns);
static inline int __must_check class_create_file(const struct class *class,
const struct class_attribute *attr)
diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h
index b5a5f32fdfd1..4f0ab88a1b31 100644
--- a/include/linux/kernfs.h
+++ b/include/linux/kernfs.h
@@ -23,6 +23,7 @@
struct file;
struct dentry;
struct iattr;
+struct ns_common;
struct seq_file;
struct vm_area_struct;
struct vm_operations_struct;
@@ -209,7 +210,7 @@ struct kernfs_node {
struct rb_node rb;
- const void *ns; /* namespace tag */
+ const struct ns_common *ns; /* namespace tag */
unsigned int hash; /* ns + name hash */
unsigned short flags;
umode_t mode;
@@ -331,7 +332,7 @@ struct kernfs_ops {
*/
struct kernfs_fs_context {
struct kernfs_root *root; /* Root of the hierarchy being mounted */
- void *ns_tag; /* Namespace tag of the mount (or NULL) */
+ struct ns_common *ns_tag; /* Namespace tag of the mount (or NULL) */
unsigned long magic; /* File system specific magic number */
/* The following are set/used by kernfs_mount() */
@@ -406,9 +407,11 @@ void pr_cont_kernfs_name(struct kernfs_node *kn);
void pr_cont_kernfs_path(struct kernfs_node *kn);
struct kernfs_node *kernfs_get_parent(struct kernfs_node *kn);
struct kernfs_node *kernfs_find_and_get_ns(struct kernfs_node *parent,
- const char *name, const void *ns);
+ const char *name,
+ const struct ns_common *ns);
struct kernfs_node *kernfs_walk_and_get_ns(struct kernfs_node *parent,
- const char *path, const void *ns);
+ const char *path,
+ const struct ns_common *ns);
void kernfs_get(struct kernfs_node *kn);
void kernfs_put(struct kernfs_node *kn);
@@ -426,7 +429,8 @@ unsigned int kernfs_root_flags(struct kernfs_node *kn);
struct kernfs_node *kernfs_create_dir_ns(struct kernfs_node *parent,
const char *name, umode_t mode,
kuid_t uid, kgid_t gid,
- void *priv, const void *ns);
+ void *priv,
+ const struct ns_common *ns);
struct kernfs_node *kernfs_create_empty_dir(struct kernfs_node *parent,
const char *name);
struct kernfs_node *__kernfs_create_file(struct kernfs_node *parent,
@@ -434,7 +438,8 @@ struct kernfs_node *__kernfs_create_file(struct kernfs_node *parent,
kuid_t uid, kgid_t gid,
loff_t size,
const struct kernfs_ops *ops,
- void *priv, const void *ns,
+ void *priv,
+ const struct ns_common *ns,
struct lock_class_key *key);
struct kernfs_node *kernfs_create_link(struct kernfs_node *parent,
const char *name,
@@ -446,9 +451,9 @@ void kernfs_break_active_protection(struct kernfs_node *kn);
void kernfs_unbreak_active_protection(struct kernfs_node *kn);
bool kernfs_remove_self(struct kernfs_node *kn);
int kernfs_remove_by_name_ns(struct kernfs_node *parent, const char *name,
- const void *ns);
+ const struct ns_common *ns);
int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,
- const char *new_name, const void *new_ns);
+ const char *new_name, const struct ns_common *new_ns);
int kernfs_setattr(struct kernfs_node *kn, const struct iattr *iattr);
__poll_t kernfs_generic_poll(struct kernfs_open_file *of,
struct poll_table_struct *pt);
@@ -459,7 +464,7 @@ int kernfs_xattr_get(struct kernfs_node *kn, const char *name,
int kernfs_xattr_set(struct kernfs_node *kn, const char *name,
const void *value, size_t size, int flags);
-const void *kernfs_super_ns(struct super_block *sb);
+const struct ns_common *kernfs_super_ns(struct super_block *sb);
int kernfs_get_tree(struct fs_context *fc);
void kernfs_free_fs_context(struct fs_context *fc);
void kernfs_kill_sb(struct super_block *sb);
@@ -494,11 +499,11 @@ static inline struct kernfs_node *kernfs_get_parent(struct kernfs_node *kn)
static inline struct kernfs_node *
kernfs_find_and_get_ns(struct kernfs_node *parent, const char *name,
- const void *ns)
+ const struct ns_common *ns)
{ return NULL; }
static inline struct kernfs_node *
kernfs_walk_and_get_ns(struct kernfs_node *parent, const char *path,
- const void *ns)
+ const struct ns_common *ns)
{ return NULL; }
static inline void kernfs_get(struct kernfs_node *kn) { }
@@ -526,14 +531,15 @@ static inline unsigned int kernfs_root_flags(struct kernfs_node *kn)
static inline struct kernfs_node *
kernfs_create_dir_ns(struct kernfs_node *parent, const char *name,
umode_t mode, kuid_t uid, kgid_t gid,
- void *priv, const void *ns)
+ void *priv, const struct ns_common *ns)
{ return ERR_PTR(-ENOSYS); }
static inline struct kernfs_node *
__kernfs_create_file(struct kernfs_node *parent, const char *name,
umode_t mode, kuid_t uid, kgid_t gid,
loff_t size, const struct kernfs_ops *ops,
- void *priv, const void *ns, struct lock_class_key *key)
+ void *priv, const struct ns_common *ns,
+ struct lock_class_key *key)
{ return ERR_PTR(-ENOSYS); }
static inline struct kernfs_node *
@@ -549,12 +555,14 @@ static inline bool kernfs_remove_self(struct kernfs_node *kn)
{ return false; }
static inline int kernfs_remove_by_name_ns(struct kernfs_node *kn,
- const char *name, const void *ns)
+ const char *name,
+ const struct ns_common *ns)
{ return -ENOSYS; }
static inline int kernfs_rename_ns(struct kernfs_node *kn,
struct kernfs_node *new_parent,
- const char *new_name, const void *new_ns)
+ const char *new_name,
+ const struct ns_common *new_ns)
{ return -ENOSYS; }
static inline int kernfs_setattr(struct kernfs_node *kn,
@@ -575,7 +583,7 @@ static inline int kernfs_xattr_set(struct kernfs_node *kn, const char *name,
const void *value, size_t size, int flags)
{ return -ENOSYS; }
-static inline const void *kernfs_super_ns(struct super_block *sb)
+static inline const struct ns_common *kernfs_super_ns(struct super_block *sb)
{ return NULL; }
static inline int kernfs_get_tree(struct fs_context *fc)
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index c8219505a79f..bcb5d4e32001 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -109,7 +109,7 @@ struct kobject *kobject_get(struct kobject *kobj);
struct kobject * __must_check kobject_get_unless_zero(struct kobject *kobj);
void kobject_put(struct kobject *kobj);
-const void *kobject_namespace(const struct kobject *kobj);
+const struct ns_common *kobject_namespace(const struct kobject *kobj);
void kobject_get_ownership(const struct kobject *kobj, kuid_t *uid, kgid_t *gid);
char *kobject_get_path(const struct kobject *kobj, gfp_t flag);
@@ -118,7 +118,7 @@ struct kobj_type {
const struct sysfs_ops *sysfs_ops;
const struct attribute_group **default_groups;
const struct kobj_ns_type_operations *(*child_ns_type)(const struct kobject *kobj);
- const void *(*namespace)(const struct kobject *kobj);
+ const struct ns_common *(*namespace)(const struct kobject *kobj);
void (*get_ownership)(const struct kobject *kobj, kuid_t *uid, kgid_t *gid);
};
diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
index 150fe2ae1b6b..4f0990e09b93 100644
--- a/include/linux/kobject_ns.h
+++ b/include/linux/kobject_ns.h
@@ -16,6 +16,7 @@
#ifndef _LINUX_KOBJECT_NS_H
#define _LINUX_KOBJECT_NS_H
+struct ns_common;
struct sock;
struct kobject;
@@ -39,10 +40,10 @@ enum kobj_ns_type {
struct kobj_ns_type_operations {
enum kobj_ns_type type;
bool (*current_may_mount)(void);
- void *(*grab_current_ns)(void);
- const void *(*netlink_ns)(struct sock *sk);
- const void *(*initial_ns)(void);
- void (*drop_ns)(void *);
+ struct ns_common *(*grab_current_ns)(void);
+ const struct ns_common *(*netlink_ns)(struct sock *sk);
+ const struct ns_common *(*initial_ns)(void);
+ void (*drop_ns)(struct ns_common *);
};
int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
@@ -51,7 +52,7 @@ const struct kobj_ns_type_operations *kobj_child_ns_ops(const struct kobject *pa
const struct kobj_ns_type_operations *kobj_ns_ops(const struct kobject *kobj);
bool kobj_ns_current_may_mount(enum kobj_ns_type type);
-void *kobj_ns_grab_current(enum kobj_ns_type type);
-void kobj_ns_drop(enum kobj_ns_type type, void *ns);
+struct ns_common *kobj_ns_grab_current(enum kobj_ns_type type);
+void kobj_ns_drop(enum kobj_ns_type type, struct ns_common *ns);
#endif /* _LINUX_KOBJECT_NS_H */
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 7ca01eb3f7d2..85c20bdd36fb 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -5339,9 +5339,9 @@ static inline netdev_tx_t netdev_start_xmit(struct sk_buff *skb, struct net_devi
}
int netdev_class_create_file_ns(const struct class_attribute *class_attr,
- const void *ns);
+ const struct ns_common *ns);
void netdev_class_remove_file_ns(const struct class_attribute *class_attr,
- const void *ns);
+ const struct ns_common *ns);
extern const struct kobj_ns_type_operations net_ns_type_operations;
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 99b775f3ff46..468259fb6049 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -396,13 +396,13 @@ struct sysfs_ops {
#ifdef CONFIG_SYSFS
-int __must_check sysfs_create_dir_ns(struct kobject *kobj, const void *ns);
+int __must_check sysfs_create_dir_ns(struct kobject *kobj, const struct ns_common *ns);
void sysfs_remove_dir(struct kobject *kobj);
int __must_check sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name,
- const void *new_ns);
+ const struct ns_common *new_ns);
int __must_check sysfs_move_dir_ns(struct kobject *kobj,
struct kobject *new_parent_kobj,
- const void *new_ns);
+ const struct ns_common *new_ns);
int __must_check sysfs_create_mount_point(struct kobject *parent_kobj,
const char *name);
void sysfs_remove_mount_point(struct kobject *parent_kobj,
@@ -410,7 +410,7 @@ void sysfs_remove_mount_point(struct kobject *parent_kobj,
int __must_check sysfs_create_file_ns(struct kobject *kobj,
const struct attribute *attr,
- const void *ns);
+ const struct ns_common *ns);
int __must_check sysfs_create_files(struct kobject *kobj,
const struct attribute * const *attr);
int __must_check sysfs_chmod_file(struct kobject *kobj,
@@ -419,7 +419,7 @@ struct kernfs_node *sysfs_break_active_protection(struct kobject *kobj,
const struct attribute *attr);
void sysfs_unbreak_active_protection(struct kernfs_node *kn);
void sysfs_remove_file_ns(struct kobject *kobj, const struct attribute *attr,
- const void *ns);
+ const struct ns_common *ns);
bool sysfs_remove_file_self(struct kobject *kobj, const struct attribute *attr);
void sysfs_remove_files(struct kobject *kobj, const struct attribute * const *attr);
@@ -437,7 +437,7 @@ void sysfs_remove_link(struct kobject *kobj, const char *name);
int sysfs_rename_link_ns(struct kobject *kobj, struct kobject *target,
const char *old_name, const char *new_name,
- const void *new_ns);
+ const struct ns_common *new_ns);
void sysfs_delete_link(struct kobject *dir, struct kobject *targ,
const char *name);
@@ -502,7 +502,7 @@ ssize_t sysfs_bin_attr_simple_read(struct file *file, struct kobject *kobj,
#else /* CONFIG_SYSFS */
-static inline int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
+static inline int sysfs_create_dir_ns(struct kobject *kobj, const struct ns_common *ns)
{
return 0;
}
@@ -512,14 +512,14 @@ static inline void sysfs_remove_dir(struct kobject *kobj)
}
static inline int sysfs_rename_dir_ns(struct kobject *kobj,
- const char *new_name, const void *new_ns)
+ const char *new_name, const struct ns_common *new_ns)
{
return 0;
}
static inline int sysfs_move_dir_ns(struct kobject *kobj,
struct kobject *new_parent_kobj,
- const void *new_ns)
+ const struct ns_common *new_ns)
{
return 0;
}
@@ -537,7 +537,7 @@ static inline void sysfs_remove_mount_point(struct kobject *parent_kobj,
static inline int sysfs_create_file_ns(struct kobject *kobj,
const struct attribute *attr,
- const void *ns)
+ const struct ns_common *ns)
{
return 0;
}
@@ -567,7 +567,7 @@ static inline void sysfs_unbreak_active_protection(struct kernfs_node *kn)
static inline void sysfs_remove_file_ns(struct kobject *kobj,
const struct attribute *attr,
- const void *ns)
+ const struct ns_common *ns)
{
}
@@ -612,7 +612,7 @@ static inline void sysfs_remove_link(struct kobject *kobj, const char *name)
static inline int sysfs_rename_link_ns(struct kobject *k, struct kobject *t,
const char *old_name,
- const char *new_name, const void *ns)
+ const char *new_name, const struct ns_common *ns)
{
return 0;
}
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index d7bec49ee9ea..80de5e98a66d 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -264,14 +264,14 @@ void ipx_unregister_sysctl(void);
#define ipx_unregister_sysctl()
#endif
-#ifdef CONFIG_NET_NS
-void __put_net(struct net *net);
-
static inline struct net *to_net_ns(struct ns_common *ns)
{
return container_of(ns, struct net, ns);
}
+#ifdef CONFIG_NET_NS
+void __put_net(struct net *net);
+
/* Try using get_net_track() instead */
static inline struct net *get_net(struct net *net)
{
@@ -309,7 +309,7 @@ static inline int check_net(const struct net *net)
return ns_ref_read(net) != 0;
}
-void net_drop_ns(void *);
+void net_drop_ns(struct ns_common *);
void net_passive_dec(struct net *net);
#else
diff --git a/lib/kobject.c b/lib/kobject.c
index cfdb2c3f20a2..9c9ff0f5175f 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -27,7 +27,7 @@
* and thus @kobj should have a namespace tag associated with it. Returns
* %NULL otherwise.
*/
-const void *kobject_namespace(const struct kobject *kobj)
+const struct ns_common *kobject_namespace(const struct kobject *kobj)
{
const struct kobj_ns_type_operations *ns_ops = kobj_ns_ops(kobj);
@@ -1083,9 +1083,9 @@ bool kobj_ns_current_may_mount(enum kobj_ns_type type)
return may_mount;
}
-void *kobj_ns_grab_current(enum kobj_ns_type type)
+struct ns_common *kobj_ns_grab_current(enum kobj_ns_type type)
{
- void *ns = NULL;
+ struct ns_common *ns = NULL;
spin_lock(&kobj_ns_type_lock);
if (kobj_ns_type_is_valid(type) && kobj_ns_ops_tbl[type])
@@ -1096,7 +1096,7 @@ void *kobj_ns_grab_current(enum kobj_ns_type type)
}
EXPORT_SYMBOL_GPL(kobj_ns_grab_current);
-void kobj_ns_drop(enum kobj_ns_type type, void *ns)
+void kobj_ns_drop(enum kobj_ns_type type, struct ns_common *ns)
{
spin_lock(&kobj_ns_type_lock);
if (kobj_ns_type_is_valid(type) &&
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 871941c9830c..ddbc4d7482d2 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -238,7 +238,7 @@ static int kobj_usermode_filter(struct kobject *kobj)
ops = kobj_ns_ops(kobj);
if (ops) {
- const void *init_ns, *ns;
+ const struct ns_common *init_ns, *ns;
ns = kobj->ktype->namespace(kobj);
init_ns = ops->initial_ns();
@@ -388,7 +388,7 @@ static int kobject_uevent_net_broadcast(struct kobject *kobj,
#ifdef CONFIG_NET
const struct kobj_ns_type_operations *ops;
- const struct net *net = NULL;
+ const struct ns_common *ns = NULL;
ops = kobj_ns_ops(kobj);
if (!ops && kobj->kset) {
@@ -404,14 +404,17 @@ static int kobject_uevent_net_broadcast(struct kobject *kobj,
*/
if (ops && ops->netlink_ns && kobj->ktype->namespace)
if (ops->type == KOBJ_NS_TYPE_NET)
- net = kobj->ktype->namespace(kobj);
+ ns = kobj->ktype->namespace(kobj);
- if (!net)
+ if (!ns)
ret = uevent_net_broadcast_untagged(env, action_string,
devpath);
[Output truncated: showing 1000 of 1221 lines]]
|
| 26/2 |
2026/11/24 01:09 |
tool |
git-log |
0m
Args: map[Count:20 PathPrefix:net/core/dev.c]
Results: map[Output:b10c986f1769 net: prevent receive header offset overflow during decapsulation
fdca4b030c78 net: Segment CHECKSUM_UNNECESSARY GSO skbs other than fraglist
c164a431a646 net: wait for in-flight device unregistrations before netns dismantle
35d2d6e5ac0d net: reject a negative TCP header offset in qdisc_pkt_len_segs_init()
241dec6f9ab7 net: stop defer_count outliving the deferred-free list
8dc87fc5d6a0 net: Use a dedicated flag to track disabled napi instances
695e1408eb90 net: use eth_type_trans_careful() in __dev_forward_skb2()
d6f81fd6abe2 net: sched: prevent scheduling deactivated qdiscs
d3ff07f5acc5 net: limit priority VLAN untag depth
6d5a2cb0b7d6 net: xps: bound the cleanup loop by the old map's num_tc
c6648c9f3b51 net: harden qdisc_pkt_len_segs_init() against malicious GSO packets
9fd93893b6fa net: phy: phy_link_topology: Track ports in phy_link_topology
32bfd220cd6f net: core: re-segment oversized TCP GSO skbs
0bba48256b0a net: core: factor out the GSO device limit check
cc9dcb0e7a42 net: core: use the packet's L3 protocol for the GSO size limit
f12d2907992d ipv6: Batch rt6_uncached_list_flush_dev() in netdev_run_todo().
ca6854799069 ipv4: Batch rt_flush_dev() in netdev_run_todo().
810a662abcd5 net: reject a netdev that implements only one hwtstamp NDO
05fe748456ea net: reject ops-locked drivers without ndo_set_rx_mode_async
57f66330c6bb net: move the netdev_ops checks into a helper
]
|
| 27/2 |
2026/11/24 01:09 |
llm |
cause-finder |
0m
Model:
Tokens:
input: 37754
output: 130
thoughts: 1905
Thoughts: **My Brain's Dive into the Crash: A Detailed Retrospective**
Okay, hold on a second. Before I jump to any conclusions, I *really* need to scrutinize these crash registers and the stack trace, line by painstaking line. Let's re-read this crash report with the utmost care.
Looking at the registers:
* `r0` is pointing to non-paged memory. Standard stuff.
* `r1`, `r2`, `r3`, `r4`, `r5`, `r6`, `r9` are all referencing `kernfs_node_cache` objects, each of size 88 bytes. The pointers and offsets are varied, indicating different nodes within this cache.
* `r7` is pointing to a `kmalloc-192` allocation.
* `r8` is referencing a `kmalloc-cg-512` allocation.
Now, the real alarm bells start ringing with `kernfs_node_cache` and its size of 88 bytes. I'm recalling the `kernfs_node` structure. Offset 16 within that structure is the `rb` field, which contains `__rb_parent_color`, `rb_right`, and `rb_left`. Specifically, `rb.rb_left` is at offset 24. And then I see it: `0x00000021`, which is 33. *Why* would offset 24 of an 88-byte `kernfs_node` object hold the value `0x00000021`? This is highly unusual.
Let's break down the `kernfs_node` structure I'm working with:
* Offset 0 (4 bytes): `count` (atomic_t)
* Offset 4 (4 bytes): `active` (atomic_t)
* Offset 8 (4 bytes): `__parent`
* Offset 12 (4 bytes): `name`
* Offset 16 (12 bytes): `rb` (containing `__rb_parent_color` at 16, `rb_right` at 20, and `rb_left` at 24)
* Offset 28 (4 bytes): `ns`
* Offset 32 (4 bytes): `hash`
* Offset 36 (2 bytes): `flags`
* Offset 38 (2 bytes): `mode`
* Offset 40 (24 bytes): union (e.g., `dir`, `symlink`, `attr`)
* Offset 64 (8 bytes): `id`
* Offset 72 (4 bytes): `priv`
* Offset 76 (4 bytes): `iattr`
* Offset 80 (8 bytes): `rcu`
Then I'm looking at the address `0x8c5db268`. What's significant about it in relation to the other addresses?
* `0x8c6d03c8` is associated with the `queues` directory, specifically its parent (`kn_parent`).
* `0x8c5db688` is identified as an `rx-0` node (`kn`), found at offset `0x688` within a page starting at `0x8c5db000`. This offset `0x688` translates to `1672`, which is `19 * 88`.
* `0x8c5db3c8` is identified as a `parent` node, at offset `0x3c8` (`968`, or `11 * 88`).
* And `0x8c5db268`, the one that's got `0x00000021` in its `rb.rb_left`, is identified as a `sibling` node, at offset `0x268` (`616`, or `7 * 88`).
This brings me to `dev->_rx`. I'm thinking about the function `net_rx_queue_update_kobjects(dev, real_rx, 0)`. This function is responsible for removing RX queues. The crucial part is that it removes them in descending order, from `real_rx - 1` down to `0`.
Now, let's consider the state. `r8` is a `kmalloc-cg-512` allocation at `0x86ef9200` with an offset of 72. The fact that `rx-0` (at `0x8c5db688`) is *being removed* in this context is a red flag. If `rx-0` is being removed, and the loop counts down, then `rx-1`, `rx-2`, and so on (if `real_rx` was greater than 1) would have *already been removed* before `rx-0` was processed.
So, if `rx-0` is still present in the tree, attached to its `parent` (`0x8c5db3c8`) and its `sibling` (`0x8c5db268`), what else is in the `queues` directory (`0x8c6d03c8`)?
This is where it gets tricky. I'm recalling the order of operations in `remove_queue_kobjects`: it removes RX queues *first*, and *then* TX queues. So, at the point when `rx-0` is being dealt with, *all* the TX queues (`tx-0`, `tx-1`, ..., `tx-15` -- assuming default bonding configuration of 16 TX queues) are *still present* in `queues->dir.children`.
This leads me to a critical juncture: Is `0x8c5db268` (the `sibling` node) actually a `tx-*` queue? Or has it been freed and then re-used (a Use-After-Free scenario)? Or perhaps corrupted in some other way?
The RCA stated: "Because `0x8c5db268` was a live `struct kernfs_node` in `queues->dir.children` whose `rb.rb_left` field (offset 24) was overwritten with `0x00000021`..." This is the core of the problem.
The question is: *Why* was `rb.rb_left` overwritten? Does `kernfs`, the `rbtree` implementation, `net-sysfs`, `bonding`, or any other component involved have a known bug that would corrupt offset 24 of a `kernfs_node`, or lead to a UAF, or a use of a freed `kernfs_node`, or general corruption?
Or, could `0x00000021` originate from *another* slab object within a merged cache (remember, our `kernfs_node_cache` is 88 bytes, which could be merged with other objects of similar size)? Could it be from a `kernfs_node` UAF, an out-of-bounds write, or an uninitialized field somewhere in `fs/kernfs/`, `drivers/net/bonding/`, `net/`, or `mm/`?
I absolutely must not jump to conclusions here. My next steps have to be methodical. I need to investigate two primary avenues:
1. **Code Auditing:** Is there a bug in `kernfs`, `sysfs`, `net-sysfs`, `bonding`, `net/core/dev.c`, or `lib/rbtree.c` that could lead to this kind of corruption or UAF?
2. **Change Analysis:** What commits were recently introduced in `fs/kernfs/`, `net/core/`, `drivers/net/bonding/`, `mm/`, `fs/`, and related areas *before* the problematic commit `f802b6558eb81bd5888d761a0cdc8afe5fd8c941`?
For the second point, I'll be using `git log`. I'll likely need to use `PathPrefix=""` or specify a broad date range like `"Since: 1 month"` or `"Since: 3 months"`. If I need to be more precise, I can use `MessageRegexps: [".*"]` with a count, say `Count: 30`, to get recent commits. I'll also be specifically examining `fs/kernfs/dir.c`, looking at functions like `kernfs_rename_ns`, `kernfs_add_one`, `__kernfs_remove`, and `kernfs_put` for any suspicious logic.
|
| 28/2 |
2026/11/24 01:09 |
tool |
git-log |
0m
Args: map[Count:40 MessageRegexps:[.]]
Results: map[Output:bd6d2f87c223 KVM: PPC: Fix TOCTOU kernel stack disclosure via kvm_run->mmio.len
0e3d5c040826 KVM: PPC: Book3S HV: Use u8 to store guest's interrupt priorities
56ce4ed6316c tracing: Ignore .function on the function trace event
39bc1fdbce1e tracing: Add notrace to event functions that hook to ftrace
abf7185109d3 ring-buffer: Do not check si_mem_available() before deferred init completes
761a77e09577 tracing: Do not allow user events to add a system name
2891516d90b4 tracing: Take trace_access_lock() in tracing_buffers_ioctl()
a15260001084 tracing: Add tests for globbing number-based strings
4d0d96187340 tracing: Properly match strings that start with numbers
210bc23d4708 tracing/hwlat: Do the latency calculations in nanoseconds
1382c57e40b3 ring-buffer: Increment pages_read on remote ring buffer page swap
d1a4551c99aa ring-buffer: Order remote page commit with data and timestamp
27d44f1c5809 ring-buffer: Check remote reader page commit before meta entries
2a6d7231c79e ring-buffer: Skip remote reader page swap when on tail
65f42f1fa038 fgraph: Do not mark index 0 in every shadow stack frame
c62206dfe9c8 tracing: Validate user addresses in faultable buffer copies
2b237dc23a39 tracing: Wait for marker writers when copy_trace_marker is cleared
0fbdc293697a tracing/user_events: Don't free an event that a dynamic event still references
5f8554105545 tracing/osnoise: Don't start a kthread in timerlat user-space mode
d03e7f74c471 fgraph: Read the task->ret_stack with a smp_load_acquire()
7ea88e9d57e9 fgraph: Use scoped_guard() for the task list walk
700e5c063fd7 fgraph: Allocate shadow stacks inline with GFP_NOWAIT
a20691808762 tracing: Free tracer resources on instance creation failure
5d4eeee1697e tracing/filters: Fix false success return in process_system_preds()
42647658bdd8 tracing/filters: Check for missing operand after operator in parse_pred()
87e0a196153e tracing/filters: Handle out-of-range CPU for OP_NE in cpumask comparison
b82178ad9e28 tracing/filters: Fix MATCH_END_ONLY regex matching for fixed-size strings
cae7fb0d853e tracing: Avoid undefined shifts for zero histogram map size
2b3bed9617bb tracing: Drop the synthetic event ref when clearing hist triggers
3432b3d1f517 tracing: Define common event fields before enabling boot events
97adb02064c6 tracing/filters: Treat zero-length dynamic strings as empty
9eb7e9068b26 tracing: Restrict perf filters that read kernel strings
09ee6ce0a949 tracing: Keep copying markers when one instance is stopped
fb5289b697c9 zonefs: ignore RLIMIT_FSIZE above LLONG_MAX in zonefs_write_check_limits()
7f7b822d09c5 fuse: limit name size in listxattr
d9013d15b937 fuse: clear the old EOF tail before writeback-cache writes
71b2cafb76c6 fuse: fix UBSAN warning in fuse_iomap_writeback_range()
31678e68f826 gpio: shared-proxy: propagate -ENOTSUPP from .set_config()
54efc2e1e9af KVM: PPC: BookE: Use vcpu_err() instead of printk() in kvmppc_dump_vcpu()
ba4564fc66ae powerpc32/bpf: return false from bpf_jit_supports_fsession() on ppc32
]
|
| 29/2 |
2026/11/24 01:09 |
tool |
codesearch-definition-source |
0m
Args: map[Name:__kernfs_remove]
Results: map[SourceCode:1536: static void __kernfs_remove(struct kernfs_node *kn)
1537: {
1538: struct kernfs_node *pos, *parent;
1539:
1540: /* Short-circuit if non-root @kn has already finished removal. */
1541: if (!kn)
1542: return;
1543:
1544: lockdep_assert_held_read(&kernfs_root(kn)->kernfs_supers_rwsem);
1545: lockdep_assert_held_write(&kernfs_root(kn)->kernfs_rwsem);
1546:
1547: /*
1548: * This is for kernfs_remove_self() which plays with active ref
1549: * after removal.
1550: */
1551: if (kernfs_parent(kn) && RB_EMPTY_NODE(&kn->rb))
1552: return;
1553:
1554: pr_debug("kernfs %s: removing\n", kernfs_rcu_name(kn));
1555:
1556: /* prevent new usage by marking all nodes removing and deactivating */
1557: down_write(&kernfs_root(kn)->kernfs_iattr_rwsem);
1558: pos = NULL;
1559: while ((pos = kernfs_next_descendant_post(pos, kn))) {
1560: pos->flags |= KERNFS_REMOVING;
1561: if (kernfs_active(pos))
1562: atomic_add(KN_DEACTIVATED_BIAS, &pos->active);
1563: }
1564: up_write(&kernfs_root(kn)->kernfs_iattr_rwsem);
1565:
1566: /* deactivate and unlink the subtree node-by-node */
1567: do {
1568: pos = kernfs_leftmost_descendant(kn);
1569:
1570: /*
1571: * kernfs_drain() may drop kernfs_rwsem temporarily and @pos's
1572: * base ref could have been put by someone else by the time
1573: * the function returns. Make sure it doesn't go away
1574: * underneath us.
1575: */
1576: kernfs_get(pos);
1577:
1578: kernfs_drain(pos, true);
1579: parent = kernfs_parent(pos);
1580: /*
1581: * kernfs_unlink_sibling() succeeds once per node. Use it
1582: * to decide who's responsible for cleanups.
1583: */
1584: if (!parent || kernfs_unlink_sibling(pos)) {
1585: struct kernfs_iattrs *ps_iattr =
1586: parent ? parent->iattr : NULL;
1587:
1588: down_write(&kernfs_root(kn)->kernfs_iattr_rwsem);
1589:
1590: kernfs_clear_inode_nlink(pos);
1591:
1592: /* update timestamps on the parent */
1593: if (ps_iattr) {
1594: ktime_get_real_ts64(&ps_iattr->ia_ctime);
1595: ps_iattr->ia_mtime = ps_iattr->ia_ctime;
1596: }
1597:
1598: up_write(&kernfs_root(kn)->kernfs_iattr_rwsem);
1599: kernfs_put(pos);
1600: }
1601:
1602: kernfs_put(pos);
1603: } while (pos != kn);
1604: }
SourceFile:fs/kernfs/dir.c]
|
| 30/2 |
2026/11/24 01:09 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode: 581: /**
582: * kernfs_put - put a reference count on a kernfs_node
583: * @kn: the target kernfs_node
584: *
585: * Put a reference count of @kn and destroy it if it reached zero.
586: */
587: void kernfs_put(struct kernfs_node *kn)
588: {
589: struct kernfs_node *parent;
590: struct kernfs_root *root;
591:
592: if (!kn || !atomic_dec_and_test(&kn->count))
593: return;
594: root = kernfs_root(kn);
595: repeat:
596: /*
597: * Moving/renaming is always done while holding reference.
598: * kn->parent won't change beneath us.
599: */
600: parent = kernfs_parent(kn);
601:
602: if (atomic_read(&kn->active) != KN_DEACTIVATED_BIAS) {
603: guard(rcu)();
604: WARN_ONCE(1,
605: "kernfs_put: %s/%s: released with incorrect active_ref %d\n",
606: parent ? rcu_dereference(parent->name) : "",
607: rcu_dereference(kn->name), atomic_read(&kn->active));
608: }
609:
610: if (kernfs_type(kn) == KERNFS_LINK)
611: kernfs_put(kn->symlink.target_kn);
612:
613: if (kn->iattr)
614: simple_xattrs_free(&root->xa_cache, &kn->iattr->xattrs, NULL);
615:
616: spin_lock(&root->kernfs_idr_lock);
617: idr_remove(&root->ino_idr, (u32)kernfs_ino(kn));
618: spin_unlock(&root->kernfs_idr_lock);
619:
620: call_rcu(&kn->rcu, kernfs_free_rcu);
621:
622: kn = parent;
623: if (kn) {
624: if (atomic_dec_and_test(&kn->count))
625: goto repeat;
626: } else {
627: /* just released the root kn, free @root too */
628: idr_destroy(&root->ino_idr);
629: simple_xattr_cache_cleanup(&root->xa_cache);
630: kfree_rcu(root, rcu);
631: }
632: }
SourceFile:fs/kernfs/dir.c]
|
| 31/2 |
2026/11/24 01:09 |
tool |
codesearch-definition-source |
0m
Args: map[Name:kernfs_rename_ns]
Results: map[SourceCode:1809: /**
1810: * kernfs_rename_ns - move and rename a kernfs_node
1811: * @kn: target node
1812: * @new_parent: new parent to put @sd under
1813: * @new_name: new name
1814: * @new_ns: new namespace tag
1815: *
1816: * Return: %0 on success, -errno on failure.
1817: */
1818: int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,
1819: const char *new_name, const struct ns_common *new_ns)
1820: {
1821: struct kernfs_node *old_parent;
1822: const char *dup_name = NULL;
1823: const char *put_name = NULL;
1824: struct kernfs_root *root;
1825: const char *old_name;
1826: bool reparent;
1827: int error;
1828:
1829: /* can't move or rename root */
1830: if (!rcu_access_pointer(kn->__parent))
1831: return -EINVAL;
1832:
1833: if (new_name)
1834: dup_name = kstrdup_const(new_name, GFP_KERNEL);
1835:
1836: root = kernfs_root(kn);
1837: down_write(&root->kernfs_rwsem);
1838:
1839: error = -ENOENT;
1840: if (!kernfs_active(kn) || !kernfs_active(new_parent) ||
1841: (new_parent->flags & KERNFS_EMPTY_DIR))
1842: goto out;
1843:
1844: old_parent = kernfs_parent(kn);
1845: if (root->flags & KERNFS_ROOT_INVARIANT_PARENT) {
1846: error = -EINVAL;
1847: if (WARN_ON_ONCE(old_parent != new_parent))
1848: goto out;
1849: }
1850:
1851: error = 0;
1852: old_name = kernfs_rcu_name(kn);
1853: if (!new_name)
1854: new_name = old_name;
1855: if ((old_parent == new_parent) &&
1856: (kernfs_ns_id(kn->ns) == kernfs_ns_id(new_ns)) &&
1857: (strcmp(old_name, new_name) == 0))
1858: goto out; /* nothing to rename */
1859:
1860: error = -EEXIST;
1861: if (kernfs_find_ns(new_parent, new_name, new_ns))
1862: goto out;
1863:
1864: /* rename kernfs_node */
1865: if (strcmp(old_name, new_name) != 0) {
1866: error = -ENOMEM;
1867: if (!dup_name)
1868: goto out;
1869: new_name = dup_name;
1870: dup_name = NULL;
1871: } else {
1872: new_name = NULL;
1873: }
1874:
1875: /*
1876: * Move to the appropriate place in the appropriate directories rbtree.
1877: */
1878: kernfs_unlink_sibling(kn);
1879:
1880: reparent = old_parent != new_parent;
1881: if (reparent)
1882: kernfs_get(new_parent);
1883:
1884: /*
1885: * kernfs_rename_lock protects ->__parent, ->ns and ->name, so take it
1886: * even when the parent does not change.
1887: */
1888: write_lock_irq(&root->kernfs_rename_lock);
1889:
1890: if (reparent)
1891: rcu_assign_pointer(kn->__parent, new_parent);
1892: WRITE_ONCE(kn->ns, new_ns);
1893: if (new_name)
1894: rcu_assign_pointer(kn->name, new_name);
1895:
1896: write_unlock_irq(&root->kernfs_rename_lock);
1897:
1898: if (reparent)
1899: kernfs_put(old_parent);
1900:
1901: kn->hash = kernfs_name_hash(new_name ?: old_name, kn->ns);
1902: kernfs_link_sibling(kn);
1903:
1904: if (new_name && !is_kernel_rodata((unsigned long)old_name))
1905: put_name = old_name;
1906:
1907: error = 0;
1908: out:
1909: up_write(&root->kernfs_rwsem);
1910: kfree_const(dup_name);
1911: if (put_name)
1912: kfree_rcu_mightsleep(put_name);
1913: return error;
1914: }
SourceFile:fs/kernfs/dir.c]
|
| 32/2 |
2026/11/24 01:09 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode: 813: /**
814: * kernfs_add_one - add kernfs_node to parent without warning
815: * @kn: kernfs_node to be added
816: *
817: * The caller must already have initialized @kn->parent. This
818: * function increments nlink of the parent's inode if @kn is a
819: * directory and link into the children list of the parent.
820: *
821: * Return:
822: * %0 on success, -EEXIST if entry with the given name already
823: * exists.
824: */
825: int kernfs_add_one(struct kernfs_node *kn)
826: {
827: struct kernfs_root *root = kernfs_root(kn);
828: struct kernfs_iattrs *ps_iattr;
829: struct kernfs_node *parent;
830: bool has_ns;
831: int ret;
832:
833: down_write(&root->kernfs_rwsem);
834: parent = kernfs_parent(kn);
835:
836: ret = -EINVAL;
837: has_ns = kernfs_ns_enabled(parent);
838: if (WARN(has_ns != (bool)kn->ns, KERN_WARNING "kernfs: ns %s in '%s' for '%s'\n",
839: has_ns ? "required" : "invalid",
840: kernfs_rcu_name(parent), kernfs_rcu_name(kn)))
841: goto out_unlock;
842:
843: if (kernfs_type(parent) != KERNFS_DIR)
844: goto out_unlock;
845:
846: ret = -ENOENT;
847: if (parent->flags & (KERNFS_REMOVING | KERNFS_EMPTY_DIR))
848: goto out_unlock;
849:
850: kn->hash = kernfs_name_hash(kernfs_rcu_name(kn), kn->ns);
851:
852: ret = kernfs_link_sibling(kn);
853: if (ret)
854: goto out_unlock;
855:
856: /* Update timestamps on the parent */
857: down_write(&root->kernfs_iattr_rwsem);
858:
859: ps_iattr = parent->iattr;
860: if (ps_iattr) {
861: ktime_get_real_ts64(&ps_iattr->ia_ctime);
862: ps_iattr->ia_mtime = ps_iattr->ia_ctime;
863: }
864:
865: up_write(&root->kernfs_iattr_rwsem);
866:
867: /*
868: * Activate the new node unless CREATE_DEACTIVATED is requested.
869: * If not activated here, the kernfs user is responsible for
870: * activating the node with kernfs_activate(). A node which hasn't
871: * been activated is not visible to userland and its removal won't
872: * trigger deactivation.
873: *
874: * @kn has no children yet, so kernfs_activate() would walk only @kn.
875: * Do it here rather than dropping the write lock and taking it again
876: * for every new node.
877: */
878: if (!(root->flags & KERNFS_ROOT_CREATE_DEACTIVATED))
879: kernfs_activate_one(kn);
880:
881: up_write(&root->kernfs_rwsem);
882: return 0;
883:
884: out_unlock:
885: up_write(&root->kernfs_rwsem);
886: return ret;
887: }
SourceFile:fs/kernfs/dir.c]
|
| 33/2 |
2026/11/24 01:09 |
llm |
cause-finder |
0m
Model:
Tokens:
input: 45559
output: 214
thoughts: 202
Thoughts: **Tracing the Lifecycle of Network Device Kobjects**
My current line of investigation is centered on the lifecycle and relationships of kobjects associated with network devices, specifically within the context of bonding drivers. I'm focusing my attention on the core network device handling in `net/core/dev.c`, its sysfs interface in `net/core/net-sysfs.c`, the fundamental kobject management in `lib/kobject.c`, and the specific implementation details found in `drivers/net/bonding/`.
A key point of observation, or perhaps a nagging question, arose when examining the `bond0` device. I noticed the presence of `rx-0`, `parent`, and `sibling` entries. This immediately prompted me to question the underlying mechanisms that establish these relationships and how they are represented in the sysfs hierarchy. My immediate thought was to delve into `net/core/net-sysfs.c` to understand how these kobject relationships are managed during the lifecycle of network device queues and the device itself.
Specifically, I'm looking at functions like `rx_queue_release`, `netdev_queue_release`, `netdev_register_kobject`, `netdev_unregister_kobject`, and `remove_queue_kobjects`. These functions are likely responsible for the creation, registration, and eventual cleanup of the kobjects that represent network device queues and the device itself within sysfs.
To gain a deeper understanding, I've identified specific code sections within `net/core/net-sysfs.c` that seem most relevant: roughly lines 1150-1370, which might deal with queue-specific kobject management, and lines 1900-2370, which could encompass broader device-level kobject registration and unregistration procedures. By scrutinizing these areas, I aim to unravel how the `rx-0` queue, for instance, gets linked to its parent `bond0` device, and how these sibling relationships are established and maintained as devices and their queues are added and removed.
|
| 34/2 |
2026/11/24 01:09 |
tool |
read-file |
0m
Args: map[File:net/core/net-sysfs.c FirstLine:1150 LineCount:100]
Results: map[Contents:1150: return len;
1151: }
1152:
1153: static struct rx_queue_attribute rps_cpus_attribute __ro_after_init
1154: = __ATTR(rps_cpus, 0644, show_rps_map, store_rps_map);
1155:
1156: static struct rx_queue_attribute rps_dev_flow_table_cnt_attribute __ro_after_init
1157: = __ATTR(rps_flow_cnt, 0644,
1158: show_rps_dev_flow_table_cnt, store_rps_dev_flow_table_cnt);
1159: #endif /* CONFIG_RPS */
1160:
1161: static struct attribute *rx_queue_default_attrs[] __ro_after_init = {
1162: #ifdef CONFIG_RPS
1163: &rps_cpus_attribute.attr,
1164: &rps_dev_flow_table_cnt_attribute.attr,
1165: #endif
1166: NULL
1167: };
1168: ATTRIBUTE_GROUPS(rx_queue_default);
1169:
1170: static void rx_queue_release(struct kobject *kobj)
1171: {
1172: struct netdev_rx_queue *queue = to_rx_queue(kobj);
1173: #ifdef CONFIG_RPS
1174: rps_tag_ptr tag_ptr;
1175: struct rps_map *map;
1176:
1177: map = rcu_dereference_protected(queue->rps_map, 1);
1178: if (map) {
1179: RCU_INIT_POINTER(queue->rps_map, NULL);
1180: kfree_rcu(map, rcu);
1181: }
1182:
1183: tag_ptr = xchg(&queue->rps_flow_table, 0UL);
1184: if (tag_ptr)
1185: kvfree_rcu_mightsleep(rps_tag_to_table(tag_ptr));
1186: #endif
1187:
1188: netdev_tracker_free(queue->dev, &queue->dev_tracker);
1189: /* Pairs with the smp_mb() in rx_queue_add_kobject(). */
1190: smp_mb();
1191: memset(kobj, 0, sizeof(*kobj));
1192: __dev_put(queue->dev);
1193: }
1194:
1195: static const struct ns_common *rx_queue_namespace(const struct kobject *kobj)
1196: {
1197: struct netdev_rx_queue *queue = to_rx_queue(kobj);
1198: struct device *dev = &queue->dev->dev;
1199:
1200: if (dev->class && dev->class->namespace)
1201: return dev->class->namespace(dev);
1202:
1203: return NULL;
1204: }
1205:
1206: static void rx_queue_get_ownership(const struct kobject *kobj,
1207: kuid_t *uid, kgid_t *gid)
1208: {
1209: const struct ns_common *ns = rx_queue_namespace(kobj);
1210:
1211: net_ns_get_ownership(ns ? container_of(ns, struct net, ns) : NULL,
1212: uid, gid);
1213: }
1214:
1215: static const struct kobj_type rx_queue_ktype = {
1216: .sysfs_ops = &rx_queue_sysfs_ops,
1217: .release = rx_queue_release,
1218: .namespace = rx_queue_namespace,
1219: .get_ownership = rx_queue_get_ownership,
1220: };
1221:
1222: static int rx_queue_default_mask(struct net_device *dev,
1223: struct netdev_rx_queue *queue)
1224: {
1225: #if IS_ENABLED(CONFIG_RPS) && IS_ENABLED(CONFIG_SYSCTL)
1226: struct cpumask *rps_default_mask;
1227: int res = 0;
1228:
1229: mutex_lock(&rps_default_mask_mutex);
1230:
1231: rps_default_mask = dev_net(dev)->core.rps_default_mask;
1232: if (rps_default_mask && !cpumask_empty(rps_default_mask))
1233: res = netdev_rx_queue_set_rps_mask(queue, rps_default_mask);
1234:
1235: mutex_unlock(&rps_default_mask_mutex);
1236:
1237: return res;
1238: #else
1239: return 0;
1240: #endif
1241: }
1242:
1243: static int rx_queue_add_kobject(struct net_device *dev, int index)
1244: {
1245: struct netdev_rx_queue *queue = dev->_rx + index;
1246: struct kobject *kobj = &queue->kobj;
1247: int error = 0;
1248:
1249: /* Rx queues are cleared in rx_queue_release to allow later
]
|
| 35/2 |
2026/11/24 01:09 |
tool |
read-file |
0m
Args: map[File:net/core/net-sysfs.c FirstLine:1250 LineCount:100]
Results: map[Contents:1250: * re-registration. This is triggered when their kobj refcount is
1251: * dropped.
1252: *
1253: * If a queue is removed while both a read (or write) operation and a
1254: * the re-addition of the same queue are pending (waiting on rntl_lock)
1255: * it might happen that the re-addition will execute before the read,
1256: * making the initial removal to never happen (queue's kobj refcount
1257: * won't drop enough because of the pending read). In such rare case,
1258: * return to allow the removal operation to complete.
1259: */
1260: if (unlikely(kobj->state_initialized)) {
1261: netdev_warn_once(dev, "Cannot re-add rx queues before their removal completed");
1262: return -EAGAIN;
1263: }
1264:
1265: /* Pairs with the smp_mb() in rx_queue_release(). */
1266: smp_mb();
1267:
1268: /* Kobject_put later will trigger rx_queue_release call which
1269: * decreases dev refcount: Take that reference here
1270: */
1271: netdev_hold(queue->dev, &queue->dev_tracker, GFP_KERNEL);
1272:
1273: kobj->kset = dev->queues_kset;
1274: error = kobject_init_and_add(kobj, &rx_queue_ktype, NULL,
1275: "rx-%u", index);
1276: if (error)
1277: goto err;
1278:
1279: queue->groups = rx_queue_default_groups;
1280: error = sysfs_create_groups(kobj, queue->groups);
1281: if (error)
1282: goto err;
1283:
1284: if (dev->sysfs_rx_queue_group) {
1285: error = sysfs_create_group(kobj, dev->sysfs_rx_queue_group);
1286: if (error)
1287: goto err_default_groups;
1288: }
1289:
1290: error = rx_queue_default_mask(dev, queue);
1291: if (error)
1292: goto err_default_groups;
1293:
1294: kobject_uevent(kobj, KOBJ_ADD);
1295:
1296: return error;
1297:
1298: err_default_groups:
1299: sysfs_remove_groups(kobj, queue->groups);
1300: err:
1301: kobject_put(kobj);
1302: return error;
1303: }
1304:
1305: static int rx_queue_change_owner(struct net_device *dev, int index, kuid_t kuid,
1306: kgid_t kgid)
1307: {
1308: struct netdev_rx_queue *queue = dev->_rx + index;
1309: struct kobject *kobj = &queue->kobj;
1310: int error;
1311:
1312: error = sysfs_change_owner(kobj, kuid, kgid);
1313: if (error)
1314: return error;
1315:
1316: if (dev->sysfs_rx_queue_group)
1317: error = sysfs_group_change_owner(
1318: kobj, dev->sysfs_rx_queue_group, kuid, kgid);
1319:
1320: return error;
1321: }
1322: #endif /* CONFIG_SYSFS */
1323:
1324: int
1325: net_rx_queue_update_kobjects(struct net_device *dev, int old_num, int new_num)
1326: {
1327: #ifdef CONFIG_SYSFS
1328: int i;
1329: int error = 0;
1330:
1331: #ifndef CONFIG_RPS
1332: if (!dev->sysfs_rx_queue_group)
1333: return 0;
1334: #endif
1335: for (i = old_num; i < new_num; i++) {
1336: error = rx_queue_add_kobject(dev, i);
1337: if (error) {
1338: new_num = old_num;
1339: break;
1340: }
1341: }
1342:
1343: while (--i >= new_num) {
1344: struct netdev_rx_queue *queue = &dev->_rx[i];
1345: struct kobject *kobj = &queue->kobj;
1346:
1347: if (!check_net(dev_net(dev)))
1348: kobj->uevent_suppress = 1;
1349: if (dev->sysfs_rx_queue_group)
]
|
| 36/2 |
2026/11/24 01:09 |
tool |
read-file |
0m
Args: map[File:net/core/net-sysfs.c FirstLine:1915 LineCount:100]
Results: map[Contents:1915: err = __netif_set_xps_queue(dev, mask, index, XPS_RXQS);
1916: cpus_read_unlock();
1917:
1918: rtnl_unlock();
1919:
1920: bitmap_free(mask);
1921: return err ? : len;
1922: }
1923:
1924: static struct netdev_queue_attribute xps_rxqs_attribute __ro_after_init
1925: = __ATTR_RW(xps_rxqs);
1926: #endif /* CONFIG_XPS */
1927:
1928: static struct attribute *netdev_queue_default_attrs[] __ro_after_init = {
1929: &queue_trans_timeout.attr,
1930: &queue_traffic_class.attr,
1931: #ifdef CONFIG_XPS
1932: &xps_cpus_attribute.attr,
1933: &xps_rxqs_attribute.attr,
1934: &queue_tx_maxrate.attr,
1935: #endif
1936: NULL
1937: };
1938: ATTRIBUTE_GROUPS(netdev_queue_default);
1939:
1940: static void netdev_queue_release(struct kobject *kobj)
1941: {
1942: struct netdev_queue *queue = to_netdev_queue(kobj);
1943:
1944: netdev_tracker_free(queue->dev, &queue->dev_tracker);
1945: /* Pairs with the smp_mb() in netdev_queue_add_kobject(). */
1946: smp_mb();
1947: memset(kobj, 0, sizeof(*kobj));
1948: __dev_put(queue->dev);
1949: }
1950:
1951: static const struct ns_common *netdev_queue_namespace(const struct kobject *kobj)
1952: {
1953: struct netdev_queue *queue = to_netdev_queue(kobj);
1954: struct device *dev = &queue->dev->dev;
1955:
1956: if (dev->class && dev->class->namespace)
1957: return dev->class->namespace(dev);
1958:
1959: return NULL;
1960: }
1961:
1962: static void netdev_queue_get_ownership(const struct kobject *kobj,
1963: kuid_t *uid, kgid_t *gid)
1964: {
1965: const struct ns_common *ns = netdev_queue_namespace(kobj);
1966:
1967: net_ns_get_ownership(ns ? container_of(ns, struct net, ns) : NULL,
1968: uid, gid);
1969: }
1970:
1971: static const struct kobj_type netdev_queue_ktype = {
1972: .sysfs_ops = &netdev_queue_sysfs_ops,
1973: .release = netdev_queue_release,
1974: .namespace = netdev_queue_namespace,
1975: .get_ownership = netdev_queue_get_ownership,
1976: };
1977:
1978: static bool netdev_uses_bql(const struct net_device *dev)
1979: {
1980: if (dev->lltx || (dev->priv_flags & IFF_NO_QUEUE))
1981: return false;
1982:
1983: return IS_ENABLED(CONFIG_BQL);
1984: }
1985:
1986: static int netdev_queue_add_kobject(struct net_device *dev, int index)
1987: {
1988: struct netdev_queue *queue = dev->_tx + index;
1989: struct kobject *kobj = &queue->kobj;
1990: int error = 0;
1991:
1992: /* Tx queues are cleared in netdev_queue_release to allow later
1993: * re-registration. This is triggered when their kobj refcount is
1994: * dropped.
1995: *
1996: * If a queue is removed while both a read (or write) operation and a
1997: * the re-addition of the same queue are pending (waiting on rntl_lock)
1998: * it might happen that the re-addition will execute before the read,
1999: * making the initial removal to never happen (queue's kobj refcount
2000: * won't drop enough because of the pending read). In such rare case,
2001: * return to allow the removal operation to complete.
2002: */
2003: if (unlikely(kobj->state_initialized)) {
2004: netdev_warn_once(dev, "Cannot re-add tx queues before their removal completed");
2005: return -EAGAIN;
2006: }
2007:
2008: /* Pairs with the smp_mb() in netdev_queue_release(). */
2009: smp_mb();
2010:
2011: /* Kobject_put later will trigger netdev_queue_release call
2012: * which decreases dev refcount: Take that reference here
2013: */
2014: netdev_hold(queue->dev, &queue->dev_tracker, GFP_KERNEL);
]
|
| 37/2 |
2026/11/24 01:09 |
tool |
read-file |
0m
Args: map[File:net/core/net-sysfs.c FirstLine:2170 LineCount:100]
Results: map[Contents:2170: if (error)
2171: return error;
2172:
2173: error = net_tx_queue_change_owner(ndev, real_tx, kuid, kgid);
2174: if (error)
2175: return error;
2176:
2177: return 0;
2178: }
2179:
2180: static void remove_queue_kobjects(struct net_device *dev)
2181: {
2182: int real_rx = 0, real_tx = 0;
2183:
2184: #ifdef CONFIG_SYSFS
2185: real_rx = dev->real_num_rx_queues;
2186: #endif
2187: real_tx = dev->real_num_tx_queues;
2188:
2189: net_rx_queue_update_kobjects(dev, real_rx, 0);
2190: netdev_queue_update_kobjects(dev, real_tx, 0);
2191:
2192: netdev_lock_ops(dev);
2193: dev->real_num_rx_queues = 0;
2194: dev->real_num_tx_queues = 0;
2195: netdev_unlock_ops(dev);
2196: #ifdef CONFIG_SYSFS
2197: kset_unregister(dev->queues_kset);
2198: #endif
2199: }
2200:
2201: static bool net_current_may_mount(void)
2202: {
2203: struct net *net = current->nsproxy->net_ns;
2204:
2205: return ns_capable(net->user_ns, CAP_SYS_ADMIN);
2206: }
2207:
2208: static struct ns_common *net_grab_current_ns(void)
2209: {
2210: struct net *net = current->nsproxy->net_ns;
2211: #ifdef CONFIG_NET_NS
2212: if (net)
2213: refcount_inc(&net->passive);
2214: #endif
2215: return net ? to_ns_common(net) : NULL;
2216: }
2217:
2218: static const struct ns_common *net_initial_ns(void)
2219: {
2220: return to_ns_common(&init_net);
2221: }
2222:
2223: static const struct ns_common *net_netlink_ns(struct sock *sk)
2224: {
2225: return to_ns_common(sock_net(sk));
2226: }
2227:
2228: const struct kobj_ns_type_operations net_ns_type_operations = {
2229: .type = KOBJ_NS_TYPE_NET,
2230: .current_may_mount = net_current_may_mount,
2231: .grab_current_ns = net_grab_current_ns,
2232: .netlink_ns = net_netlink_ns,
2233: .initial_ns = net_initial_ns,
2234: .drop_ns = net_drop_ns,
2235: };
2236: EXPORT_SYMBOL_GPL(net_ns_type_operations);
2237:
2238: static int netdev_uevent(const struct device *d, struct kobj_uevent_env *env)
2239: {
2240: const struct net_device *dev = to_net_dev(d);
2241: int retval;
2242:
2243: /* pass interface to uevent. */
2244: retval = add_uevent_var(env, "INTERFACE=%s", dev->name);
2245: if (retval)
2246: goto exit;
2247:
2248: /* pass ifindex to uevent.
2249: * ifindex is useful as it won't change (interface name may change)
2250: * and is what RtNetlink uses natively.
2251: */
2252: retval = add_uevent_var(env, "IFINDEX=%d", dev->ifindex);
2253:
2254: exit:
2255: return retval;
2256: }
2257:
2258: /*
2259: * netdev_release -- destroy and free a dead device.
2260: * Called when last reference to device kobject is gone.
2261: */
2262: static void netdev_release(struct device *d)
2263: {
2264: struct net_device *dev = to_net_dev(d);
2265:
2266: BUG_ON(dev->reg_state != NETREG_RELEASED);
2267:
2268: /* no need to wait for rcu grace period:
2269: * device is dead and about to be freed.
]
|
| 38/2 |
2026/11/24 01:09 |
tool |
read-file |
0m
Args: map[File:net/core/net-sysfs.c FirstLine:2270 LineCount:100]
Results: map[Contents:2270: */
2271: kfree(rcu_access_pointer(dev->ifalias));
2272: kvfree(dev);
2273: }
2274:
2275: static const struct ns_common *net_namespace(const struct device *d)
2276: {
2277: const struct net_device *dev = to_net_dev(d);
2278:
2279: return to_ns_common(dev_net(dev));
2280: }
2281:
2282: static void net_get_ownership(const struct device *d, kuid_t *uid, kgid_t *gid)
2283: {
2284: const struct net_device *dev = to_net_dev(d);
2285: const struct net *net = dev_net(dev);
2286:
2287: net_ns_get_ownership(net, uid, gid);
2288: }
2289:
2290: static const struct class net_class = {
2291: .name = "net",
2292: .dev_release = netdev_release,
2293: .dev_groups = net_class_groups,
2294: .dev_uevent = netdev_uevent,
2295: .ns_type = &net_ns_type_operations,
2296: .namespace = net_namespace,
2297: .get_ownership = net_get_ownership,
2298: };
2299:
2300: #ifdef CONFIG_OF
2301: static int of_dev_node_match(struct device *dev, const void *data)
2302: {
2303: for (; dev; dev = dev->parent) {
2304: if (dev->of_node == data)
2305: return 1;
2306: }
2307:
2308: return 0;
2309: }
2310:
2311: /*
2312: * of_find_net_device_by_node - lookup the net device for the device node
2313: * @np: OF device node
2314: *
2315: * Looks up the net_device structure corresponding with the device node.
2316: * If successful, returns a pointer to the net_device with the embedded
2317: * struct device refcount incremented by one, or NULL on failure. The
2318: * refcount must be dropped when done with the net_device.
2319: */
2320: struct net_device *of_find_net_device_by_node(struct device_node *np)
2321: {
2322: struct device *dev;
2323:
2324: dev = class_find_device(&net_class, NULL, np, of_dev_node_match);
2325: if (!dev)
2326: return NULL;
2327:
2328: return to_net_dev(dev);
2329: }
2330: EXPORT_SYMBOL(of_find_net_device_by_node);
2331: #endif
2332:
2333: /* Delete sysfs entries but hold kobject reference until after all
2334: * netdev references are gone.
2335: */
2336: void netdev_unregister_kobject(struct net_device *ndev)
2337: {
2338: struct device *dev = &ndev->dev;
2339:
2340: if (!check_net(dev_net(ndev)))
2341: dev_set_uevent_suppress(dev, 1);
2342:
2343: kobject_get(&dev->kobj);
2344:
2345: remove_queue_kobjects(ndev);
2346:
2347: pm_runtime_set_memalloc_noio(dev, false);
2348:
2349: device_del(dev);
2350: }
2351:
2352: /* Create sysfs entries for network device. */
2353: int netdev_register_kobject(struct net_device *ndev)
2354: {
2355: struct device *dev = &ndev->dev;
2356: const struct attribute_group **groups = ndev->sysfs_groups;
2357: int error = 0;
2358:
2359: device_initialize(dev);
2360: dev->class = &net_class;
2361: dev->platform_data = ndev;
2362: dev->groups = groups;
2363:
2364: dev_set_name(dev, "%s", ndev->name);
2365:
2366: #ifdef CONFIG_SYSFS
2367: /* Allow for a device specific group */
2368: if (*groups)
2369: groups++;
]
|
| 39/2 |
2026/11/24 01:09 |
llm |
cause-finder |
0m
Model:
Tokens:
input: 53486
output: 134
thoughts: 438
Thoughts: **Delving into the `bond0` Crash: A Deep Dive into Kernel Internals**
My mind immediately leaps to the crucial files involved: `bond_main.c` and `bond_sysfs.c` for the bonding driver's core logic and sysfs interface, and importantly, `net/core/dev.c` as the central point for network device management. I also need to scrutinize `fs/kernfs/mount.c` because I suspect the issue might be rooted in the kernel's file system handling, specifically related to how devices and their attributes are exposed via sysfs.
The immediate question that burns is *why* did `bond0` crash specifically within `net_rx_queue_update_kobjects`? This function name strongly suggests a problem related to the dynamic creation or management of kernel objects associated with the receive queues of the bond interface.
This line of inquiry then leads me to examine the release paths for these objects: `rx_queue_release` and `netdev_queue_release`. If an object isn't properly released, or if there's a race condition during its lifecycle, it can lead to instability. I'm also thinking about the underlying kernel mechanisms for object reference counting and sysfs directory removal: `kobject_put`, `sysfs_remove_dir`, and `kernfs_remove`. A subtle bug in how these are invoked or interacted with could be the culprit.
Then, my attention is fixated on this peculiar value: `0x00000021`. This hex value, which translates to 33 in decimal, feels like a red herring or a critical piece of corrupted data. Where could this specific value originate?
I then shift my focus to the `struct kernfs_node`, as it's the fundamental building block for sysfs entries. Looking at its structure, I see specific offsets: `__rb_parent_color` at offset 16, `rb_right` at offset 20, and `rb_left` at offset 24. The value `0x21` is at offset 24. My immediate thought is: could `0x00000021` represent a corrupted pointer, or perhaps an integer, flags, enum, count, size, or length within *another* structure of size 88 bytes that is somehow interacting with `kernfs_node`? Or, even more unsettling, is it data *within* `kernfs_node` itself that has been corrupted?
This leads me to broaden my search. I need to discover what other slab caches in the kernel allocate objects of approximately 88 bytes (acknowledging the potential size variation on 32-bit ARM, where it might be closer to 72-88 bytes). More specifically, I'm looking for any code that *writes* the value `0x21` (or 33 decimal) at offset 24 of such an object.
The critical realization about the architecture comes next: on 32-bit ARM, `sizeof(struct kernfs_node)` is indeed 88 bytes. This strongly reinforces the idea that `0x21` at offset 24 within a `kernfs_node` is a significant clue.
Finally, I need to trace the origin of the `kernfs_node` cache itself. This cache is initialized in `fs/kernfs/mount.c`. My next step is to meticulously read the code in `fs/kernfs/mount.c` around line 472, where the cache is likely defined or initialized. Concurrently, I'll be reviewing recent commits in the `mm/`, `net/`, and `fs/` subsystems, as a change in memory management, network stack, or file system handling could have introduced this bug. I'm looking for any modifications that might affect `kernfs_node` allocation, manipulation, or deallocation, especially those that could lead to a corrupted value like `0x21` being present at that specific offset.
|
| 40/2 |
2026/11/24 01:10 |
tool |
read-file |
0m
Args: map[File:fs/kernfs/mount.c FirstLine:450 LineCount:60]
Results: map[Contents: 450: kill_anon_super(sb);
451: kfree(info);
452: }
453:
454: static void __init kernfs_mutex_init(void)
455: {
456: int count;
457:
458: for (count = 0; count < NR_KERNFS_LOCKS; count++)
459: mutex_init(&kernfs_locks->node_mutex[count]);
460: }
461:
462: static void __init kernfs_lock_init(void)
463: {
464: kernfs_locks = kmalloc_obj(struct kernfs_global_locks);
465: WARN_ON(!kernfs_locks);
466:
467: kernfs_mutex_init();
468: }
469:
470: void __init kernfs_init(void)
471: {
472: kernfs_node_cache = kmem_cache_create("kernfs_node_cache",
473: sizeof(struct kernfs_node),
474: 0, SLAB_PANIC, NULL);
475:
476: /* Creates slab cache for kernfs inode attributes */
477: kernfs_iattrs_cache = kmem_cache_create("kernfs_iattrs_cache",
478: sizeof(struct kernfs_iattrs),
479: 0, SLAB_PANIC, NULL);
480:
481: kernfs_lock_init();
482: }
]
|
| 41/2 |
2026/11/24 01:10 |
tool |
git-log |
0m
Args: map[Count:20 PathPrefix:drivers/net/bonding/bond_sysfs.c]
Results: map[Output:4dc5a40b3bc9 bonding: annotate data-races in sysfs and procfs
e3b2cf6e5dba kernfs: pass struct ns_common instead of const void * for namespace tags
23a6037ce76c bonding: Remove support for use_carrier
662e451d9a62 bonding: no longer use RTNL in bonding_show_queue_id()
d67fed98caa1 bonding: no longer use RTNL in bonding_show_slaves()
6c5d17143fa4 bonding: no longer use RTNL in bonding_show_bonds()
e08190ef514f bonding: add modifier to initialization function and exit function
75a2d4226b53 driver core: class: mark the struct class for sysfs callbacks as constant
96e0718165a0 net: bonding: Convert to use sysfs_emit()/sysfs_emit_at() APIs
5944b5abd864 Bonding: add arp_missed_max option
caa9b35fadff bonding: use the correct function to check for netdev name collision
3a755cd8b7c6 bonding: add new option lacp_active
86a5ad0a4608 net: bonding: add some required blank lines
07a4ddec3ce9 bonding: add an option to specify a delay between peer notifications
0a65089ec508 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 5
5b3df177233e bonding: don't cast const buf in sysfs store
d61e40385655 drivers/net: Use octal not symbolic permissions
02dbbef05486 net: bonding: constify attribute_group structures.
174cd4b1e5fb sched/headers: Prepare to move signal wakeup & sigpending methods from <linux/sched.h> into <linux/sched/signal.h>
c8086f6d88f0 bonding: make mii_status sysfs node consistent
]
|
| 42/2 |
2026/11/24 01:10 |
tool |
git-log |
0m
Args: map[Count:20 PathPrefix:lib/kobject.c]
Results: map[Output:3aac49b236c1 kobject: Fix the kobj_set_name reference in kset_register() kernel-doc
ed96337a5bae kobject: Allow the constification of kobject attributes
e3b2cf6e5dba kernfs: pass struct ns_common instead of const void * for namespace tags
bf4afc53b77a Convert 'alloc_obj' family to use the new default GFP_KERNEL argument
69050f8d6d07 treewide: Replace kmalloc with kmalloc_obj for non-scalar types
ee9c69388e3b kobject: Remove unused functions
3ca8fbabcceb Revert "kobject: Remove redundant checks for whether ktype is NULL"
1b28cb81dab7 kobject: Remove redundant checks for whether ktype is NULL
4d0fe8c52bb3 kobject: Add sanity check for kset->kobj.ktype in kset_register()
e2dfa1d5223c kobject: Add helper kobj_ns_type_is_valid()
b2f10148ec1e kobject: Use return value of strreplace()
64414da25baf kobject: align stacktrace levels to logging message
984063339e9e kobject: define common logging prefix
dda6b81f17ad kobject: make dynamic_kobj_ktype and kset_ktype const
3bb2a01caa81 kobject: Fix slab-out-of-bounds in fill_kobj_path()
542aa24646ca kobject: make kobject_namespace take a const *
02a476d93228 kobject: make kobject_get_ownership() take a constant kobject *
8032bf1233a7 treewide: use get_random_u32_below() instead of deprecated function
1662cea4623f kset: fix memory leak when kset_register() returns error
33a0a1e3b3d1 kobject: modify kobject_get_path() to take a const *
]
|
| 43/2 |
2026/11/24 01:10 |
tool |
git-log |
0m
Args: map[Count:20 PathPrefix:fs/sysfs/]
Results: map[Output:454257f6d124 sysfs: clamp show() return value in sysfs_kf_read()
237557b8a81a sysfs: don't remove existing directory on update failure
78d797520f6a sysfs: remove trivial sysfs_get_tree() wrapper
dc4edae7f41d fs: move SB_I_USERNS_VISIBLE to FS_USERNS_MOUNT_RESTRICTED
f71cc65c01bd sysfs: upgrade OOB write by buggy .show hook into WARNing
9ce4a8c07b28 sysfs: attribute_group: Respect is_visible_const() when changing owner
e3b2cf6e5dba kernfs: pass struct ns_common instead of const void * for namespace tags
fe2511adb1fc sysfs: constify group arrays in function arguments
bf4afc53b77a Convert 'alloc_obj' family to use the new default GFP_KERNEL argument
69050f8d6d07 treewide: Replace kmalloc with kmalloc_obj for non-scalar types
d79ff2d61202 sysfs: remove exports of sysfs_*change_owner()
7dd9fdb4939b sysfs: attribute_group: enable const variants of is_visible()
c7fbb8218b4a sysfs: check visibility before changing group attribute ownership
1d6249c1ce82 sysfs: remove bin_attribute::read_new/write_new()
340d8e66c43f sysfs: constify internal references to 'struct bin_attribute'
9bec944506fa sysfs: constify attribute_group::bin_attrs
741c10b096bc kernfs: Use RCU to access kernfs_node::name.
633488947ef6 kernfs: Use RCU to access kernfs_node::parent.
3675a926feef sysfs: constify bin_attribute argument of sysfs_bin_attr_simple_read()
eb2e6c3a8d66 sysfs: bin_attribute: add const read/write callback variants
]
|
| 44/2 |
2026/11/24 01:10 |
llm |
cause-finder |
0m
Model:
Tokens:
input: 56120
output: 130
thoughts: 612
Thoughts: **Unearthing the Truth: A Deep Dive into Potential Memory Corruption**
Wait a second! I need to re-examine the prompt and the root cause analysis (RCA) very carefully. The RCA points to "External Memory Corruption" as the culprit, specifically noting that a live `struct kernfs_node` had its `rb.rb_left` field corrupted with an odd, non-pointer value (`0x00000021`). It also asserts that no local code paths within `rbtree`, `kernfs`, `sysfs`, `kobject`, `net-sysfs`, or `bonding` would write such a value or cause a race condition on `dir.children`. The RCA then suggests possible mechanisms like a dangling-pointer use-after-free or an out-of-bounds write from an adjacent object.
But before I conclude that it's truly inconclusive and my instructions dictate returning an empty candidate list, I absolutely *must* verify two critical points. First, did the RCA miss something subtle within `rbtree`, `kernfs`, `syssys`, `kobject`, `net-sysfs`, `net/core/dev.c`, or `bonding` that *could* explain this corruption? Second, is there actually a scenario within `kernfs_node`, `rbtree`, `net-sysfs`, or `bonding` that *could* directly lead to this exact issue?
To do this, I'm going to meticulously scrutinize every detail of the RCA and trace every potential code path. My immediate next step is to dive deep into `lib/rbtree.c`, specifically lines 350-450, to understand exactly what `____rb_erase_color` is doing at `lib/rbtree.c:366` and `lib/rbtree.c:445`. I'll be looking for any obscure rbtree bug or any potential `kernfs_node` vulnerability that might have been overlooked. Reading through `lib/rbtree.c` will be my next priority.
|
| 45/2 |
2026/11/24 01:10 |
tool |
read-file |
0m
Args: map[File:lib/rbtree.c FirstLine:330 LineCount:100]
Results: map[Contents: 330: /*
331: * Case 4 - left rotate at parent + color flips
332: * (p and sl could be either color here.
333: * After rotation, p becomes black, s acquires
334: * p's color, and sl keeps its color)
335: *
336: * (p) (s)
337: * / \ / \
338: * N S --> P Sr
339: * / \ / \
340: * (sl) sr N (sl)
341: */
342: tmp2 = sibling->rb_left;
343: WRITE_ONCE(parent->rb_right, tmp2);
344: WRITE_ONCE(sibling->rb_left, parent);
345: rb_set_parent_color(tmp1, sibling, RB_BLACK);
346: if (tmp2)
347: rb_set_parent(tmp2, parent);
348: __rb_rotate_set_parents(parent, sibling, root,
349: RB_BLACK);
350: augment_rotate(parent, sibling);
351: break;
352: } else {
353: sibling = parent->rb_left;
354: if (rb_is_red(sibling)) {
355: /* Case 1 - right rotate at parent */
356: tmp1 = sibling->rb_right;
357: WRITE_ONCE(parent->rb_left, tmp1);
358: WRITE_ONCE(sibling->rb_right, parent);
359: rb_set_parent_color(tmp1, parent, RB_BLACK);
360: __rb_rotate_set_parents(parent, sibling, root,
361: RB_RED);
362: augment_rotate(parent, sibling);
363: sibling = tmp1;
364: }
365: tmp1 = sibling->rb_left;
366: if (!tmp1 || rb_is_black(tmp1)) {
367: tmp2 = sibling->rb_right;
368: if (!tmp2 || rb_is_black(tmp2)) {
369: /* Case 2 - sibling color flip */
370: rb_set_parent_color(sibling, parent,
371: RB_RED);
372: if (rb_is_red(parent))
373: rb_set_black(parent);
374: else {
375: node = parent;
376: parent = rb_parent(node);
377: if (parent)
378: continue;
379: }
380: break;
381: }
382: /* Case 3 - left rotate at sibling */
383: tmp1 = tmp2->rb_left;
384: WRITE_ONCE(sibling->rb_right, tmp1);
385: WRITE_ONCE(tmp2->rb_left, sibling);
386: WRITE_ONCE(parent->rb_left, tmp2);
387: if (tmp1)
388: rb_set_parent_color(tmp1, sibling,
389: RB_BLACK);
390: augment_rotate(sibling, tmp2);
391: tmp1 = sibling;
392: sibling = tmp2;
393: }
394: /* Case 4 - right rotate at parent + color flips */
395: tmp2 = sibling->rb_right;
396: WRITE_ONCE(parent->rb_left, tmp2);
397: WRITE_ONCE(sibling->rb_right, parent);
398: rb_set_parent_color(tmp1, sibling, RB_BLACK);
399: if (tmp2)
400: rb_set_parent(tmp2, parent);
401: __rb_rotate_set_parents(parent, sibling, root,
402: RB_BLACK);
403: augment_rotate(parent, sibling);
404: break;
405: }
406: }
407: }
408:
409: /* Non-inline version for rb_erase_augmented() use */
410: void __rb_erase_color(struct rb_node *parent, struct rb_root *root,
411: void (*augment_rotate)(struct rb_node *old, struct rb_node *new))
412: {
413: ____rb_erase_color(parent, root, augment_rotate);
414: }
415: EXPORT_SYMBOL(__rb_erase_color);
416:
417: /*
418: * Non-augmented rbtree manipulation functions.
419: *
420: * We use dummy augmented callbacks here, and have the compiler optimize them
421: * out of the rb_insert_color() and rb_erase() function definitions.
422: */
423:
424: static inline void dummy_propagate(struct rb_node *node, struct rb_node *stop) {}
425: static inline void dummy_copy(struct rb_node *old, struct rb_node *new) {}
426: static inline void dummy_rotate(struct rb_node *old, struct rb_node *new) {}
427:
428: static const struct rb_augment_callbacks dummy_callbacks = {
429: .propagate = dummy_propagate,
]
|
| 46/2 |
2026/11/24 01:10 |
tool |
read-file |
0m
Args: map[File:lib/rbtree.c FirstLine:430 LineCount:50]
Results: map[Contents: 430: .copy = dummy_copy,
431: .rotate = dummy_rotate
432: };
433:
434: void rb_insert_color(struct rb_node *node, struct rb_root *root)
435: {
436: __rb_insert(node, root, dummy_rotate);
437: }
438: EXPORT_SYMBOL(rb_insert_color);
439:
440: void rb_erase(struct rb_node *node, struct rb_root *root)
441: {
442: struct rb_node *rebalance;
443: rebalance = __rb_erase_augmented(node, root, &dummy_callbacks);
444: if (rebalance)
445: ____rb_erase_color(rebalance, root, dummy_rotate);
446: }
447: EXPORT_SYMBOL(rb_erase);
448:
449: bool rb_erase_linked(struct rb_node_linked *node, struct rb_root_linked *root)
450: {
451: if (node->prev)
452: node->prev->next = node->next;
453: else
454: root->rb_leftmost = node->next;
455:
456: if (node->next)
457: node->next->prev = node->prev;
458:
459: rb_erase(&node->node, &root->rb_root);
460: RB_CLEAR_LINKED_NODE(node);
461:
462: return !!root->rb_leftmost;
463: }
464: EXPORT_SYMBOL_GPL(rb_erase_linked);
465:
466: /*
467: * Augmented rbtree manipulation functions.
468: *
469: * This instantiates the same __always_inline functions as in the non-augmented
470: * case, but this time with user-defined callbacks.
471: */
472:
473: void __rb_insert_augmented(struct rb_node *node, struct rb_root *root,
474: void (*augment_rotate)(struct rb_node *old, struct rb_node *new))
475: {
476: __rb_insert(node, root, augment_rotate);
477: }
478: EXPORT_SYMBOL(__rb_insert_augmented);
479:
]
|
| 47/2 |
2026/11/24 01:10 |
tool |
codesearch-definition-source |
0m
Args: map[Name:kernfs_link_sibling]
Results: map[SourceCode: 371: /**
372: * kernfs_link_sibling - link kernfs_node into sibling rbtree
373: * @kn: kernfs_node of interest
374: *
375: * Link @kn into its sibling rbtree which starts from
376: * @kn->parent->dir.children.
377: *
378: * Locking:
379: * kernfs_rwsem held exclusive
380: *
381: * Return:
382: * %0 on success, -EEXIST on failure.
383: */
384: static int kernfs_link_sibling(struct kernfs_node *kn)
385: {
386: struct rb_node *parent = NULL;
387: struct kernfs_node *kn_parent;
388: struct rb_node **node;
389:
390: kn_parent = kernfs_parent(kn);
391: node = &kn_parent->dir.children.rb_node;
392:
393: while (*node) {
394: struct kernfs_node *pos;
395: int result;
396:
397: pos = rb_to_kn(*node);
398: parent = *node;
399: result = kernfs_sd_compare(kn, pos);
400: if (result < 0)
401: node = &pos->rb.rb_left;
402: else if (result > 0)
403: node = &pos->rb.rb_right;
404: else
405: return -EEXIST;
406: }
407:
408: /* add new node and rebalance the tree */
409: rb_link_node(&kn->rb, parent, node);
410: rb_insert_color(&kn->rb, &kn_parent->dir.children);
411:
412: /* successfully added, account subdir number */
413: down_write(&kernfs_root(kn)->kernfs_iattr_rwsem);
414: if (kernfs_type(kn) == KERNFS_DIR)
415: kn_parent->dir.subdirs++;
416: kernfs_inc_rev(kn_parent);
417: up_write(&kernfs_root(kn)->kernfs_iattr_rwsem);
418:
419: return 0;
420: }
SourceFile:fs/kernfs/dir.c]
|
| 48/2 |
2026/11/24 01:10 |
tool |
codesearch-definition-source |
0m
Args: map[Name:__kernfs_new_node]
Results: map[SourceCode: 653: static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root,
654: struct kernfs_node *parent,
655: const char *name, umode_t mode,
656: kuid_t uid, kgid_t gid,
657: unsigned flags)
658: {
659: struct kernfs_node *kn;
660: u32 id_highbits;
661: int ret;
662:
663: name = kstrdup_const(name, GFP_KERNEL);
664: if (!name)
665: return NULL;
666:
667: kn = kmem_cache_zalloc(kernfs_node_cache, GFP_KERNEL);
668: if (!kn)
669: goto err_out1;
670:
671: idr_preload(GFP_KERNEL);
672: spin_lock(&root->kernfs_idr_lock);
673: ret = idr_alloc_cyclic(&root->ino_idr, kn, 1, 0, GFP_ATOMIC);
674: if (ret >= 0 && ret < root->last_id_lowbits)
675: root->id_highbits++;
676: id_highbits = root->id_highbits;
677: root->last_id_lowbits = ret;
678: spin_unlock(&root->kernfs_idr_lock);
679: idr_preload_end();
680: if (ret < 0)
681: goto err_out2;
682:
683: kn->id = (u64)id_highbits << 32 | ret;
684:
685: atomic_set(&kn->count, 1);
686: atomic_set(&kn->active, KN_DEACTIVATED_BIAS);
687: RB_CLEAR_NODE(&kn->rb);
688:
689: rcu_assign_pointer(kn->name, name);
690: kn->mode = mode;
691: kn->flags = flags;
692:
693: if (!uid_eq(uid, GLOBAL_ROOT_UID) || !gid_eq(gid, GLOBAL_ROOT_GID)) {
694: struct iattr iattr = {
695: .ia_valid = ATTR_UID | ATTR_GID,
696: .ia_uid = uid,
697: .ia_gid = gid,
698: };
699:
700: ret = __kernfs_setattr(kn, &iattr);
701: if (ret < 0)
702: goto err_out3;
703: }
704:
705: if (parent) {
706: kernfs_get(parent);
707: rcu_assign_pointer(kn->__parent, parent);
708:
709: ret = security_kernfs_init_security(parent, kn);
710: if (ret)
711: goto err_out4;
712: }
713:
714: return kn;
715:
716: err_out4:
717: RCU_INIT_POINTER(kn->__parent, NULL);
718: kernfs_put(parent);
719: if (kn->iattr) {
720: simple_xattrs_free(&root->xa_cache, &kn->iattr->xattrs, NULL);
721: kmem_cache_free(kernfs_iattrs_cache, kn->iattr);
722: }
723: err_out3:
724: spin_lock(&root->kernfs_idr_lock);
725: idr_remove(&root->ino_idr, (u32)kernfs_ino(kn));
726: spin_unlock(&root->kernfs_idr_lock);
727: err_out2:
728: kmem_cache_free(kernfs_node_cache, kn);
729: err_out1:
730: kfree_const(name);
731: return NULL;
732: }
SourceFile:fs/kernfs/dir.c]
|
| 49/2 |
2026/11/24 01:10 |
llm |
cause-finder |
0m
Model:
Tokens:
input: 61170
output: 42
thoughts: 1218
Thoughts: **Diving Deep into the `kernfs_node` Structure and Potential Memory Corruption**
My current investigation is fixated on a specific memory address, `0x8c5db268`, which I suspect might be a `kernfs_node`. I'm meticulously examining every byte and field within this suspected structure. Specifically, I'm looking at offset 16, which corresponds to the `rb` field, containing `__rb_parent_color`, `rb_right`, and `rb_left`.
A value of `0x00000021` has surfaced, and I'm trying to understand its origin. Reviewing the registers, I see:
* `pc`: `0x81c05e08`
* `lr`: `0x00000000` (This is odd, I'll need to follow up on that)
* `psr`: `20000113`
* `sp`: `e0379c70`
* `ip`: `8c5db3d8`
* `fp`: `e0379c84`
* `r10`: `000000c0`
* `r9`: `8c6d03c8`
* `r8`: `86ef9248`
* `r7`: `83c1d9c0`
* `r6`: `8c6d03c8`
* `r5`: `8c5db698`
* `r4`: `8c5db688`
* `r3`: `8c5db278` (This points to `&sibling_kn->rb`, which is offset 16 from `0x8c5db268`)
* `r2`: `0x8c5db3d9` (This appears to be `parent | RB_BLACK`, where the `parent` is `0x8c5db3d8`, which matches `ip`, and is likely `&parent_kn->rb` within `0x8c5db3c8`)
* `r1`: `0x8c6d03f4` (This points to `&kn_parent->dir.children`, offset 44 from `0x8c6d03c8`)
* `r0`: `00000021` (This value was loaded from `[r3, #8]`, which is offset 24 from `0x8c5db268`)
The crucial question is: **Why does `r0` contain `0x00000021`?** This value is peculiar because its least significant bit is set, indicating it's odd. This leads me to two primary hypotheses:
1. **Possibility A: The `kernfs_node` at `0x8c5db268` has been freed and reallocated.** The `0x00000021` could be a stray value from a newly allocated structure in a merged slab cache (specifically, a size 88 cache). This reallocation might have occurred while the original `kernfs_node` was still incorrectly linked within `queues->dir.children`.
2. **Possibility B: The `rb_left` pointer within the `kernfs_node` at `0x8c5db268` has been corrupted.** This corruption could have been caused by either the rbtree operations or by `kernfs` itself.
I'm immediately trying to rule out the simpler explanation first. My prior root cause analysis (RCA) suggested that a premature `kernfs_put()` would have triggered a `WARN_ONCE` and set the `TAINT_WARN` flag. I need to re-evaluate this assumption. Could `0x8c5db268` have been freed *without* triggering that warning, even if it was still a child in `queues->dir.children`?
Let's scrutinize the conditions under which a `kernfs_node` might be freed without a `kernfs_put()` warning:
* **Scenario 1: `atomic_read(&kn->active) == KN_DEACTIVATED_BIAS`**. When does `active` reach this state? It's typically before activation (when `KERNFS_ROOT_CREATE_DEACTIVATED` is set, which isn't the case here for sysfs) or, critically, *after* `__kernfs_remove()` has processed the node. However, if `__kernfs_remove()` had already executed, it would have called `kernfs_unlink_sibling(pos)` *before* `kernfs_put(pos)`. This means `0x8c5db268` couldn't have been in `queues->dir.children` if `__kernfs_remove()` had completed its work on it.
* **Scenario 2: Direct `kmem_cache_free` without `kernfs_put()` call.** Is there any other code path that calls `kmem_cache_free(kernfs_node_cache, ...)` directly? Looking at the kernel, the only other instance I can find is within the error handling path of `__kernfs_new_node()` (specifically `err_out2`), which occurs *before* the node is linked into any tree via `kernfs_add_one()`. This again suggests the node wouldn't be in `queues->dir.children` at the time of direct freeing.
* **Scenario 3: Corruption of `rb_node` by the rbtree or `kernfs` itself.** Let's examine `lib/rbtree.c`. Neither `rb_erase` nor `rb_insert_color` appear to write `0x21` into `rb_left`. These functions primarily deal with `struct rb_node *` pointers or NULL.
This leads me back to the `kernfs_node` structure itself. What data is stored at offset 24 of a `struct kernfs_node`? I need to consult the definition in `include/linux/kernfs.h`, specifically looking at lines 190-260, to understand what field occupies that position and how it might explain the `0x00000021` value. The possibility of a freed and reallocated slab is becoming increasingly plausible, especially if the node was still linked in `dir.children` when it was unexpectedly reclaimed.
|
| 50/2 |
2026/11/24 01:10 |
tool |
read-file |
0m
Args: map[File:include/linux/kernfs.h FirstLine:190 LineCount:70]
Results: map[Contents: 190: /*
191: * kernfs_node - the building block of kernfs hierarchy. Each and every
192: * kernfs node is represented by single kernfs_node. Most fields are
193: * private to kernfs and shouldn't be accessed directly by kernfs users.
194: *
195: * As long as count reference is held, the kernfs_node itself is
196: * accessible. Dereferencing elem or any other outer entity requires
197: * active reference.
198: */
199: struct kernfs_node {
200: atomic_t count;
201: atomic_t active;
202: #ifdef CONFIG_DEBUG_LOCK_ALLOC
203: struct lockdep_map dep_map;
204: #endif
205: /*
206: * Use kernfs_get_parent() and kernfs_name/path() instead of
207: * accessing the following two fields directly. If the node is
208: * never moved to a different parent, it is safe to access the
209: * parent directly.
210: */
211: struct kernfs_node __rcu *__parent;
212: const char __rcu *name;
213:
214: struct rb_node rb;
215:
216: const struct ns_common *ns; /* namespace tag */
217: unsigned int hash; /* ns + name hash */
218: unsigned short flags;
219: umode_t mode;
220:
221: union {
222: struct kernfs_elem_dir dir;
223: struct kernfs_elem_symlink symlink;
224: struct kernfs_elem_attr attr;
225: };
226:
227: /*
228: * 64bit unique ID. On 64bit ino setups, id is the ino. On 32bit,
229: * the low 32bits are ino and upper generation.
230: */
231: u64 id;
232:
233: void *priv;
234: struct kernfs_iattrs *iattr;
235:
236: struct rcu_head rcu;
237: };
238:
239: /*
240: * kernfs_syscall_ops may be specified on kernfs_create_root() to support
241: * syscalls. These optional callbacks are invoked on the matching syscalls
242: * and can perform any kernfs operations which don't necessarily have to be
243: * the exact operation requested. An active reference is held for each
244: * kernfs_node parameter.
245: */
246: struct kernfs_syscall_ops {
247: int (*show_options)(struct seq_file *sf, struct kernfs_root *root);
248:
249: int (*mkdir)(struct kernfs_node *parent, const char *name,
250: umode_t mode);
251: int (*rmdir)(struct kernfs_node *kn);
252: int (*rename)(struct kernfs_node *kn, struct kernfs_node *new_parent,
253: const char *new_name);
254: int (*show_path)(struct seq_file *sf, struct kernfs_node *kn,
255: struct kernfs_root *root);
256: };
257:
258: struct kernfs_node *kernfs_root_to_node(struct kernfs_root *root);
259:
]
|
| 51/2 |
2026/11/24 01:10 |
llm |
cause-finder |
0m
Model:
Tokens:
input: 63519
output: 58
thoughts: 273
Thoughts: **Analyzing a Critical Kernel Softlockup: Re-evaluating External Memory Corruption Claims**
I was reviewing a crash log that pointed to a `Tainted: [L]=SOFTLOCKUP` state. The previous root cause analysis (RCA) concluded that the crash was a consequence of prior, uncaptured external slab memory corruption. Specifically, the RCA stated that a `kernfs_node` in `queues->dir.children` had its `rb.rb_left` field (at offset 24) overwritten with `0x00000021`. It further argued that no local code paths within `rbtree`, `kernfs`, `sysfs`, `kobject`, `net-sysfs`, or `bonding` would write an odd/non-pointer value to this specific offset or cause an unlock race on `dir.children`.
However, I'm pausing to reconsider this conclusion. While the previous RCA's logic seems sound at first glance, I believe it's imperative to exhaust all internal possibilities before definitively attributing the issue to external factors or declaring it inconclusive. My intuition suggests there might be an overlooked internal race condition or a subtle interaction that wasn't fully captured.
Therefore, my immediate next step is to investigate the `kernfs` subsystem more deeply, specifically focusing on functions that directly manipulate the `kn->rb` (red-black tree node) or `dir.children` members. I'm specifically thinking about functions like `kernfs_link_sibling`, `kernfs_unlink_sibling`, and `kernfs_rename_ns`, as these are prime candidates for modifying the `kernfs_node`'s red-black tree structure and its children.
To that end, I'm going to perform a comprehensive code search across the entire kernel codebase. I will use `codesearch-find-references` to identify *all* locations where `kernfs_node::rb` and `kernfs_elem_dir::children` are modified. This exhaustive search will help me confirm or refute the RCA's assertion that no internal paths could be responsible for the observed memory corruption. I want to be absolutely certain that we haven't missed a critical internal race or an unexpected interaction within the kernel's core filesystem and networking components.
|
| 52/2 |
2026/11/24 01:10 |
tool |
codesearch-find-references |
0m
Args: map[Name:kernfs_node::rb]
Results: map[References:[map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:__kernfs_new_node SourceFile:fs/kernfs/dir.c SourceLine:687] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:__kernfs_new_node SourceFile:fs/kernfs/dir.c SourceLine:687] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:__kernfs_remove SourceFile:fs/kernfs/dir.c SourceLine:1551] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:__kernfs_remove SourceFile:fs/kernfs/dir.c SourceLine:1551] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_activate_one SourceFile:fs/kernfs/dir.c SourceLine:1437] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_activate_one SourceFile:fs/kernfs/dir.c SourceLine:1437] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_dir_next_pos SourceFile:fs/kernfs/dir.c SourceLine:1989] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:kernfs_dir_next_pos SourceFile:fs/kernfs/dir.c SourceLine:1993] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:kernfs_dir_pos SourceFile:fs/kernfs/dir.c SourceLine:1957] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_dir_pos SourceFile:fs/kernfs/dir.c SourceLine:1970] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:kernfs_dir_pos SourceFile:fs/kernfs/dir.c SourceLine:1974] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:kernfs_find_ns SourceFile:fs/kernfs/dir.c SourceLine:920] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:kernfs_leftmost_descendant SourceFile:fs/kernfs/dir.c SourceLine:1387] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:kernfs_link_sibling SourceFile:fs/kernfs/dir.c SourceLine:397] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:kernfs_link_sibling SourceFile:fs/kernfs/dir.c SourceLine:401] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:kernfs_link_sibling SourceFile:fs/kernfs/dir.c SourceLine:403] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_link_sibling SourceFile:fs/kernfs/dir.c SourceLine:409] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_link_sibling SourceFile:fs/kernfs/dir.c SourceLine:410] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_next_descendant_post SourceFile:fs/kernfs/dir.c SourceLine:1420] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:kernfs_next_descendant_post SourceFile:fs/kernfs/dir.c SourceLine:1422] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_remove_self SourceFile:fs/kernfs/dir.c SourceLine:1752] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_remove_self SourceFile:fs/kernfs/dir.c SourceLine:1752] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_unlink_sibling SourceFile:fs/kernfs/dir.c SourceLine:439] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_unlink_sibling SourceFile:fs/kernfs/dir.c SourceLine:439] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_unlink_sibling SourceFile:fs/kernfs/dir.c SourceLine:449] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_unlink_sibling SourceFile:fs/kernfs/dir.c SourceLine:450] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_unlink_sibling SourceFile:fs/kernfs/dir.c SourceLine:450]] TruncatedOutput:false]
|
| 53/2 |
2026/11/24 01:10 |
tool |
codesearch-find-references |
0m
Args: map[Name:kernfs_elem_dir::children]
Results: map[References:[map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:kernfs_dir_pos SourceFile:fs/kernfs/dir.c SourceLine:1949] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_enable_ns SourceFile:include/linux/kernfs.h SourceLine:391] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_enable_ns SourceFile:include/linux/kernfs.h SourceLine:391] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_enable_ns SourceFile:include/linux/kernfs.h SourceLine:391] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_enable_ns SourceFile:include/linux/kernfs.h SourceLine:391] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_enable_ns SourceFile:include/linux/kernfs.h SourceLine:391] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_enable_ns SourceFile:include/linux/kernfs.h SourceLine:391] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_enable_ns SourceFile:include/linux/kernfs.h SourceLine:391] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:kernfs_find_ns SourceFile:fs/kernfs/dir.c SourceLine:903] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_leftmost_descendant SourceFile:fs/kernfs/dir.c SourceLine:1383] map[ReferenceKind:reads ReferencingEntityKind:function ReferencingEntityName:kernfs_link_sibling SourceFile:fs/kernfs/dir.c SourceLine:391] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_link_sibling SourceFile:fs/kernfs/dir.c SourceLine:410] map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_unlink_sibling SourceFile:fs/kernfs/dir.c SourceLine:449]] TruncatedOutput:false]
|
| 54/2 |
2026/11/24 01:10 |
llm |
cause-finder |
0m
Model:
Tokens:
input: 66080
output: 80
thoughts: 84
Thoughts: **My Mental Walkthrough of `kernfs` Core Operations**
Okay, so my immediate reaction upon encountering these `kernfs` functions – specifically `kernfs_activate_one`, `kernfs_dir_pos`, `kernfs_remove_self`, and `kernfs_enable_ns` – is to dive into their mechanics. I want to understand the precise sequence of operations and how they interact with the underlying filesystem structures.
But then, a flicker of caution. Before I get too deep into the specifics of activation, directory positioning, self-removal, and namespace enablement, I need to be absolutely certain about the integrity of the critical synchronization mechanisms. My priority shifts. I need to pause my detailed analysis of those individual functions for a moment and instead, meticulously review `kernfs_activate_one`, `kernfs_remove_self`, and crucially, `kernfs_drain`. My reasoning here is that `kernfs_drain` likely holds a key to how resources are released and cleaned up, and any race conditions or missed lock acquisitions/releases within activation and self-removal, especially when combined with draining operations, could lead to severe data corruption or system instability. I'm looking for any potential overlapping lock scopes, improper lock ordering, or situations where a lock might be held across a blocking operation or a context switch that could expose a vulnerability. It's about ensuring the foundational safety nets are in place before I map out the more complex interactions.
|
| 55/2 |
2026/11/24 01:10 |
tool |
codesearch-definition-source |
0m
Args: map[Name:kernfs_activate_one]
Results: map[SourceCode:1428: static void kernfs_activate_one(struct kernfs_node *kn)
1429: {
1430: lockdep_assert_held_write(&kernfs_root(kn)->kernfs_rwsem);
1431:
1432: kn->flags |= KERNFS_ACTIVATED;
1433:
1434: if (kernfs_active(kn) || (kn->flags & (KERNFS_HIDDEN | KERNFS_REMOVING)))
1435: return;
1436:
1437: WARN_ON_ONCE(rcu_access_pointer(kn->__parent) && RB_EMPTY_NODE(&kn->rb));
1438: WARN_ON_ONCE(atomic_read(&kn->active) != KN_DEACTIVATED_BIAS);
1439:
1440: atomic_sub(KN_DEACTIVATED_BIAS, &kn->active);
1441: }
SourceFile:fs/kernfs/dir.c]
|
| 56/2 |
2026/11/24 01:10 |
tool |
codesearch-definition-source |
0m
Args: map[Name:kernfs_remove_self]
Results: map[SourceCode:1683: /**
1684: * kernfs_remove_self - remove a kernfs_node from its own method
1685: * @kn: the self kernfs_node to remove
1686: *
1687: * The caller must be running off of a kernfs operation which is invoked
1688: * with an active reference - e.g. one of kernfs_ops. This can be used to
1689: * implement a file operation which deletes itself.
1690: *
1691: * For example, the "delete" file for a sysfs device directory can be
1692: * implemented by invoking kernfs_remove_self() on the "delete" file
1693: * itself. This function breaks the circular dependency of trying to
1694: * deactivate self while holding an active ref itself. It isn't necessary
1695: * to modify the usual removal path to use kernfs_remove_self(). The
1696: * "delete" implementation can simply invoke kernfs_remove_self() on self
1697: * before proceeding with the usual removal path. kernfs will ignore later
1698: * kernfs_remove() on self.
1699: *
1700: * kernfs_remove_self() can be called multiple times concurrently on the
1701: * same kernfs_node. Only the first one actually performs removal and
1702: * returns %true. All others will wait until the kernfs operation which
1703: * won self-removal finishes and return %false. Note that the losers wait
1704: * for the completion of not only the winning kernfs_remove_self() but also
1705: * the whole kernfs_ops which won the arbitration. This can be used to
1706: * guarantee, for example, all concurrent writes to a "delete" file to
1707: * finish only after the whole operation is complete.
1708: *
1709: * Return: %true if @kn is removed by this call, otherwise %false.
1710: */
1711: bool kernfs_remove_self(struct kernfs_node *kn)
1712: {
1713: bool ret;
1714: struct kernfs_root *root = kernfs_root(kn);
1715:
1716: down_read(&root->kernfs_supers_rwsem);
1717: down_write(&root->kernfs_rwsem);
1718: kernfs_break_active_protection(kn);
1719:
1720: /*
1721: * SUICIDAL is used to arbitrate among competing invocations. Only
1722: * the first one will actually perform removal. When the removal
1723: * is complete, SUICIDED is set and the active ref is restored
1724: * while kernfs_rwsem for held exclusive. The ones which lost
1725: * arbitration waits for SUICIDED && drained which can happen only
1726: * after the enclosing kernfs operation which executed the winning
1727: * instance of kernfs_remove_self() finished.
1728: */
1729: if (!(kn->flags & KERNFS_SUICIDAL)) {
1730: kn->flags |= KERNFS_SUICIDAL;
1731: __kernfs_remove(kn);
1732: kn->flags |= KERNFS_SUICIDED;
1733: ret = true;
1734: } else {
1735: wait_queue_head_t *waitq = &kernfs_root(kn)->deactivate_waitq;
1736: DEFINE_WAIT(wait);
1737:
1738: while (true) {
1739: prepare_to_wait(waitq, &wait, TASK_UNINTERRUPTIBLE);
1740:
1741: if ((kn->flags & KERNFS_SUICIDED) &&
1742: atomic_read(&kn->active) == KN_DEACTIVATED_BIAS)
1743: break;
1744:
1745: up_write(&root->kernfs_rwsem);
1746: up_read(&root->kernfs_supers_rwsem);
1747: schedule();
1748: down_read(&root->kernfs_supers_rwsem);
1749: down_write(&root->kernfs_rwsem);
1750: }
1751: finish_wait(waitq, &wait);
1752: WARN_ON_ONCE(!RB_EMPTY_NODE(&kn->rb));
1753: ret = false;
1754: }
1755:
1756: /*
1757: * This must be done while kernfs_rwsem held exclusive; otherwise,
1758: * waiting for SUICIDED && deactivated could finish prematurely.
1759: */
1760: kernfs_unbreak_active_protection(kn);
1761:
1762: up_write(&root->kernfs_rwsem);
1763: up_read(&root->kernfs_supers_rwsem);
1764: return ret;
1765: }
SourceFile:fs/kernfs/dir.c]
|
| 57/2 |
2026/11/24 01:10 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode: 500: /**
501: * kernfs_drain - drain kernfs_node
502: * @kn: kernfs_node to drain
503: * @drop_supers: Set to true if this function is called with the
504: * kernfs_supers_rwsem locked.
505: *
506: * Drain existing usages and nuke all existing mmaps of @kn. Multiple
507: * removers may invoke this function concurrently on @kn and all will
508: * return after draining is complete.
509: */
510: static void kernfs_drain(struct kernfs_node *kn, bool drop_supers)
511: __releases(&kernfs_root(kn)->kernfs_rwsem)
512: __acquires(&kernfs_root(kn)->kernfs_rwsem)
513: {
514: struct kernfs_root *root = kernfs_root(kn);
515:
516: lockdep_assert_held_write(&root->kernfs_rwsem);
517: WARN_ON_ONCE(kernfs_active(kn));
518:
519: /*
520: * Skip draining if already fully drained. This avoids draining and its
521: * lockdep annotations for nodes which have never been activated
522: * allowing embedding kernfs_remove() in create error paths without
523: * worrying about draining.
524: */
525: if (atomic_read(&kn->active) == KN_DEACTIVATED_BIAS &&
526: !kernfs_should_drain_open_files(kn))
527: return;
528:
529: up_write(&root->kernfs_rwsem);
530: if (drop_supers)
531: up_read(&root->kernfs_supers_rwsem);
532:
533: if (kernfs_lockdep(kn)) {
534: rwsem_acquire(&kn->dep_map, 0, 0, _RET_IP_);
535: if (atomic_read(&kn->active) != KN_DEACTIVATED_BIAS)
536: lock_contended(&kn->dep_map, _RET_IP_);
537: }
538:
539: wait_event(root->deactivate_waitq,
540: atomic_read(&kn->active) == KN_DEACTIVATED_BIAS);
541:
542: if (kernfs_lockdep(kn)) {
543: lock_acquired(&kn->dep_map, _RET_IP_);
544: rwsem_release(&kn->dep_map, _RET_IP_);
545: }
546:
547: if (kernfs_should_drain_open_files(kn))
548: kernfs_drain_open_files(kn);
549:
550: if (drop_supers)
551: down_read(&root->kernfs_supers_rwsem);
552: down_write(&root->kernfs_rwsem);
553: }
SourceFile:fs/kernfs/dir.c]
|
| 58/2 |
2026/11/24 01:10 |
llm |
cause-finder |
0m
Model:
Tokens:
input: 68876
output: 90
thoughts: 1214
Thoughts: **Analyzing a Critical Kernel Crash: A Deep Dive into `kernfs` and Network Kobject Management**
I've been examining a kernel crash that points to a potential issue within the `kernfs` subsystem, specifically concerning how network-related kobjects are managed. My initial thought process was triggered by a close look at the `kernfs_drain` and `__kernfs_remove` functions. I noticed that `kernfs_drain` is designed to decrement a reference count, wait for all active elements and open files associated with a node to be drained, and then re-acquire a semaphore. This process, crucial for maintaining consistency, occurs under the protection of `kernfs_rwsem` whenever the directory's children list or the node's red-black tree is modified.
This brought me to consider the network stack, specifically the files within `net/core/net-sysfs.c`, `net/core/dev.c`, and even `drivers/net/bonding/`. I started questioning how network queue kobjects, like those managed by `net_rx_queue_update_kobjects` and `netdev_queue_update_kobjects`, interact with the `kernfs` removal process. In `net_rx_queue_update_kobjects`, for instance, it's clear that `rx-0` kobjects are created using `kobject_init_and_add` which eventually calls `sysfs_create_dir_ns`. Similarly, `netdev_queue_add_kobject` handles the creation of TX queue kobjects.
The critical point of concern emerged when I looked at `remove_queue_kobjects(ndev)`. This function calls `net_rx_queue_update_kobjects` and `netdev_queue_update_kobjects` with a count of zero, implying a removal operation. My worry is: what happens if a kobject that is being managed by these network functions is somehow removed or freed *while* the `kernfs` subsystem is in the middle of its removal process? The standard path for kobject removal, `kobject_put` leading to `kobject_cleanup`, `__kobject_del`, `sysfs_remove_dir`, and ultimately `kernfs_remove` and `kernfs_unlink_sibling`, seems susceptible to race conditions if not handled meticulously.
This line of thinking led me to the specific crash details: a value of `0x21` at offset 24 of an address `0x8c5db268`. I immediately wondered if this `0x21` represented something significant. I started cross-referencing this with the structure sizes within the kernel. Could there be a bug in the network drivers, the filesystem layer, memory management, or even the bonding driver that's causing an overwrite of an 88-byte slab object, or perhaps writing `0x21` at that specific offset?
I explored the meaning of `0x21`. It could be the ASCII character `'!'`, or the decimal value 33. More intriguingly, it could be interpreted as `0x20 | 1`. Could this represent a pointer to zero plus an offset of 33? Or, considering red-black tree structures, could it be related to `__rb_parent_color`, where the parent was `0x20` and the color was `1` (RB_BLACK)? However, I quickly checked and found that `__rb_parent_color` is at offset 16, not 24. The crucial observation is that offset 24 in a `struct kernfs_node` is actually `rb_left`.
This leads to a significant hypothesis: could `0x8c5db268` be a `struct kernfs_node` where its `rb.rb_left` field has been corrupted? Alternatively, could `0x8c5db268` *not* actually be a `kernfs_node` at all?
The crash log itself provides a vital clue: "Register r3 information: slab kernfs_node_cache start 8c5db268 pointer offset 16 size 88". The mention of `kernfs_node_cache` and a size of 88 bytes is critical, especially with `CONFIG_SLAB_MERGE_DEFAULT=y`. This configuration means that `kernfs_node_cache` could have been merged with *any* other kmem_cache of a compatible size. Crucially, SLUB typically reports the name of the *first* cache that created the alias, which would be `kernfs_node_cache` since `kernfs_init()` runs very early in boot. This implies that the object at `0x8c5db268` might not actually be a `kernfs_node`, but rather another object of size 88 bytes that has been allocated from a cache merged with `kernfs_node_cache`.
Therefore, the most pressing questions now are:
1. Could `0x8c5db268` have been a `kernfs_node` that was subsequently freed and then reallocated for a different purpose?
2. Could it have been overwritten by an out-of-bounds write from another part of the kernel?
3. Or, most critically, could it be a use-after-free scenario, where a `kernfs_node` was freed while still being referenced by the network kobject management code?
My immediate next step is to rigorously investigate the possibility of a `kernfs_node` being freed while it's still present in `queues->dir.children`. I need to meticulously examine every instance of `kernfs_put`, `kmem_cache_free(kernfs_node_cache, ...)` and `kernfs_free_rcu` within `fs/kernfs/`. I'll be utilizing tools like `codesearch-find-references` for `kernfs_node_cache` and `kernfs_put` to ensure I haven't missed any potential paths. The corruption at offset 24, specifically `rb_left`, combined with the `kernfs_node_cache` alias, strongly suggests a fundamental issue with object lifecycle management, likely a race condition or a use-after-free within the interaction between the network subsystem's kobject creation/destruction and the `kernfs` cleanup process.
|
| 59/2 |
2026/11/24 01:10 |
tool |
codesearch-find-references |
0m
Error:
Args: map[Name:kernfs_node_cache]
Results: map[References:<nil> TruncatedOutput:false]
|
| 60/2 |
2026/11/24 01:10 |
tool |
codesearch-find-references |
0m
Args: map[Name:kernfs_free_rcu]
Results: map[References:[map[ReferenceKind:takes-address-of ReferencingEntityKind:function ReferencingEntityName:kernfs_put SourceFile:fs/kernfs/dir.c SourceLine:620]] TruncatedOutput:false]
|
| 61/2 |
2026/11/24 01:10 |
tool |
codesearch-find-references |
0m
Args: map[Name:kernfs_remove SourceTreePrefix:fs/]
Results: map[References:[map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:internal_create_group SourceFile:fs/sysfs/group.c SourceLine:192] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:kernfs_destroy_root SourceFile:fs/kernfs/dir.c SourceLine:1096] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:sysfs_remove_dir SourceFile:fs/sysfs/dir.c SourceLine:101] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:sysfs_remove_group SourceFile:fs/sysfs/group.c SourceLine:330]] TruncatedOutput:false]
|
| 62/2 |
2026/11/24 01:10 |
llm |
cause-finder |
0m
Model:
Tokens:
input: 70510
output: 49
thoughts: 22
Thoughts: **My Internal Monologue: A Deep Dive into `kernfs_node_cache`**
Right, so before I commit to anything, I need absolute certainty. My first instinct is to verify my understanding of `kernfs_node_cache`. I'm going to run a quick `grepper` search for that specific term. This isn't about doubt, per se, but about the meticulous process of confirmation. I need to see every instance, every context in which it appears. This will allow me to build a comprehensive picture, ensuring no nuance is missed. I want to understand not just what it *is*, but how it's *used* – the patterns, the dependencies, the surrounding code. This thoroughness is critical for the level of expertise I operate at; a surface-level understanding just won't cut it when dealing with kernel-level constructs. This check is a cornerstone of my validation process.
|
| 63/2 |
2026/11/24 01:10 |
tool |
grepper |
0m
Args: map[Expression:kernfs_node_cache]
Results: map[Output:fs/kernfs/dir.c=568=static void kernfs_free_rcu(struct rcu_head *rcu)
--
fs/kernfs/dir.c-577-
fs/kernfs/dir.c:578: kmem_cache_free(kernfs_node_cache, kn);
fs/kernfs/dir.c-579-}
--
fs/kernfs/dir.c=653=static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root,
--
fs/kernfs/dir.c-666-
fs/kernfs/dir.c:667: kn = kmem_cache_zalloc(kernfs_node_cache, GFP_KERNEL);
fs/kernfs/dir.c-668- if (!kn)
--
fs/kernfs/dir.c-727- err_out2:
fs/kernfs/dir.c:728: kmem_cache_free(kernfs_node_cache, kn);
fs/kernfs/dir.c-729- err_out1:
--
fs/kernfs/kernfs-internal.h=172=extern const struct super_operations kernfs_sops;
fs/kernfs/kernfs-internal.h:173:extern struct kmem_cache *kernfs_node_cache, *kernfs_iattrs_cache;
fs/kernfs/kernfs-internal.h-174-
--
fs/kernfs/mount.c-23-
fs/kernfs/mount.c:24:struct kmem_cache *kernfs_node_cache __ro_after_init;
fs/kernfs/mount.c-25-struct kmem_cache *kernfs_iattrs_cache __ro_after_init;
--
fs/kernfs/mount.c=470=void __init kernfs_init(void)
fs/kernfs/mount.c-471-{
fs/kernfs/mount.c:472: kernfs_node_cache = kmem_cache_create("kernfs_node_cache",
fs/kernfs/mount.c-473- sizeof(struct kernfs_node),
]
|
| 64/2 |
2026/11/24 01:10 |
tool |
grepper |
0m
Args: map[Expression:kernfs_free_rcu]
Results: map[Output:fs/kernfs/dir.c=566=EXPORT_SYMBOL_GPL(kernfs_get);
fs/kernfs/dir.c-567-
fs/kernfs/dir.c:568:static void kernfs_free_rcu(struct rcu_head *rcu)
fs/kernfs/dir.c-569-{
--
fs/kernfs/dir.c=587=void kernfs_put(struct kernfs_node *kn)
--
fs/kernfs/dir.c-619-
fs/kernfs/dir.c:620: call_rcu(&kn->rcu, kernfs_free_rcu);
fs/kernfs/dir.c-621-
]
|
| 65/2 |
2026/11/24 01:10 |
llm |
cause-finder |
0m
Model:
Tokens:
input: 71335
output: 100
thoughts: 786
Thoughts: **My Debugging Journey into `kernfs_put` and Node Activation**
Okay, so I'm staring at this `kernfs_put()` function, and the kernel's own Right-Click Analysis (RCA) has already confirmed something crucial: it checks if a `kernfs_node` is active. The condition `atomic_read(&kn->active) != KN_DEACTIVATED_BIAS` triggers a `WARN_ONCE` if the `active` count isn't what it expects. What's more, the `Tainted: G L` output shows no `W` flag, which means the system hasn't been tainted by a `TAINT_WARN`. This is a strong indicator that `kernfs_put()` has *never* been called on an *active* `kernfs_node`.
Now, I'm tracing where `active` is set to `KN_DEACTIVATED_BIAS`. It seems `__kernfs_remove()` is the *only* function that does this. And here's a key point: `__kernfs_remove()` *also* calls `kernfs_unlink_sibling(pos)` *before* it calls `kernfs_put(pos)`, and crucially, this unlinking happens under the protection of `kernfs_rwsem`.
This leads me to question about nodes created with `KERNFS_ROOT_CREATE_DEACTIVATED`. I've checked, and `sysfs_root` doesn't use this flag. I also dug into the specific case of `0x8c6d03c8` – the `queues` directory under `bond0` in `sysfs`. This path goes through `sysfs_remove_dir` to `kernfs_remove`, and finally to `__kernfs_remove`.
But what about other creation paths? Could `kernfs_create_dir_ns` or `kernfs_new_node` lead to a situation where a `kernfs_node` in `sysfs` either fails activation or gets double-`kernfs_put`? If a double-put happened while the node was active, that `WARN_ONCE` would have fired. What if it was *never* activated? I need to examine `sysfs_create_dir_ns`, `kernfs_add_one`, `kernfs_create_link`, and `__kernfs_create_file`.
Looking at `kernfs_add_one`, I see this:
if (!(root->flags & KERNFS_ROOT_CREATE_DEACTIVATED))
kernfs_activate_one(kn);
This tells me that unless explicitly created as deactivated, any node linked into a directory in `sysfs` *is* activated. And importantly, `kernfs_link_sibling` happens *before* `kernfs_activate_one`. This means a node is linked into the parent's children list *before* the `kernfs_rwsem` is even released.
So, what if `kernfs_link_sibling` fails? If that happens, `kn` is never actually added to the `dir.children` list.
Then there's `kernfs_rename_ns`. I'm thinking about what happens there. It calls `kernfs_unlink_sibling(kn)` and then `kernfs_link_sibling(kn)`. Does `kernfs_rename_ns` ever fail and leave a node unlinked or corrupt the red-black tree structure? My initial assessment is no, it appears to handle these operations robustly.
Finally, I'm casting a wider net and checking specific locations like `net/core/dev.c` and `drivers/net/bonding/` to rule out any bugs related to `bond0`, `net_rx_queue_update_kobjects`, or `netdev_unregister_kobject`. I'm also specifically looking at `unregister_netdevice_many_notify` around line 12807 in `net/core/dev.c`. I need to carefully read the code in that vicinity to understand its behavior.
|
| 66/2 |
2026/11/24 01:11 |
tool |
read-file |
0m
Args: map[File:net/core/dev.c FirstLine:12740 LineCount:100]
Results: map[Contents:12740: if (!netdev_need_ops_lock(dev))
12741: list_add_tail(&dev->close_list, &close_head);
12742: }
12743: netif_close_many(&close_head, true);
12744:
12745: list_for_each_entry(dev, head, unreg_list) {
12746: /* And unlink it from device chain. */
12747: unlist_netdevice(dev);
12748: netdev_lock(dev);
12749: WRITE_ONCE(dev->reg_state, NETREG_UNREGISTERING);
12750: netdev_unlock(dev);
12751: }
12752: flush_all_backlogs();
12753:
12754: synchronize_net();
12755:
12756: list_for_each_entry(dev, head, unreg_list) {
12757: struct sk_buff *skb = NULL;
12758:
12759: /* Shutdown queueing discipline. */
12760: netdev_lock_ops(dev);
12761: dev_shutdown(dev);
12762: dev_tcx_uninstall(dev);
12763: dev_xdp_uninstall(dev);
12764: dev_memory_provider_uninstall(dev);
12765: netdev_work_cancel_all(dev);
12766: netdev_unlock_ops(dev);
12767: bpf_dev_bound_netdev_unregister(dev);
12768:
12769: netdev_offload_xstats_disable_all(dev);
12770:
12771: /* Notify protocols, that we are about to destroy
12772: * this device. They should clean all the things.
12773: */
12774: call_netdevice_notifiers(NETDEV_UNREGISTER, dev);
12775:
12776: if (!(dev->rtnl_link_ops && dev->rtnl_link_initializing))
12777: skb = rtmsg_ifinfo_build_skb(RTM_DELLINK, dev, ~0U, 0,
12778: GFP_KERNEL, NULL, 0,
12779: portid, nlh);
12780:
12781: /*
12782: * Flush the unicast and multicast chains
12783: */
12784: dev_uc_flush(dev);
12785: dev_mc_flush(dev);
12786:
12787:
12788: netdev_rss_contexts_free(dev);
12789:
12790: call_netdevice_notifiers(NETDEV_PRE_UNINIT, dev);
12791:
12792: if (dev->netdev_ops->ndo_uninit)
12793: dev->netdev_ops->ndo_uninit(dev);
12794:
12795: mutex_destroy(&dev->ethtool->rss_lock);
12796:
12797: net_shaper_flush_netdev(dev);
12798:
12799: if (skb)
12800: rtmsg_ifinfo_send(skb, dev, GFP_KERNEL, portid, nlh);
12801:
12802: /* Notifier chain MUST detach us all upper devices. */
12803: WARN_ON(netdev_has_any_upper_dev(dev));
12804: WARN_ON(netdev_has_any_lower_dev(dev));
12805:
12806: /* Remove entries from kobject tree */
12807: netdev_unregister_kobject(dev);
12808: #ifdef CONFIG_XPS
12809: /* Remove XPS queueing entries */
12810: netif_reset_xps_queues_gt(dev, 0);
12811: #endif
12812: }
12813:
12814: synchronize_net();
12815:
12816: list_for_each_entry(dev, head, unreg_list) {
12817: #ifdef CONFIG_DEBUG_NET_SMALL_RTNL
12818: struct net *net = dev_net(dev);
12819:
12820: /* spin_lock() can be moved outside of the loop
12821: * once the per-netns RTNL conversion completes.
12822: */
12823: spin_lock(&net->dev_unreg_lock);
12824: list_del(&dev->unreg_list_net);
12825: spin_unlock(&net->dev_unreg_lock);
12826: #endif
12827: netdev_put(dev, &dev->dev_registered_tracker);
12828: net_set_todo(dev);
12829: cnt++;
12830: }
12831: atomic_add(cnt, &dev_unreg_count);
12832:
12833: list_del(head);
12834: }
12835:
12836: /**
12837: * unregister_netdevice_many - unregister many devices
12838: * @head: list of devices
12839: *
]
|
| 67/2 |
2026/11/24 01:11 |
tool |
codesearch-definition-source |
0m
Args: map[Name:netdev_queue_update_kobjects]
Results: map[SourceCode:2061: int
2062: netdev_queue_update_kobjects(struct net_device *dev, int old_num, int new_num)
2063: {
2064: #ifdef CONFIG_SYSFS
2065: int i;
2066: int error = 0;
2067:
2068: /* Tx queue kobjects are allowed to be updated when a device is being
2069: * unregistered, but solely to remove queues from qdiscs. Any path
2070: * adding queues should be fixed.
2071: */
2072: WARN(dev->reg_state == NETREG_UNREGISTERING && new_num > old_num,
2073: "New queues can't be registered after device unregistration.");
2074:
2075: for (i = old_num; i < new_num; i++) {
2076: error = netdev_queue_add_kobject(dev, i);
2077: if (error) {
2078: new_num = old_num;
2079: break;
2080: }
2081: }
2082:
2083: while (--i >= new_num) {
2084: struct netdev_queue *queue = dev->_tx + i;
2085:
2086: if (!check_net(dev_net(dev)))
2087: queue->kobj.uevent_suppress = 1;
2088:
2089: if (netdev_uses_bql(dev))
2090: sysfs_remove_group(&queue->kobj, &dql_group);
2091:
2092: sysfs_remove_groups(&queue->kobj, queue->groups);
2093: kobject_put(&queue->kobj);
2094: }
2095:
2096: return error;
2097: #else
2098: return 0;
2099: #endif /* CONFIG_SYSFS */
2100: }
SourceFile:net/core/net-sysfs.c]
|
| 68/2 |
2026/11/24 01:11 |
tool |
codesearch-definition-source |
0m
Args: map[Name:netdev_register_kobject]
Results: map[SourceCode:2352: /* Create sysfs entries for network device. */
2353: int netdev_register_kobject(struct net_device *ndev)
2354: {
2355: struct device *dev = &ndev->dev;
2356: const struct attribute_group **groups = ndev->sysfs_groups;
2357: int error = 0;
2358:
2359: device_initialize(dev);
2360: dev->class = &net_class;
2361: dev->platform_data = ndev;
2362: dev->groups = groups;
2363:
2364: dev_set_name(dev, "%s", ndev->name);
2365:
2366: #ifdef CONFIG_SYSFS
2367: /* Allow for a device specific group */
2368: if (*groups)
2369: groups++;
2370:
2371: *groups++ = &netstat_group;
2372: *groups++ = &netdev_phys_group;
2373:
2374: if (wireless_group_needed(ndev))
2375: *groups++ = &wireless_group;
2376: #endif /* CONFIG_SYSFS */
2377:
2378: /* Hold back the KOBJ_ADD uevent until the device is listed. */
2379: dev_set_uevent_suppress(dev, 1);
2380:
2381: error = device_add(dev);
2382: if (error)
2383: return error;
2384:
2385: error = register_queue_kobjects(ndev);
2386: if (error) {
2387: device_del(dev);
2388: return error;
2389: }
2390:
2391: pm_runtime_set_memalloc_noio(dev, true);
2392:
2393: return error;
2394: }
SourceFile:net/core/net-sysfs.c]
|
| 69/2 |
2026/11/24 01:11 |
llm |
cause-finder |
0m
Model:
Tokens:
input: 75014
output: 116
thoughts: 232
Thoughts: **Analysis of Kernel Commit Interactions and Potential Race Conditions**
My immediate thought upon encountering the `c164a431a646 net: wait for in-flight device unregistrations before netns dismantle` and `241dec6f9ab7 net: stop defer_count outliving the deferred-free list` commits was that they likely address some form of race condition or ordering issue related to network device unregistration and network namespace dismantling. Given my expertise, I understand the critical nature of these operations and the potential for subtle bugs if not handled with extreme care.
Therefore, my first instinct was to dive into these specific commits to understand the exact problem they are solving and the mechanism of their solution. I wanted to ascertain if they were introducing new complexities or if they were straightforward fixes.
Beyond these two commits, my mind immediately cast a wider net. Network namespaces and device management are tightly coupled with filesystem operations (specifically sysfs in this context) and memory management. Thus, I decided it was prudent to also examine recent commits in `fs/kernfs/dir.c` and the `mm/` directory. This is because modifications in these core areas could have unintended ripple effects on network device handling, and I needed to ensure there wasn't a pre-existing or newly introduced issue that these network commits might be interacting with.
At this point, I also began considering specific network subsystems that might exhibit complex unregistration or initialization patterns. The `bonding` driver is a prime candidate for this. It involves intricate setup, enslavement, and release operations, which could potentially interact with device unregistration in non-obvious ways. My specific line of inquiry here was whether `bond_main.c` (specifically in functions like `bond_uninit`, `bond_setup`, `bond_enslave`, and `bond_release`) ever directly touched `rx-0`, `kernfs_node`, or `queues_kset`. My reasoning was that if bonding was interacting with these low-level structures directly, it could introduce dependencies or race conditions not immediately apparent from the network device core commits alone. However, my initial assessment suggested that bonding typically operates at a higher level, relying on standard netdev sysfs/rtnl interfaces, which *should* mean it's less likely to have direct, problematic interactions with the specific issues raised by the aforementioned network core commits.
To ensure absolute thoroughness and to fully grasp the context of the initial two commits, I then performed `git show` on both `c164a431a646` and `241dec6f9ab7`. This step is crucial for me to review not just the code changes themselves, but also the commit messages, author information, and any associated discussions or bug reports that might provide further insight into the problem domain and the implications of the fixes. It's about understanding the "why" as much as the "what."
|
| 70/2 |
2026/11/24 01:11 |
tool |
git-show |
0m
Args:
Results: map[Output:commit c164a431a646983275d0076ff5b0e4c326fbc10b
Author: Eric Dumazet <edumazet@kernel.org>
Date: Thu Nov 5 15:45:43 2026 +0100
net: wait for in-flight device unregistrations before netns dismantle
A device can be unregistered by a context other than the cleanup_net()
of its own netns, for instance a veth whose peer in another netns is
deleted. If references on it are still held, it stays in
netdev_wait_allrefs_any(), which rebroadcasts NETDEV_UNREGISTER every
second.
Meanwhile its netns can be dismantled: default_device_exit_batch()
only takes care of devices still listed in the netns, then pernet exit
handlers free their state, and finally struct net is freed while the
device still points to it.
The rebroadcasts then run notifiers against torn down pernet state, or
freed memory. Three instances were reported so far:
- netdev_genl_netdevice_event(): net->genl_sock is NULL [1]
- nh_netdev_event(): net->nexthop.devhash is NULL [2]
- nf_tables netdevice notifiers: use-after-free of the nftables
pernet storage [3]
but any notifier using dev_net(dev) is affected, as is
netdev_wait_allrefs_any() itself (__rtnl_net_lock(dev_net(dev)) with
CONFIG_DEBUG_NET_SMALL_RTNL=y).
This was prevented by rtnl_lock_unregistering() until I removed it
in commit 8a4fc54b07d7 ("net: get rid of rtnl_lock_unregistering()"),
considering only the loopback dependency, and missing the notifiers one.
Restore a per-netns counter of devices sitting in netdev_run_todo(),
and make default_device_exit_batch() wait for it to reach zero, after
it has unregistered all devices of the dying netns(es). At this point
no new unregistration can be started for these netns.
Unlike the old barrier, this only waits for devices of the netns being
dismantled and runs after their own devices are gone.
Tested on a KASAN kernel with a debug-only hack holding a reference
on a veth device for 5 seconds after its unregistration: a nexthop
on the veth in netns X, delete its peer from init_net, then delete X.
Without this patch, the nexthop_flush_dev() null-ptr-deref from [2]
triggers. With it, no splat; netns churn and dismantle of a netns
whose own device is held still work.
[1] https://lore.kernel.org/netdev/6adf9f64.6200f071.51519.0ed1.GAE@google.com/
[2] https://lore.kernel.org/netdev/20261105114707.3030737-1-bsdhenrymartin@gmail.com/
[3] https://lore.kernel.org/netdev/20261105114817.3033625-1-bsdhenrymartin@gmail.com/
Fixes: 8a4fc54b07d7 ("net: get rid of rtnl_lock_unregistering()")
Cc: stable@vger.kernel.org
Reported-by: syzbot+1269fe6cc2016008124e@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/netdev/6adf9f64.6200f071.51519.0ed1.GAE@google.com/
Reported-by: Henry Martin <bsdhenrymartin@gmail.com>
Closes: https://lore.kernel.org/netdev/20261105114707.3030737-1-bsdhenrymartin@gmail.com/
Closes: https://lore.kernel.org/netdev/20261105114817.3033625-1-bsdhenrymartin@gmail.com/
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Reviewed-by: Naman Gulati <namangulati@google.com>
Link: https://patch.msgid.link/20261105144543.1624238-1-edumazet@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index c29a22ca178f..4a4d72080acd 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -72,6 +72,7 @@ struct net {
unsigned int dev_base_seq; /* protected by rtnl_mutex */
atomic_t dev_mc_genid; /* dev->mc membership changes */
+ atomic_t dev_unreg_pending; /* devices in netdev_run_todo() */
u32 ifindex;
spinlock_t nsid_lock;
diff --git a/net/core/dev.c b/net/core/dev.c
index df1a840b0334..5d25b65e20dc 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -11101,6 +11101,14 @@ atomic_t dev_unreg_count = ATOMIC_INIT(0);
static void net_set_todo(struct net_device *dev)
{
list_add_tail(&dev->todo_list, &net_todo_list);
+ atomic_inc(&dev_net(dev)->dev_unreg_pending);
+}
+
+/* Paired with net_set_todo(). @net must not be used after this call. */
+static void net_unreg_done(struct net *net)
+{
+ if (atomic_dec_and_test(&net->dev_unreg_pending))
+ wake_up(&netdev_unregistering_wq);
}
static netdev_features_t netdev_sync_upper_features(struct net_device *lower,
@@ -12000,6 +12008,7 @@ void netdev_run_todo(void)
if (unlikely(dev->reg_state != NETREG_UNREGISTERING)) {
netdev_WARN(dev, "run_todo but not unregistering\n");
list_del(&dev->todo_list);
+ net_unreg_done(dev_net(dev));
continue;
}
@@ -12016,8 +12025,11 @@ void netdev_run_todo(void)
cnt = 0;
while (!list_empty(&list)) {
+ struct net *net;
+
dev = netdev_wait_allrefs_any(&list);
list_del(&dev->todo_list);
+ net = dev_net(dev);
/* paranoia */
BUG_ON(netdev_refcnt_read(dev) != 1);
@@ -12038,6 +12050,8 @@ void netdev_run_todo(void)
/* Free network device */
kobject_put(&dev->dev.kobj);
+
+ net_unreg_done(net);
}
if (cnt && atomic_sub_and_test(cnt, &dev_unreg_count))
wake_up(&netdev_unregistering_wq);
@@ -13486,6 +13500,17 @@ static void __net_exit default_device_exit_net(struct net *net)
}
}
+static bool __net_exit netns_dev_unreg_pending(const struct list_head *net_list)
+{
+ struct net *net;
+
+ list_for_each_entry(net, net_list, exit_list) {
+ if (atomic_read(&net->dev_unreg_pending))
+ return true;
+ }
+ return false;
+}
+
static void __net_exit default_device_exit_batch(struct list_head *net_list)
{
/* At exit all network devices most be removed from a network
@@ -13527,6 +13552,16 @@ static void __net_exit default_device_exit_batch(struct list_head *net_list)
unregister_netdevice_many(&dev_kill_list);
rtnl_unlock();
+ /* Devices of these netns unregistered from another context
+ * (e.g. a veth whose peer was deleted) can still be waiting
+ * in netdev_run_todo() for their last references, while
+ * NETDEV_UNREGISTER is rebroadcast for them. Wait for them
+ * before pernet exit handlers tear down the state used by
+ * netdevice notifiers, and before the netns is freed.
+ * No new unregistration can start: all devices are unlisted.
+ */
+ wait_event(netdev_unregistering_wq, !netns_dev_unreg_pending(net_list));
+
rtnl_net_flush_workqueue();
}
]
|
| 71/2 |
2026/11/24 01:11 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 241dec6f9ab74d8c3ef246764f3611666b96b9e1
Author: Joseph Kain <jkain@nuro.ai>
Date: Thu Oct 29 14:11:01 2026 -0700
net: stop defer_count outliving the deferred-free list
After the llist conversion, rejected frees retain their counter
increments. A producer racing the counter reset and list detach can
also leave a count for an skb already drained. Deferred freeing can
then remain disabled while the list is empty.
Undo rejected reservations and subtract only the number of skbs
drained. Allow admission up to the configured limit. Retain the
halfway notification and also notify when the reserved count reaches
the limit, covering reservations published after an earlier purge.
Fixes: 844c9db7f7f5 ("net: use llist for sd->defer_list")
Signed-off-by: Joseph Kain <jkain@nuro.ai>
Assisted-by: LLM
Signed-off-by: Dave Miller <davem@davem-thinkpadp1gen8.ibmlond.csb>
diff --git a/net/core/dev.c b/net/core/dev.c
index f32353b0467c..1ad5a47a4409 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -7073,16 +7073,22 @@ static void __skb_defer_free_flush(struct skb_defer_node *sdn, int budget)
{
struct llist_node *free_list;
struct sk_buff *skb, *next;
+ long n = 0;
if (llist_empty(&sdn->defer_list))
return;
- atomic_long_set(&sdn->defer_count, 0);
free_list = llist_del_all(&sdn->defer_list);
llist_for_each_entry_safe(skb, next, free_list, ll_node) {
prefetch(next);
napi_consume_skb(skb, budget);
+ n++;
}
+ /* Subtract exactly what was drained. Never store an absolute value:
+ * mixing one with the relative updates in skb_attempt_defer_free()
+ * lets the counter go negative, and it is read as unsigned there.
+ */
+ atomic_long_sub(n, &sdn->defer_count);
}
void skb_defer_node_flush(struct skb_defer_node *sdn)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 48f676411724..68192e477ff1 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -7499,8 +7499,14 @@ nodefer: kfree_skb_napi_cache(skb);
defer_max = READ_ONCE(net_hotdata.sysctl_skb_defer_max);
defer_count = atomic_long_inc_return(&sdn->defer_count);
- if (defer_count >= defer_max)
+ if (defer_count > defer_max) {
+ /* Undo the reservation. An llist_add() does not release one --
+ * the skb stays charged until a flush subtracts the batch that
+ * contains it -- so a rejected free must undo its own.
+ */
+ atomic_long_dec(&sdn->defer_count);
goto nodefer;
+ }
llist_add(&skb->ll_node, &sdn->defer_list);
@@ -7509,8 +7515,13 @@ nodefer: kfree_skb_napi_cache(skb);
return;
}
- /* Send an IPI every time queue reaches half capacity. */
- kick = (defer_count - 1) == (defer_max >> 1);
+ /* Half capacity, plus the skb that fills the queue. Equality alone can
+ * be consumed early -- if the producer holding the kick value publishes
+ * first, its purge drains only that skb and the reservations published
+ * after it match nothing -- which would leave a full queue with nothing
+ * pending.
+ */
+ kick = (defer_count - 1) == (defer_max >> 1) || defer_count == defer_max;
/* Make sure to trigger NET_RX_SOFTIRQ on the remote CPU
* if we are unlucky enough (this seems very unlikely).
]
|
| 72/2 |
2026/11/24 01:11 |
tool |
git-show |
0m
Args:
Results: map[Output:commit ef179363b04306dbc645c53207b9ad3516ebc75f
Author: Shakeel Butt <shakeel.butt@linux.dev>
Date: Tue Oct 27 07:32:47 2026 -0700
kernfs: avoid READ_ONCE() on a kgid_t in kernfs_new_node()
kernfs_new_node() reads the parent's gid with READ_ONCE(attrs->ia_gid).
That gid is a kgid_t, which is a struct.
On SMP alpha, READ_ONCE() ends by casting the value it loaded back to
the type of its argument. Here that is a cast from a struct to the same
struct. GCC accepts that as an extension, but ISO C does not allow a
cast to or from a struct type, so sparse warns:
fs/kernfs/dir.c:751:31: sparse: sparse: cast to non-scalar
fs/kernfs/dir.c:751:31: sparse: sparse: cast from non-scalar
Read the gid_t inside the kgid_t instead, and wrap it back up with
KGIDT_INIT(). This is still a single marked load of the same four bytes.
There is no functional change. With GCC 12 for alpha (the config from
the report) and GCC 14 for x86-64 (with and without KCSAN),
fs/kernfs/dir.o has the same object code before and after this change.
Fixes: 81bdc85b4c08 ("kernfs: fix up the unlocked attribute reads on the creation paths")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202610261608.vItiXCGW-lkp@intel.com/
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Acked-by: Tejun Heo <tj@kernel.org>
Link: https://patch.msgid.link/20261027143247.3537239-1-shakeel.butt@linux.dev
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 324d61a00545..800af10d9511 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -750,7 +750,7 @@ struct kernfs_node *kernfs_new_node(struct kernfs_node *parent,
struct kernfs_iattrs *attrs = READ_ONCE(parent->iattr);
if (attrs)
- gid = READ_ONCE(attrs->ia_gid);
+ gid = KGIDT_INIT(READ_ONCE(attrs->ia_gid.val));
if (flags & KERNFS_DIR)
mode |= S_ISGID;
]
|
| 73/2 |
2026/11/24 01:11 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 237557b8a81ab948e8332f7c0058e758f081c0a3
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: Wed May 20 15:05:04 2026 +0200
sysfs: don't remove existing directory on update failure
When sysfs_update_group() is called for a named group and create_files()
fails (e.g. -ENOMEM), internal_create_group() calls kernfs_remove(kn) on
the group directory. In the update path, kn was obtained via
kernfs_find_and_get() and refers to a directory that already existed
before this call. Removing it silently destroys a sysfs group that the
caller did not create.
Only remove the directory if we created it ourselves. On update failure
the directory remains as it is left empty by remove_files() inside
create_files(), but can be repopulated by a retry.
Cc: Rajat Jain <rajatja@google.com>
Fixes: c855cf2759d2 ("sysfs: Fix internal_create_group() for named group updates")
Cc: stable <stable@kernel.org>
Assisted-by: gkh_clanker_t1000
Reviewed-by: Rafael J. Wysocki (Intel) <rafael@kernel.org>
Reviewed-by: Danilo Krummrich <dakr@kernel.org>
Link: https://patch.msgid.link/2026052003-uniquely-hastily-c093@gregkh
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index 182e54e575ee..4e1e4f18a166 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -188,7 +188,7 @@ static int internal_create_group(struct kobject *kobj, int update,
kernfs_get(kn);
error = create_files(kn, kobj, uid, gid, grp, update);
if (error) {
- if (grp->name)
+ if (grp->name && !update)
kernfs_remove(kn);
}
kernfs_put(kn);
]
|
| 74/2 |
2026/11/24 01:11 |
llm |
cause-finder |
0m
Model:
Tokens:
input: 80528
output: 78
thoughts: 2092
Thoughts: **My Detailed Analysis of the Kernel Crash and Investigation**
Okay, I need to really dig into this. My primary goal here is to critically examine every single assertion made in the Root Cause Analysis (RCA) and determine if this is indeed an external memory corruption issue, or if there's a subtle local bug within our own codebase that I'm overlooking. The ultimate objective is to pinpoint the offending commit, if possible, or at least establish the most likely scenario with high confidence.
Let's break down the RCA's claims one by one and scrutinize them:
1. **Crash Location: `____rb_erase_color lib/rbtree.c:366 [inline]` and `rb_erase+0x168/0x3dc lib/rbtree.c:445`**
* The immediate cause of the trap is a `ldr r2, [r0]` instruction, where `r0` is `0x00000021`. This is happening right after `r3` (which was `0x8c5db278`) loaded `0x8c5db3d9` into `r2` and `0x8c5db3d8` into `ip`.
* The value `0x8c5db278` is identified as a pointer to a `kernfs_node` object within the `kernfs_node_cache` slab. This object starts at `0x8c5db268`, has a size of 88 bytes.
* The instruction `ldr r0, [r3, #8]` at line 365 of `lib/rbtree.c` is significant. This loads `r0` with `0x00000021`. Looking at the `struct kernfs_node` layout, offset 8 within the `rb` field (which is at offset 16) corresponds to `rb.rb_left`. This is crucial.
* The crash occurs at line 366: `if (!tmp1 || rb_is_black(tmp1))`. The `rb_is_black(tmp1)` call then attempts to dereference `tmp1` (which is `r0`, `0x00000021`) via `ldr r2, [r0]`. This is a NULL or invalid pointer dereference.
* Now, let's confirm the `struct rb_node` layout on 32-bit ARM. The `__rb_parent_color` is at offset 0, `rb_right` at offset 4, and `rb_left` at offset 8. So, indeed, `[r3, #8]` points to the `rb_left` field of the `rb` member of the `kernfs_node` pointed to by `r3`.
* The value `0x00000021` is what `rb_left` has been set to. This is the core of the problem.
2. **Why is `0x00000021` at `0x8c5db268 + 24` (which is `rb.rb_left`)?**
* My immediate thought is that `0x00000021` is **not** a valid kernel pointer. On this ARM kernel, `PAGE_OFFSET` is `0x80000000`, and all valid kernel addresses seem to be in the `0x8xxxxxxx` or `0xe0xxxxxx` range. `0x00000021` is far too small. It's also not `NULL`.
* Crucially, the `rb_left` and `rb_right` fields within `struct rb_node` are designed to hold either `NULL` or a 4-byte-aligned pointer to another `struct rb_node`. The color bits (`RB_BLACK` is `1`) are *only* stored in the `__rb_parent_color` field at offset 0. They are never mixed into the `rb_left` or `rb_right` pointer fields. Therefore, a value like `0x00000021` could **never** be legitimately written there by a correct rbtree operation. This strongly suggests memory corruption.
3. **Could `kernfs` have written `0x00000021` into offset 24 of `struct kernfs_node`?**
* I've re-checked the `struct kernfs_node` layout:
* `count` (0-3)
* `active` (4-7)
* `__parent` (8-11)
* `name` (12-15)
* `rb` (16-27): This is a 12-byte structure.
* `__rb_parent_color` (16-19)
* `rb_right` (20-23)
* `rb_left` (24-27)
* `ns` (28-31)
* `hash` (32-35)
* There are no unions or other fields in `struct kernfs_node` that would naturally place data at offset 24 of the `rb` member (which is `rb.rb_left`).
* Furthermore, all modifications to `kn->rb` and `dir.children` within `kernfs` are protected by `down_write(&root->kernfs_rwsem)`. This semaphore protection implies that `kernfs` operations themselves *shouldn't* be able to corrupt this field in such a way, especially not with an invalid pointer value.
* A critical point raised is the possibility of a Use-After-Free (UAF) or double-free. If `kernfs_put()` freed the `kernfs_node` at `0x8c5db268` *prematurely*, while it was still active and pointed to by something like `dir.children`, then a subsequent operation might attempt to use that freed memory.
* However, the `kernfs_put()` function has a `WARN_ONCE` at `fs/kernfs/dir.c:604` for precisely this scenario: `WARN_ONCE(1, "kernfs_put: ... released with incorrect active_ref ...")`. If this warning had triggered, the kernel would have been tainted with `W` (TAINT_WARN). The current oops shows `Tainted: [L]=SOFTLOCKUP`, but no `W`. This makes a direct UAF within `kernfs_put` itself less likely, or at least not flagged in the usual way.
* This leads me to consider more insidious corruption scenarios:
* **Slab Merging:** If `CONFIG_SLAB_MERGE_DEFAULT` is enabled, `kernfs_node_cache` might be merged with another slab cache. An object from *that* merged cache could be the culprit, either through its own UAF/OOB write or by corrupting an adjacent object in the merged slab.
* **Adjacent Object Overflow:** An object residing next to `0x8c5db268` in the slab (either within `kernfs_node_cache` or a merged cache) might have an out-of-bounds write that overflows into the `rb.rb_left` field of our target `kernfs_node`.
* **Earlier Owner UAF Write:** What if `0x8c5db268` was allocated as a `kernfs_node`, but its *previous* occupant in the slab cache (from a merged cache) had already performed a UAF write to offset 24, and that invalid data (`0x00000021`) just happened to still be there when `kernfs_node` took over the allocation?
4. **Could there be a known bug in `net/`, `fs/`, `drivers/`, `mm/`, etc., that explains this?**
* This is where the instruction to return an empty `CandidateCommits` list if confidence is low really resonates. I need to be absolutely sure. The instructions explicitly state: "If you cannot determine the commit with confidence, return an empty CandidateCommits list rather than guessing." And my reply must provide a "clear bisection log explaining the root cause... the git history you traced... commits examined... why you ruled out other commits, and how you reached your conclusion."
* So, I need to exhaust the possibilities of a determinable commit.
* I've re-verified:
* `struct rb_node` layout.
* Key `kernfs` functions like `sysfs_init`, `kernfs_rename_ns`, `kernfs_add_one`, `__kernfs_remove`, `kernfs_remove_self`.
* The specific interaction where `kobj` from networking (`netdev_rx_queue`) is involved. My analysis here is that `kobj` objects are allocated from `kmalloc-cg-512`, *not* `kernfs_node_cache`. The `kobj->sd` pointer (`0x86ef9200`) points to `0x8c5db688`, which is the `rx-0` `kernfs_node` being removed. The crashed `kernfs_node` is `0x8c5db268`, which is a *sibling* to `rx-0` within `queues->dir.children`. So, while networking code might *trigger* the removal of nodes, it's unlikely to be directly *writing* `0x00000021` into the `rb_left` field of a *different* `kernfs_node` unless there's a very complex interaction involving slab corruption.
My current thinking is that the `0x00000021` value strongly points to memory corruption outside of the standard `kernfs` tree manipulation logic. The lack of a `TAINT_WARN` makes a direct UAF in `kernfs_put` less likely, and the non-pointer value suggests something more fundamental like slab corruption, an adjacent object overflow, or a UAF write from a previous occupant of the slab slot. Without a clear signature of a specific function or path leading to this exact `0x00000021` corruption, committing to a single commit becomes highly speculative. I need more concrete evidence to confidently identify a specific commit or a sequence of events that *consistently* leads to this state. If I can't establish that, I must adhere to the instructions and return an empty list.
|
| 75/2 |
2026/11/24 01:11 |
tool |
codesearch-struct-layout |
0m
Args:
Results: map[Fields:[map[Name:__rb_parent_color OffsetBits:0 SizeBits:32] map[Name:rb_right OffsetBits:32 SizeBits:32] map[Name:rb_left OffsetBits:64 SizeBits:32]]]
|
| 76/2 |
2026/11/24 01:11 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode: 85: int __init sysfs_init(void)
86: {
87: int err;
88:
89: sysfs_root = kernfs_create_root(NULL, KERNFS_ROOT_EXTRA_OPEN_PERM_CHECK,
90: NULL);
91: if (IS_ERR(sysfs_root))
92: return PTR_ERR(sysfs_root);
93:
94: sysfs_root_kn = kernfs_root_to_node(sysfs_root);
95:
96: err = register_filesystem(&sysfs_fs_type);
97: if (err) {
98: kernfs_destroy_root(sysfs_root);
99: return err;
100: }
101:
102: return 0;
103: }
SourceFile:fs/sysfs/mount.c]
|
| 77/2 |
2026/11/24 01:11 |
tool |
codesearch-definition-source |
0m
Args: map[Name:kernfs_free_rcu]
Results: map[SourceCode: 568: static void kernfs_free_rcu(struct rcu_head *rcu)
569: {
570: struct kernfs_node *kn = container_of(rcu, struct kernfs_node, rcu);
571:
572: /* If the whole node goes away, then name can't be used outside */
573: kfree_const(rcu_access_pointer(kn->name));
574:
575: if (kn->iattr)
576: kmem_cache_free(kernfs_iattrs_cache, kn->iattr);
577:
578: kmem_cache_free(kernfs_node_cache, kn);
579: }
SourceFile:fs/kernfs/dir.c]
|
| 78/2 |
2026/11/24 01:11 |
llm |
cause-finder |
0m
Model:
Tokens:
input: 83294
output: 20
thoughts: 955
Thoughts: **My Deep Dive into the Kernel Crash: A Detective's Log**
Alright, let's break down this kernel crash, or rather, my thought process in dissecting it. It all started with this root cause analysis, and my immediate reaction was, "Does this hold water against the actual kernel source?" I immediately went to commit `f802b6558eb81bd5888d761a0cdc8afe5fd8c941` – the bedrock of my investigation.
My first point of scrutiny was how `____rb_erase_color()` within `rb_erase()`, itself called by `kernfs_unlink_sibling()`, was dereferencing `tmp1 = sibling->rb_left`. The analysis pointed to a specific memory address and an offset within a `struct kernfs_node`. My brain immediately went to the memory layout: `struct kernfs_node` is 88 bytes, and the `rb` member (a `struct rb_node`) is at offset 16. Within `struct rb_node`, `rb_left` is at offset 8. So, `0x8c5db268 + 24` is indeed `sibling_kn->rb.rb_left`. This part checked out. The critical observation was the trap: it was trying to load `tmp1->__rb_parent_color` with `r0` being `0x00000021`. That value, `0x00000021`, immediately screamed "WRONG!" to me. It's not a pointer, it's an odd value, and it's definitely not something the `lib/rbtree.c` or any part of `struct kernfs_node` itself should be writing to `__rb_parent_color` (which only holds color bits). This was a major red flag.
Then I started thinking about the context of these modifications. All manipulations of `dir.children` and `kn->rb` in `fs/kernfs/dir.c` (like `kernfs_link_sibling()`, `kernfs_unlink_sibling()`, etc.) are protected by `root->kernfs_rwsem`. This is a crucial synchronization mechanism. I also recalled how `sysfs_init()` creates `sysfs_root` *without* `KERNFS_ROOT_CREATE_DEACTIVATED`. This implies that every node in sysfs is active from the get-go and only deactivated and unlinked in `__kernfs_remove()` before a `kernfs_put()`. If there were a premature `kernfs_put()` on an active node within `queues->dir.children`, I'd expect to see a `WARN_ONCE` at `fs/kernfs/dir.c:604-607`, marking the kernel as `TAINT_WARN`. But the crash trace shows `Tainted: [L]=SOFTLOCKUP`, which means that warning isn't present. This further solidifies my suspicion that the issue isn't a simple race condition within the expected `kernfs` flow.
My next step was a thorough historical review. I meticulously examined the Git history of all the subsystems involved in the call trace: `net/core/net-sysfs.c`, `net/core/dev.c`, `fs/kernfs/`, `fs/sysfs/`, `drivers/net/bonding/`, and `lib/kobject.c`. I wasn't just looking at any commit; I was specifically targeting recent changes like `a9d60b086944`, `4424f06120fd`, `09452e5114bd`, `8b64f32fee95`, `e3b2cf6e5dba`, `c164a431a646`, `241dec6f9ab7`, `ef179363b043`, and `237557b8a81a`. My goal was to find any recent commit that could have introduced a bug that either corrupts `kernfs_node::rb.rb_left` or creates a race condition on `dir.children`. After this deep dive, I found no such culprit.
So, what's the conclusion? The crash itself, characterized by that invalid `0x00000021` value being loaded, isn't directly attributable to a logical bug within the `kernfs` or `rbtree` code as isolated in the provided trace. The lack of expected warnings and the successful validation against recent commits strongly suggest that the root cause lies *outside* the immediate scope of this crash dump. I'm thinking external memory corruption. This could be a use-after-free in a shared slab cache (especially a 88-byte one, which seems coincidental with `struct kernfs_node` size), an out-of-bounds write from an adjacent slab object, or some wild write that occurred during the preceding workload. Since the crash trace itself doesn't capture the origin of this external corruption (and KASAN wasn't enabled to help us), I can't confidently pinpoint a specific commit. Therefore, my decision is to be honest and not guess. We should report an empty `CandidateCommits` list.
Therefore, I'm instructing the system to call `set-results` with `CandidateCommits: []`.
|
| 79/2 |
2026/11/24 01:11 |
tool |
set-results |
0m
Args:
Results: map[CandidateCommits:<nil>]
|
| 80/2 |
2026/11/24 01:11 |
llm |
cause-finder |
0m
Model:
Tokens:
input: 84286
output: 1769
thoughts: 44
Thoughts: **My Comprehensive Verification of the Root Cause and Git History**
Alright, having thoroughly dug into this issue, I'm ready to articulate my findings. My primary objective was to definitively pinpoint the root cause of the problem. To achieve this, I undertook a meticulous examination of the Git history, scrutinizing various commits to understand their impact and potential contribution to the observed behavior.
My process involved systematically reviewing commits that appeared to be relevant, either chronologically or based on their perceived functional changes. For each commit I investigated, I asked myself: "Could this specific change have introduced the observed bug?" I analyzed the code modifications within these commits, looking for logical errors, incorrect assumptions, or unintended side effects that might manifest as the problem we're seeing.
However, a significant challenge emerged: despite this detailed review, I've been unable to confidently identify a single, specific commit that directly introduced the issue. This isn't to say there wasn't an introducing commit; rather, my analysis of the available information has led me to conclude that no single commit can be confidently identified as the culprit.
This lack of a clear, single introducing commit could stem from several factors. Perhaps the issue is the result of a subtle interaction between multiple changes, rather than a direct consequence of one isolated commit. It's also possible that the bug was introduced in a commit that, on the surface, appeared benign or even beneficial, making its role in the problem less obvious. Furthermore, the sheer volume of changes or the complexity of the codebase might obscure the precise moment the defect was introduced.
Therefore, while I've ruled out many individual commits as the *sole* or *obvious* cause, the absence of a definitive, confidence-inspiring introducing commit means I cannot, with certainty, point to a single change as the origin of this problem. My summary reflects this nuanced conclusion: the root cause verification is complete, the git history has been examined, specific commits have been evaluated and, where possible, ruled out, but the precise introducing commit remains elusive with the confidence I'd prefer.
|
| 81/1 |
2026/11/24 01:11 |
action |
format-bisect |
0m
Results: map[Commits:<nil> IsRelease:false]
|