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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE8F2ECAAD3 for ; Thu, 15 Sep 2022 02:06:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230103AbiIOCGp (ORCPT ); Wed, 14 Sep 2022 22:06:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230079AbiIOCGm (ORCPT ); Wed, 14 Sep 2022 22:06:42 -0400 Received: from out30-42.freemail.mail.aliyun.com (out30-42.freemail.mail.aliyun.com [115.124.30.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9F2A5B05D for ; Wed, 14 Sep 2022 19:06:40 -0700 (PDT) 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 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; >> } >> >>