Commit 51f8bd6d authored by Mateusz Guzik's avatar Mateusz Guzik Committed by Andrew Morton
Browse files

get_task_exe_file: check PF_KTHREAD locklessly

Same thing as 8ac5dc66 ("get_task_mm: check PF_KTHREAD lockless")

Nowadays PF_KTHREAD is sticky and it was never protected by ->alloc_lock. 
Move the PF_KTHREAD check outside of task_lock() section to make this code
more understandable.

Link: https://lkml.kernel.org/r/20241119143526.704986-1-mjguzik@gmail.com


Signed-off-by: default avatarMateusz Guzik <mjguzik@gmail.com>
Acked-by: default avatarOleg Nesterov <oleg@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 93b6bd40
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -1514,12 +1514,13 @@ struct file *get_task_exe_file(struct task_struct *task)
	struct file *exe_file = NULL;
	struct mm_struct *mm;

	if (task->flags & PF_KTHREAD)
		return NULL;

	task_lock(task);
	mm = task->mm;
	if (mm) {
		if (!(task->flags & PF_KTHREAD))
	if (mm)
		exe_file = get_mm_exe_file(mm);
	}
	task_unlock(task);
	return exe_file;
}