From d1a4549a3645e55cc9ade09e360280590b3c9559 Mon Sep 17 00:00:00 2001 From: Pavankumar Kondeti Date: Mon, 28 Sep 2026 09:25:46 +0530 Subject: workqueue: Fix NULL current_pwq deref in mem-reclaim helper 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 Signed-off-by: Tejun Heo --- kernel/workqueue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'kernel/workqueue.c') diff --git a/kernel/workqueue.c b/kernel/workqueue.c index c56c042d1c35..c1cb328bce3c 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); } -- cgit v1.2.3