All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mel Gorman <mgorman@techsingularity.net>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	linux-mm@kvack.org
Subject: Re: [bug report] mm, compaction: capture a page under direct compaction
Date: Fri, 28 Feb 2020 13:47:25 +0000	[thread overview]
Message-ID: <20200228134725.GK3818@techsingularity.net> (raw)
In-Reply-To: <18b0df3c-0589-d96c-23fa-040798fee187@suse.cz>

On Thu, Feb 27, 2020 at 08:45:46AM +0100, Vlastimil Babka wrote:

Bit late to the game but;

> ----8<----
> From 3118d9bea8a0fcef294915220f824674fb039ec3 Mon Sep 17 00:00:00 2001
> From: Vlastimil Babka <vbabka@suse.cz>
> Date: Wed, 26 Feb 2020 17:53:54 +0100
> Subject: [PATCH] mm, compaction: fully assume capture is not NULL in
>  compact_zone_order()
> 
> Dan reports:
> 
> The patch 5e1f0f098b46: "mm, compaction: capture a page under direct
> compaction" from Mar 5, 2019, leads to the following Smatch complaint:
> 
>     mm/compaction.c:2321 compact_zone_order()
>      error: we previously assumed 'capture' could be null (see line 2313)
> 
> mm/compaction.c
>   2288  static enum compact_result compact_zone_order(struct zone *zone, int order,
>   2289                  gfp_t gfp_mask, enum compact_priority prio,
>   2290                  unsigned int alloc_flags, int classzone_idx,
>   2291                  struct page **capture)
>                                       ^^^^^^^
> 
>   2313		if (capture)
>                     ^^^^^^^
> Check for NULL
> 
>   2314			current->capture_control = &capc;
>   2315
>   2316		ret = compact_zone(&cc, &capc);
>   2317
>   2318		VM_BUG_ON(!list_empty(&cc.freepages));
>   2319		VM_BUG_ON(!list_empty(&cc.migratepages));
>   2320
>   2321		*capture = capc.page;
>                 ^^^^^^^^
> Unchecked dereference.
> 
>   2322		current->capture_control = NULL;
>   2323
> 
> In practice this is not an issue, as the only caller path passes non-NULL
> capture:
> 
> __alloc_pages_direct_compact()
>   struct page *page = NULL;
>   try_to_compact_pages(capture = &page);
>     compact_zone_order(capture = capture);
> 
> So let's remove the unnecessary check, which should also make Smatch happy.
> 
> Fixes: 5e1f0f098b46 ("mm, compaction: capture a page under direct compaction")
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Suggested-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
> Cc: Mel Gorman <mgorman@techsingularity.net>

Acked-by: Mel Gorman <mgorman@techsingularity.net>

-- 
Mel Gorman
SUSE Labs


      reply	other threads:[~2020-02-28 13:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-24  6:35 [bug report] mm, compaction: capture a page under direct compaction Dan Carpenter
2020-02-26 17:04 ` Vlastimil Babka
2020-02-27  1:56   ` Andrew Morton
2020-02-27  7:45     ` Vlastimil Babka
2020-02-28 13:47       ` Mel Gorman [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=20200228134725.GK3818@techsingularity.net \
    --to=mgorman@techsingularity.net \
    --cc=akpm@linux-foundation.org \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-mm@kvack.org \
    --cc=vbabka@suse.cz \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.