From: <gregkh@linuxfoundation.org>
To: david@redhat.com,gregkh@linuxfoundation.org,linux-mm@kvack.org,liqiong@nfschina.com
Cc: <stable-commits@vger.kernel.org>
Subject: Patch "mm: fix dereference a null pointer in migrate[_huge]_page_move_mapping()" has been added to the 4.19-stable tree
Date: Thu, 17 Mar 2022 11:27:15 +0100 [thread overview]
Message-ID: <164751283597127@kroah.com> (raw)
In-Reply-To: <20220217115416.55835-1-liqiong@nfschina.com>
This is a note to let you know that I've just added the patch titled
mm: fix dereference a null pointer in migrate[_huge]_page_move_mapping()
to the 4.19-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
mm-fix-dereference-a-null-pointer-in-migrate_page_move_mapping.patch
and it can be found in the queue-4.19 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.
From liqiong@nfschina.com Thu Mar 17 11:25:02 2022
From: liqiong <liqiong@nfschina.com>
Date: Thu, 17 Feb 2022 19:54:16 +0800
Subject: mm: fix dereference a null pointer in migrate[_huge]_page_move_mapping()
To: david@redhat.com, gregkh@linuxfoundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, liqiong <liqiong@nfschina.com>, stable@vger.kernel.org
Message-ID: <20220217115416.55835-1-liqiong@nfschina.com>
From: liqiong <liqiong@nfschina.com>
Upstream doesn't use radix tree any more in migrate.c, no need this patch.
The two functions look up a slot and dereference the pointer,
If the pointer is null, the kernel would crash and dump.
The 'numad' service calls 'migrate_pages' periodically. If some slots
being replaced (Cache Eviction), the radix_tree_lookup_slot() returns
a null pointer that causes kernel crash.
"numad": crash> bt
[exception RIP: migrate_page_move_mapping+337]
Introduce pointer checking to avoid dereference a null pointer.
Cc: <stable@vger.kernel.org> # linux-4.19.y
Signed-off-by: liqiong <liqiong@nfschina.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
mm/migrate.c | 8 ++++++++
1 file changed, 8 insertions(+)
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -472,6 +472,10 @@ int migrate_page_move_mapping(struct add
pslot = radix_tree_lookup_slot(&mapping->i_pages,
page_index(page));
+ if (pslot == NULL) {
+ xa_unlock_irq(&mapping->i_pages);
+ return -EAGAIN;
+ }
expected_count += hpage_nr_pages(page) + page_has_private(page);
if (page_count(page) != expected_count ||
@@ -590,6 +594,10 @@ int migrate_huge_page_move_mapping(struc
xa_lock_irq(&mapping->i_pages);
pslot = radix_tree_lookup_slot(&mapping->i_pages, page_index(page));
+ if (pslot == NULL) {
+ xa_unlock_irq(&mapping->i_pages);
+ return -EAGAIN;
+ }
expected_count = 2 + page_has_private(page);
if (page_count(page) != expected_count ||
Patches currently in stable-queue which might be from liqiong@nfschina.com are
queue-4.19/mm-fix-dereference-a-null-pointer-in-migrate_page_move_mapping.patch
prev parent reply other threads:[~2022-03-17 10:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-17 6:38 [PATCH] mm: fix dereference a null pointer in migrate[_huge]_page_move_mapping() liqiong
2022-02-17 7:29 ` Greg KH
2022-02-17 7:51 ` David Hildenbrand
2022-02-17 8:48 ` 李力琼
2022-02-17 8:56 ` David Hildenbrand
2022-02-17 7:59 ` 李力琼
2022-02-17 8:39 ` 李力琼
2022-02-17 11:54 ` [PATCH] [PATCH 4.19 STABLE] " liqiong
2022-03-17 10:26 ` Greg KH
2022-03-17 10:27 ` gregkh [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=164751283597127@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=david@redhat.com \
--cc=linux-mm@kvack.org \
--cc=liqiong@nfschina.com \
--cc=stable-commits@vger.kernel.org \
/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.