diff options
| author | Karl Mehltretter <kmehltretter@gmail.com> | 2026-08-27 06:17:08 +0200 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-08-27 22:50:06 -0700 |
| commit | dbc01ec641c0fad6e17b0483432eae337e7487e3 (patch) | |
| tree | 28182095d47fc17ec8825c9517c63262bac45dce /scripts/objdiff | |
| parent | 32a7cc3c9a814e6e2689badef227f8cb3b6b672f (diff) | |
| download | linux-next-dbc01ec641c0fad6e17b0483432eae337e7487e3.tar.gz linux-next-dbc01ec641c0fad6e17b0483432eae337e7487e3.zip | |
klist: avoid accesses after waking klist_remove()
klist_remove() waits until a node is unreferenced so that its caller can
free the containing object. klist_release() currently publishes
waiter->woken and wakes the waiter before its final accesses to the waiter
and node. klist_remove() can then return, allowing its stack waiter and
the containing object to be freed or reused while klist_release() is still
running. In particular, bus_remove_driver() can free drv->p while
__device_attach() walks the same bus klist with bus_for_each_drv().
On an arm64 Cortex-A72 system, an unpatched 7.2.0-rc3 kernel with
CONFIG_PREEMPT_RT=y and CONFIG_KASAN=y reproduced the bug through the
in-tree I2C/at24 path. KASAN reported a use-after-free in
klist_dec_and_del() reached from klist_next()/bus_for_each_drv() while
at24 was being unregistered.
Clear n_klist and take a task reference before publishing woken. Use
release/acquire accesses for that publication and wake the referenced
task. The task reference keeps the waiter task alive if it returns and
exits before wake_up_process().
Link: https://lore.kernel.org/20260827041708.31682-1-kmehltretter@gmail.com
Fixes: 8b0c250be489 ("[PATCH] add klist_node_attached() to determine if a node is on a list or not.")
Fixes: 210272a28465 ("driver core: Remove completion from struct klist_node")
Assisted-by: LLM
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
Cc: Danilo Krummrich <dakr@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'scripts/objdiff')
0 files changed, 0 insertions, 0 deletions
