linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Shuai Xue <xueshuai@linux.alibaba.com>
To: Andrew Morton <akpm@linux-foundation.org>
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 <ying.huang@intel.com>
Subject: Re: [PATCH] mm,hwpoison: check mm when killing accessing process
Date: Thu, 15 Sep 2022 09:36:59 +0800	[thread overview]
Message-ID: <e9076da5-bd96-1a21-e4af-36eb46409178@linux.alibaba.com> (raw)
In-Reply-To: <20220914153542.285f870f728c6129a479a69d@linux-foundation.org>



在 2022/9/15 AM6:35, Andrew Morton 写道:
> On Wed, 14 Sep 2022 14:49:35 +0800 Shuai Xue <xueshuai@linux.alibaba.com> 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 <xueshuai@linux.alibaba.com>
> 
> 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


  reply	other threads:[~2022-09-15  1:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-14  6:49 Shuai Xue
2022-09-14 22:35 ` Andrew Morton
2022-09-15  1:36   ` Shuai Xue [this message]
2022-09-15  1:45 ` Miaohe Lin
2022-09-15  2:06   ` Shuai Xue
2022-09-15  1:48 ` Naoya Horiguchi
2022-09-15  2:08   ` Shuai Xue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e9076da5-bd96-1a21-e4af-36eb46409178@linux.alibaba.com \
    --to=xueshuai@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=cuibixuan@linux.alibaba.com \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=naoya.horiguchi@nec.com \
    --cc=ying.huang@intel.com \
    --cc=zhuo.song@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox