* [PATCH] workqueue: Fix NULL current_pwq deref in mem-reclaim helper
@ 2026-09-28 3:55 Pavankumar Kondeti
2026-09-28 18:18 ` Tejun Heo
0 siblings, 1 reply; 2+ messages in thread
From: Pavankumar Kondeti @ 2026-09-28 3:55 UTC (permalink / raw)
To: Tejun Heo, Lai Jiangshan, Trond Myklebust, Mike Snitzer
Cc: linux-kernel, Pavankumar Kondeti
current_is_workqueue_mem_reclaim() uses current_wq_worker() to decide
whether %current is a workqueue worker and then checks the current
workqueue flags. However, current_wq_worker() only implies that %current
is a kworker; it does not imply that the worker is currently executing a
work item.
worker->current_pwq is set while process_one_work() runs the work
function and cleared afterwards. A kworker outside work-item execution can
therefore have PF_WQ_WORKER set with current_pwq cleared.
Guard the flag check with worker->current_pwq. Without a current_pwq, the
worker is not executing on a WQ_MEM_RECLAIM workqueue, so the helper
should return false.
Fixes: da729ddd4a1b ("NFS/localio: issue IO inline when not in a memory-reclaim context")
Signed-off-by: Pavankumar Kondeti <pavan.kondeti@oss.qualcomm.com>
---
kernel/workqueue.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 959525393739..3d0497639e79 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -6320,7 +6320,7 @@ bool current_is_workqueue_mem_reclaim(void)
{
struct worker *worker = current_wq_worker();
- return worker &&
+ return worker && worker->current_pwq &&
((worker->current_pwq->wq->flags &
(WQ_MEM_RECLAIM | __WQ_LEGACY)) == WQ_MEM_RECLAIM);
}
---
base-commit: 72d3fcf802c45d00b300f25b848a93c3a2bd7c7e
change-id: 20260928-wq_mem_reclaim_fix-39b357dfa4f0
Best regards,
--
Pavankumar Kondeti <pavan.kondeti@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-28 18:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-28 3:55 [PATCH] workqueue: Fix NULL current_pwq deref in mem-reclaim helper Pavankumar Kondeti
2026-09-28 18:18 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®