mm/oom_kill: fix wild pointer in out_of_memory
Subsystems (2)
PATCH 1/1 mm/oom_kill: fix wild pointer in out_of_memory
From: Bin Lai <[email protected]>
From: Bin Lai <[email protected]>
The oc->chosen is used by oom implementation, and the caller does not initialize this variable. If the tasks of memcg are all unkillable, oom_evaluate_task cann't choose any task, and the oc->chosen will be a wild pointer. So we should initialize oc->chosen before calling oom_evaluate_task.
mm/oom_kill.c +1 -0
@@ -366,6 +366,7 @@ static int oom_evaluate_task(struct task_struct *task, void *arg)static void select_bad_process (struct oom_control *oc) { oc->chosen_points =LONG_MIN ; + oc->chosen =NULL ;if (is_memcg_oom (oc))mem_cgroup_scan_tasks (oc->memcg, oom_evaluate_task, oc);
Signature · 1 line
1.8.3.1
Michal Hocko
maintainerQuoted 9 lines · Jiang Biao
From: Bin Lai <[email protected]>
From: Bin Lai <[email protected]>
The
oc->chosenis used by oom implementation, and the caller does not initialize this variable. If the tasks of memcg are all unkillable,oom_evaluate_taskcann't choose any task, and theoc->chosenwill be a wild pointer. So we should initializeoc->chosenbefore callingoom_evaluate_task.
All callers do initialize oom_control on the stack and even partial structure initialization on stack will result in the zeroying of all other structure's element. So I do not think there is any problem.
Quoted 19 lines
Signed-off-by Bin Lai <[email protected]>Reviewed-by Jiang Biao <[email protected]>mm/oom_kill.c +1
-0@@ -366,6 +366,7 @@ static int oom_evaluate_task(struct task_struct *task, void *arg)static void select_bad_process (struct oom_control *oc) { oc->chosen_points =LONG_MIN ; + oc->chosen =NULL ;if (is_memcg_oom (oc))mem_cgroup_scan_tasks (oc->memcg, oom_evaluate_task, oc);Signature · 1 line
1.8.3.1
Signature · 2 lines
Michal Hocko SUSE Labs