linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.com>
To: Jiang Biao <benbjiang@gmail.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, robinlai@tencent.com,
	benbjiang@tencent.com
Subject: Re: [PATCH] mm/oom_kill: fix wild pointer in out_of_memory
Date: Mon, 15 Mar 2021 09:22:07 +0100	[thread overview]
Message-ID: <YE8ZL8VTllD5RLOf@dhcp22.suse.cz> (raw)
In-Reply-To: <20210313042300.3833-1-benbjiang@gmail.com>

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

      reply	other threads:[~2021-03-15  8:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YE8ZL8VTllD5RLOf@dhcp22.suse.cz \
    --to=mhocko@suse.com \
    --cc=akpm@linux-foundation.org \
    --cc=benbjiang@gmail.com \
    --cc=benbjiang@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=robinlai@tencent.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).