From: zhenwei pi <pizhenwei@bytedance.com>
To: akpm@linux-foundation.org, naoya.horiguchi@nec.com
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
zhenwei pi <pizhenwei@bytedance.com>,
Wu Fengguang <fengguang.wu@intel.com>
Subject: [PATCH 4/4] mm/memofy-failure.c: add hwpoison_filter for soft offline
Date: Fri, 29 Apr 2022 22:22:06 +0800 [thread overview]
Message-ID: <20220429142206.294714-5-pizhenwei@bytedance.com> (raw)
In-Reply-To: <20220429142206.294714-1-pizhenwei@bytedance.com>
hwpoison_filter is missing in the soft offline path, this leads an
issue: after enabling the corrupt filter, the user process still has
a chance to inject hwpoison fault by
madvise(addr, len, MADV_SOFT_OFFLINE) at PFN which is expected to
reject.
Cc: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
---
mm/memory-failure.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index a6a27c8b800f..6564f5a34658 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -2313,7 +2313,9 @@ static void put_ref_page(struct page *page)
* @pfn: pfn to soft-offline
* @flags: flags. Same as memory_failure().
*
- * Returns 0 on success, otherwise negated errno.
+ * Returns 0 on success
+ * -EOPNOTSUPP for memory_filter() filtered the error event
+ * < 0 otherwise negated errno.
*
* Soft offline a page, by migration or invalidation,
* without killing anything. This is for the case when
@@ -2350,6 +2352,11 @@ int soft_offline_page(unsigned long pfn, int flags)
return -EIO;
}
+ if (hwpoison_filter(page)) {
+ put_ref_page(ref_page);
+ return -EOPNOTSUPP;
+ }
+
mutex_lock(&mf_mutex);
if (PageHWPoison(page)) {
--
2.20.1
next prev parent reply other threads:[~2022-04-29 14:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-29 14:22 [PATCH 0/4] memory-failure: fix hwpoison_filter zhenwei pi
2022-04-29 14:22 ` [PATCH 1/4] mm/memory-failure.c: move clear_hwpoisoned_pages zhenwei pi
2022-05-06 8:55 ` Naoya Horiguchi
2022-04-29 14:22 ` [PATCH 2/4] mm/memofy-failure.c:: simplify num_poisoned_pages_dec zhenwei pi
2022-05-06 8:55 ` Naoya Horiguchi
2022-04-29 14:22 ` [PATCH 3/4] mm/memofy-failure.c: optimize hwpoison_filter zhenwei pi
2022-05-06 8:59 ` Naoya Horiguchi
2022-05-06 13:38 ` zhenwei pi
2022-05-06 16:28 ` David Hildenbrand
2022-05-07 0:28 ` zhenwei pi
2022-05-07 8:20 ` Naoya Horiguchi
2022-05-07 9:19 ` zhenwei pi
2022-04-29 14:22 ` zhenwei pi [this message]
2022-05-06 8:59 ` [PATCH 4/4] mm/memofy-failure.c: add hwpoison_filter for soft offline Naoya Horiguchi
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=20220429142206.294714-5-pizhenwei@bytedance.com \
--to=pizhenwei@bytedance.com \
--cc=akpm@linux-foundation.org \
--cc=fengguang.wu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=naoya.horiguchi@nec.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).