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 5082FECAAD8 for ; Thu, 15 Sep 2022 02:06:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CC8DD6B0074; Wed, 14 Sep 2022 22:06:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C78AA8D0002; Wed, 14 Sep 2022 22:06:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B41308D0001; Wed, 14 Sep 2022 22:06:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A6B426B0074 for ; Wed, 14 Sep 2022 22:06:42 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 830F51407B2 for ; Thu, 15 Sep 2022 02:06:42 +0000 (UTC) X-FDA: 79912681044.25.3AE2A8F Received: from out30-44.freemail.mail.aliyun.com (out30-44.freemail.mail.aliyun.com [115.124.30.44]) by imf12.hostedemail.com (Postfix) with ESMTP id 3F1C3400C2 for ; Thu, 15 Sep 2022 02:06:40 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=xueshuai@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0VPqfvKR_1663207594; Received: from 30.240.121.31(mailfrom:xueshuai@linux.alibaba.com fp:SMTPD_---0VPqfvKR_1663207594) by smtp.aliyun-inc.com; Thu, 15 Sep 2022 10:06:38 +0800 Message-ID: Date: Thu, 15 Sep 2022 10:06:33 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH] mm,hwpoison: check mm when killing accessing process Content-Language: en-US To: Miaohe Lin Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, cuibixuan@linux.alibaba.com, baolin.wang@linux.alibaba.com, zhuo.song@linux.alibaba.com, naoya.horiguchi@nec.com, akpm@linux-foundation.org References: <20220914064935.7851-1-xueshuai@linux.alibaba.com> <51eb9735-349e-db8b-fa1c-096a924ef520@huawei.com> From: Shuai Xue In-Reply-To: <51eb9735-349e-db8b-fa1c-096a924ef520@huawei.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663207602; a=rsa-sha256; cv=none; b=cJx4GgKDPaN/Nk+fRhvpllXL6xeBHfaVbOwelI9ZocYUwZ4j6UHguoy6m7QRKTZyyqamFk UHUcszl/qCyuOtkMoXqA3DSJAKCfdWO2bIRJZKR6QOE2vbYjL5EGCLRjT5FwNiFv+2ItdY MB7w+3rzjMG40dgMv/xJ5tkn0dOuFoI= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf12.hostedemail.com: domain of xueshuai@linux.alibaba.com designates 115.124.30.44 as permitted sender) smtp.mailfrom=xueshuai@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663207602; 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=HgHjMqYzlsGplCDelqNFI9LEwgx4NHiMOXCqOSa3tJo=; b=0MJtqilu83uoF9S4wSvkG11TmvwgNanL5vch3JfdQ5+fpZLaCOERa3Bwm6qQXKQsFjvR+H /+SezXDqUjwTv8a3qJPi9dePVIz0dYmtD7xeXtYM4INjmvTEXrrPVWsvqorfDmpmcbo20t 5Ve7kx3/y/GylmOUItAk/uG5Pdz85Do= X-Stat-Signature: uo57qokurpo8d9rqgowxijqzgrs7gej4 X-Rspamd-Queue-Id: 3F1C3400C2 X-Rspam-User: Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf12.hostedemail.com: domain of xueshuai@linux.alibaba.com designates 115.124.30.44 as permitted sender) smtp.mailfrom=xueshuai@linux.alibaba.com X-Rspamd-Server: rspam02 X-HE-Tag: 1663207600-843409 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: 在 2022/9/15 AM9:45, Miaohe Lin 写道: > 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 Thank you for your review. Cheers, Shuai > > >> --- >> 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; >> } >> >>