linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
	David Rientjes <rientjes@google.com>,
	Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Oleg Nesterov <oleg@redhat.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] oom_reaper: don't call mmput_async() on uninitialized mm
Date: Mon, 30 May 2016 08:43:02 +0200	[thread overview]
Message-ID: <20160530064302.GA22928@dhcp22.suse.cz> (raw)
In-Reply-To: <20160527125534.b8be57b284599f5424512d09@linux-foundation.org>

On Fri 27-05-16 12:55:34, Andrew Morton wrote:
> On Fri, 27 May 2016 10:10:59 +0200 Michal Hocko <mhocko@kernel.org> wrote:
> 
> > On Fri 27-05-16 10:00:48, Arnd Bergmann wrote:
> > > The change to the oom_reaper to hold a mutex inside __oom_reap_task()
> > > accidentally started calling mmput_async() on the local
> > > mm before that variable got initialized, as reported by gcc
> > > in linux-next:
> > > 
> > > mm/oom_kill.c: In function '__oom_reap_task':
> > > mm/oom_kill.c:537:2: error: 'mm' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> > > 
> > > This rearranges the code slightly back to the state before patch
> > > but leaves the lock in place. The error handling in the function
> > > still looks a bit confusing and could probably be improved
> > > but I could not come up with a solution that made me happy
> > > for now.
> > > 
> > > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > > Fixes: mmotm ("oom_reaper: close race with exiting task")
> > 
> > Thanks for catching that Arnd?
> > 
> > Acked-by: Michal Hocko <mhocko@suse.com>
> 
> I think I preferred my version - all those unwinding return statements
> can cause problems..

looks good to me as well.

Thanks!

> --- a/mm/oom_kill.c~oom_reaper-close-race-with-exiting-task-fix
> +++ a/mm/oom_kill.c
> @@ -443,7 +443,7 @@ static bool __oom_reap_task(struct task_
>  {
>  	struct mmu_gather tlb;
>  	struct vm_area_struct *vma;
> -	struct mm_struct *mm;
> +	struct mm_struct *mm = NULL;
>  	struct task_struct *p;
>  	struct zap_details details = {.check_swap_entries = true,
>  				      .ignore_dirty = true};
> @@ -534,7 +534,8 @@ unlock_oom:
>  	 * different context because we shouldn't risk we get stuck there and
>  	 * put the oom_reaper out of the way.
>  	 */
> -	mmput_async(mm);
> +	if (mm)
> +		mmput_async(mm);
>  	return ret;
>  }
>  
> _

-- 
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

      reply	other threads:[~2016-05-30  6:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-27  8:00 Arnd Bergmann
2016-05-27  8:10 ` Michal Hocko
2016-05-27 19:55   ` Andrew Morton
2016-05-30  6:43     ` 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=20160530064302.GA22928@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=oleg@redhat.com \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=rientjes@google.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