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 3641BECAAD3 for ; Thu, 15 Sep 2022 01:37:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8792F6B0071; Wed, 14 Sep 2022 21:37:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 827F88D0002; Wed, 14 Sep 2022 21:37:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6EF4C8D0001; Wed, 14 Sep 2022 21:37:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 5CBE56B0071 for ; Wed, 14 Sep 2022 21:37:09 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 36E6412010A for ; Thu, 15 Sep 2022 01:37:09 +0000 (UTC) X-FDA: 79912606578.15.3CE312C Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by imf08.hostedemail.com (Postfix) with ESMTP id BF6F81600AA for ; Thu, 15 Sep 2022 01:37:07 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=xueshuai@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0VPqLUsL_1663205822; Received: from 30.240.121.31(mailfrom:xueshuai@linux.alibaba.com fp:SMTPD_---0VPqLUsL_1663205822) by smtp.aliyun-inc.com; Thu, 15 Sep 2022 09:37:04 +0800 Message-ID: Date: Thu, 15 Sep 2022 09:36:59 +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: Andrew Morton Cc: naoya.horiguchi@nec.com, linmiaohe@huawei.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, cuibixuan@linux.alibaba.com, baolin.wang@linux.alibaba.com, zhuo.song@linux.alibaba.com, Huang Ying References: <20220914064935.7851-1-xueshuai@linux.alibaba.com> <20220914153542.285f870f728c6129a479a69d@linux-foundation.org> From: Shuai Xue In-Reply-To: <20220914153542.285f870f728c6129a479a69d@linux-foundation.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf08.hostedemail.com: domain of xueshuai@linux.alibaba.com designates 115.124.30.45 as permitted sender) smtp.mailfrom=xueshuai@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663205828; a=rsa-sha256; cv=none; b=sunx0sHI6r0IzMf83e3MmTSIP4ir93FosGAY2NWlXeAGi8i5Vip08J2y5Qr/bLUXHtB2cx DakdwOY2DVd4Co2CVG2p4Z4bcce2IgKwcOIa6Xq1SeHZbm/C6GV7EgTCJj9EOYt02VyTIs ze5ojT1UImLQC8svubeAkVSy2eIaa7w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663205828; 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=u++ikCIN0AVYRpqod45GXbLG2go8o5rbZjW8z9p4ivg=; b=tz9IbFGs+2z34kG7eEdRJV+FYmr2WXEeon+kxItg4KHXvLcLgmV0FRbZGpjYi9zr1aStvD iKAL5FwrVzNwC3kFstWzSbecKWoO9Xvx04QsaJheFHLFNm3o5h3PKynIsz0c7sBNV4p583 frWgh2rNYtOCVcYKtb91dd4L4ylpXTw= X-Rspam-User: Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf08.hostedemail.com: domain of xueshuai@linux.alibaba.com designates 115.124.30.45 as permitted sender) smtp.mailfrom=xueshuai@linux.alibaba.com X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: BF6F81600AA X-Stat-Signature: 3mzps5gg3fqajd6ts3hmosuar5cjgc38 X-HE-Tag: 1663205827-70761 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 AM6:35, Andrew Morton 写道: > On Wed, 14 Sep 2022 14:49:35 +0800 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. > > Thanks. > > When fixing a bug, please always describe the user-visible effects of > tha bug. I'm thinking "null pointer deref crashes the kernel". Got it. Thank you :) > >> Fixes: a3f5d80ea401 ("mm,hwpoison: send SIGBUS with error virutal address") >> Signed-off-by: Shuai Xue > > I'll add cc:stable. Thanks. > >> --- 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; >> } > > This is an unrelated change which doesn't appear to match the style in > memory-failure.c, so I'll drop this hunk. I see, thanks. Cheers, Shuai