mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 11:03:43 +02:00
get_task_exe_file: check PF_KTHREAD locklessly
Same thing as 8ac5dc6659 ("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: Mateusz Guzik <mjguzik@gmail.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
93b6bd4068
commit
51f8bd6db5
|
|
@ -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))
|
||||
exe_file = get_mm_exe_file(mm);
|
||||
}
|
||||
if (mm)
|
||||
exe_file = get_mm_exe_file(mm);
|
||||
task_unlock(task);
|
||||
return exe_file;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user