From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE2E3C433EF for ; Fri, 6 May 2022 08:59:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 504056B0075; Fri, 6 May 2022 04:59:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4B4426B0078; Fri, 6 May 2022 04:59:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A44C6B007B; Fri, 6 May 2022 04:59:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2B9FD6B0075 for ; Fri, 6 May 2022 04:59:55 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id F246F2CFD0 for ; Fri, 6 May 2022 08:59:54 +0000 (UTC) X-FDA: 79434720750.08.EE4A8D6 Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by imf23.hostedemail.com (Postfix) with ESMTP id B20F2140046 for ; Fri, 6 May 2022 08:59:43 +0000 (UTC) Date: Fri, 6 May 2022 17:59:45 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1651827592; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=It468l5rDEjybV0iEao8CQ9t2I1qPohrUTy4neYSFfI=; b=gMcCaOMa4f7ms4z9s1DlZwbAaxS3JIJuSSdco/SY0xMK04TyV99mSm2uLjZYJdxtnf/y4M U+BoYDzNv42p2crlpa24TtUUBBSlVyaqW5TjkEYeOU62jXg1sZBnjSf5OmHySayuYlzH1H 22lIC6qsakbGf0JWoPi2/rMlVG8r5/I= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Naoya Horiguchi To: zhenwei pi Cc: akpm@linux-foundation.org, naoya.horiguchi@nec.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wu Fengguang Subject: Re: [PATCH 4/4] mm/memofy-failure.c: add hwpoison_filter for soft offline Message-ID: <20220506085945.GD1356094@u2004> References: <20220429142206.294714-1-pizhenwei@bytedance.com> <20220429142206.294714-5-pizhenwei@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220429142206.294714-5-pizhenwei@bytedance.com> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=gMcCaOMa; spf=pass (imf23.hostedemail.com: domain of naoya.horiguchi@linux.dev designates 91.121.223.63 as permitted sender) smtp.mailfrom=naoya.horiguchi@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: B20F2140046 X-Stat-Signature: oyqug5dfpts3n1gbdnao7m6g4wd6zic6 X-HE-Tag: 1651827583-826007 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Apr 29, 2022 at 10:22:06PM +0800, zhenwei pi wrote: > 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. The motivation is fine to me. Thank you for finding this. > > Cc: Wu Fengguang > Signed-off-by: zhenwei pi > --- > 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 Using word hwpoison_filter() rather than memory_filter() seems better to me. > + * < 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; > + } > + Based on the assumption behind hwpoison_filter(), calling it after get_hwpoison_page() would be better? Thanks, Naoya Horiguchi