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 7C7CFC6FA82 for ; Thu, 15 Sep 2022 01:45:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EBD296B0071; Wed, 14 Sep 2022 21:45:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E46D96B0073; Wed, 14 Sep 2022 21:45:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE66F8D0001; Wed, 14 Sep 2022 21:45:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B97DE6B0071 for ; Wed, 14 Sep 2022 21:45:23 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 91FE8160350 for ; Thu, 15 Sep 2022 01:45:23 +0000 (UTC) X-FDA: 79912627326.16.C9D5371 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf28.hostedemail.com (Postfix) with ESMTP id 3E762C00CA for ; Thu, 15 Sep 2022 01:45:21 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MSfzX6mKjzNm7G; Thu, 15 Sep 2022 09:40:40 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 15 Sep 2022 09:45:16 +0800 Subject: Re: [PATCH] mm,hwpoison: check mm when killing accessing process To: Shuai Xue CC: , , , , , , References: <20220914064935.7851-1-xueshuai@linux.alibaba.com> From: Miaohe Lin Message-ID: <51eb9735-349e-db8b-fa1c-096a924ef520@huawei.com> Date: Thu, 15 Sep 2022 09:45:16 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20220914064935.7851-1-xueshuai@linux.alibaba.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663206321; a=rsa-sha256; cv=none; b=1msWehDANUz9L0av/s6Z4kCgFl5weKno9YDq0kqXgiWRxoTi53vFyrJ3vLXqMv0XupAXSe 45rsEX2Vm4VXtDibM3+WKj9WAfe43lMYj60SUXnO+2A4fPHKp1xHCZQX7NAg85uGCbDdFK IcY1CBGd+iPFxYxD85Ctzkh+GfakQzs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663206321; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6MirzViAek46SkMOVwPCTIOcC68pRWWO5hBRwl7ycCw=; b=k91iBgNIUj82ZUr3GZeELgE6ll9LS90jbgR4r/g/bLkaM51Dc1Gilc9nEBuQ22Gw+067sT 6sw525T7N5WxbNHXKDSDsLOQ3PY5jaTjHmxUzPY3eSZ+SvP31+Qgl5ZzY2JlLr+BuBIyys 5lRpTGl8y+ncGaeIK8zwD2GAzbWeylk= X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 3E762C00CA X-Rspam-User: Authentication-Results: imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Stat-Signature: f1zx77nr5j3zs78jhfi4b8dwyzgfow3q X-HE-Tag: 1663206321-356250 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 2022/9/14 14:49, Shuai Xue wrote: > The GHES code calls memory_failure_queue() from IRQ context to queue work > into workqueue and schedule it on the current CPU. Then the work is > processed in memory_failure_work_func() by kworker and calls > memory_failure(). > > When a page is already poisoned, commit a3f5d80ea401 ("mm,hwpoison: send > SIGBUS with error virutal address") make memory_failure() call > kill_accessing_process() that: > > - holds mmap locking of current->mm > - does pagetable walk to find the error virtual address > - and sends SIGBUS to the current process with error info. > > However, the mm of kworker is not valid. Therefore, check mm when killing > accessing process. > > Fixes: a3f5d80ea401 ("mm,hwpoison: send SIGBUS with error virutal address") > Signed-off-by: Shuai Xue Thanks for fixing. Reviewed-by: Miaohe Lin Thanks, Miaohe Lin > --- > mm/memory-failure.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index 14439806b5ef..7553917ce820 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -743,6 +743,9 @@ static int kill_accessing_process(struct task_struct *p, unsigned long pfn, > }; > priv.tk.tsk = p; > > + if (!p->mm) > + return -EFAULT; > + > mmap_read_lock(p->mm); > ret = walk_page_range(p->mm, 0, TASK_SIZE, &hwp_walk_ops, > (void *)&priv); > @@ -751,6 +754,7 @@ static int kill_accessing_process(struct task_struct *p, unsigned long pfn, > else > ret = 0; > mmap_read_unlock(p->mm); > + > return ret > 0 ? -EHWPOISON : -EFAULT; > } > >