mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2024-12-28 16:52:18 +00: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
1aefbedee7
commit
7bd439f024
@ -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