linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hugh Dickins <hughd@google.com>
To: Sasha Levin <sasha.levin@oracle.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Konstantin Khlebnikov <koct9i@gmail.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Hugh Dickins <hughd@google.com>,
	Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>,
	Mel Gorman <mgorman@suse.de>
Subject: Re: mm: NULL ptr deref in migrate_page_move_mapping
Date: Mon, 22 Sep 2014 16:04:43 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LSU.2.11.1409221531570.1244@eggly.anvils> (raw)
In-Reply-To: <5420407E.8040406@oracle.com>

On Mon, 22 Sep 2014, Sasha Levin wrote:
> 
> 	int migrate_page_move_mapping(struct address_space *mapping,
> 	                struct page *newpage, struct page *page,
> 	                struct buffer_head *head, enum migrate_mode mode,
> 	                int extra_count)
> 	{
> 	        int expected_count = 1 + extra_count;
> 	        void **pslot;
> 	
> 	        if (!mapping) {
> 	                /* Anonymous page without mapping */
> 	                if (page_count(page) != expected_count)
> 	                        return -EAGAIN;
> 	                return MIGRATEPAGE_SUCCESS;
> 	        }
> 	
> 	        spin_lock_irq(&mapping->tree_lock);
> 	
> 	        pslot = radix_tree_lookup_slot(&mapping->page_tree,
> 	                                        page_index(page));  <==== Returned NULL
> 	
> 	        expected_count += 1 + page_has_private(page);
> 	        if (page_count(page) != expected_count ||
> 	                radix_tree_deref_slot_protected(pslot, &mapping->tree_lock) != page) { <==== Dereferenced that NULL
> 	                spin_unlock_irq(&mapping->tree_lock);
> 	                return -EAGAIN;
> 	        }
> 
> I don't think it's just a missing '!= NULL' check

I agree: we have had this page locked since before the
mapping = page_mapping(page), so it ought to be in its radix_tree.

Though if we believe that argument, then am I not implying that the
"radix_blah() != page" check is redundant?  Hmm, perhaps someone can
see why it is needed, in which case that might give a hint on the crash.

But my suspicion is that it's just for safety: it corresponds to the
original "*radix_pointer != page" check in the first mm/migrate.c in
2.6.17, which may be there just so as not to rely so heavily on mm
locking protocols enforced elsewhere.

> but I'm not sure what went wrong.

Most likely would be a zeroing of the radix_tree node, just as you
were experiencing zeroing of other mm structures in earlier weeks.

Not that I've got any suggestions on where to take it from there.

Hugh

--
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:[~2014-09-22 23:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-22 15:30 Sasha Levin
2014-09-22 23:04 ` Hugh Dickins [this message]
2014-09-22 23:49   ` Sasha Levin
2014-09-27  3:02   ` Sasha Levin
2014-09-27  7:01     ` Andrey Ryabinin

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=alpine.LSU.2.11.1409221531570.1244@eggly.anvils \
    --to=hughd@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=koct9i@gmail.com \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=n-horiguchi@ah.jp.nec.com \
    --cc=sasha.levin@oracle.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