* [PATCH] mm/oom_kill: fix wild pointer in out_of_memory
@ 2021-03-13 4:23 Jiang Biao
2021-03-15 8:22 ` Michal Hocko
0 siblings, 1 reply; 2+ messages in thread
From: Jiang Biao @ 2021-03-13 4:23 UTC (permalink / raw)
To: akpm; +Cc: linux-mm, linux-kernel, robinlai, benbjiang
From: Bin Lai <robinlai@tencent.com>
From: Bin Lai <robinlai@tencent.com>
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.
Signed-off-by: Bin Lai <robinlai@tencent.com>
Reviewed-by: Jiang Biao <benbjiang@tencent.com>
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 9efaf43..0658a30 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -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);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/oom_kill: fix wild pointer in out_of_memory
2021-03-13 4:23 [PATCH] mm/oom_kill: fix wild pointer in out_of_memory Jiang Biao
@ 2021-03-15 8:22 ` Michal Hocko
0 siblings, 0 replies; 2+ messages in thread
From: Michal Hocko @ 2021-03-15 8:22 UTC (permalink / raw)
To: Jiang Biao; +Cc: akpm, linux-mm, linux-kernel, robinlai, benbjiang
On Sat 13-03-21 12:23:00, Jiang Biao wrote:
> From: Bin Lai <robinlai@tencent.com>
>
> From: Bin Lai <robinlai@tencent.com>
>
> 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.
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.
>
> Signed-off-by: Bin Lai <robinlai@tencent.com>
> Reviewed-by: Jiang Biao <benbjiang@tencent.com>
>
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> index 9efaf43..0658a30 100644
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -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);
> --
> 1.8.3.1
>
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-15 8:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-13 4:23 [PATCH] mm/oom_kill: fix wild pointer in out_of_memory Jiang Biao
2021-03-15 8:22 ` Michal Hocko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).