Skip to content

Commit b3f9916

Browse files
committed
sched: Update task_tick_numa to ignore tasks without an mm
Qian Cai <[email protected]> wrote: > Reverting the last 3 commits of the series fixed a boot crash. > > 1b2552c fork: Stop allowing kthreads to call execve > 753550e fork: Explicitly set PF_KTHREAD > 68d85f0 init: Deal with the init process being a user mode process > > BUG: KASAN: null-ptr-deref in task_nr_scan_windows.isra.0 > arch_atomic_long_read at ./include/linux/atomic/atomic-long.h:29 > (inlined by) atomic_long_read at ./include/linux/atomic/atomic-instrumented.h:1266 > (inlined by) get_mm_counter at ./include/linux/mm.h:1996 > (inlined by) get_mm_rss at ./include/linux/mm.h:2049 > (inlined by) task_nr_scan_windows at kernel/sched/fair.c:1123 > Read of size 8 at addr 00000000000003d0 by task swapper/0/1 With the change to init and the user mode helper processes to not have PF_KTHREAD set before they call kernel_execve the PF_KTHREAD test in task_tick_numa became insufficient to detect all tasks that have "->mm == NULL". Correct that by testing for "->mm == NULL" directly. Reported-by: Qian Cai <[email protected]> Tested-by: Qian Cai <[email protected]> Fixes: 1b2552c ("fork: Stop allowing kthreads to call execve") Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent 1b2552c commit b3f9916

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/sched/fair.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2915,7 +2915,7 @@ static void task_tick_numa(struct rq *rq, struct task_struct *curr)
29152915
/*
29162916
* We don't care about NUMA placement if we don't have memory.
29172917
*/
2918-
if ((curr->flags & (PF_EXITING | PF_KTHREAD)) || work->next != work)
2918+
if (!curr->mm || (curr->flags & (PF_EXITING | PF_KTHREAD)) || work->next != work)
29192919
return;
29202920

29212921
/*

0 commit comments

Comments
 (0)