public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Naoya Horiguchi <naoya.horiguchi@nec.com>,
	Youquan Song <youquan.song@intel.com>,
	Tony Luck <tony.luck@intel.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 5.15 19/21] mm/hwpoison: fix error page recovered but reported "not recovered"
Date: Fri, 13 May 2022 16:24:01 +0200	[thread overview]
Message-ID: <20220513142230.431675712@linuxfoundation.org> (raw)
In-Reply-To: <20220513142229.874949670@linuxfoundation.org>

From: Naoya Horiguchi <naoya.horiguchi@nec.com>

commit 046545a661af2beec21de7b90ca0e35f05088a81 upstream.

When an uncorrected memory error is consumed there is a race between the
CMCI from the memory controller reporting an uncorrected error with a
UCNA signature, and the core reporting and SRAR signature machine check
when the data is about to be consumed.

If the CMCI wins that race, the page is marked poisoned when
uc_decode_notifier() calls memory_failure() and the machine check
processing code finds the page already poisoned.  It calls
kill_accessing_process() to make sure a SIGBUS is sent.  But returns the
wrong error code.

Console log looks like this:

  mce: Uncorrected hardware memory error in user-access at 3710b3400
  Memory failure: 0x3710b3: recovery action for dirty LRU page: Recovered
  Memory failure: 0x3710b3: already hardware poisoned
  Memory failure: 0x3710b3: Sending SIGBUS to einj_mem_uc:361438 due to hardware memory corruption
  mce: Memory error not recovered

kill_accessing_process() is supposed to return -EHWPOISON to notify that
SIGBUS is already set to the process and kill_me_maybe() doesn't have to
send it again.  But current code simply fails to do this, so fix it to
make sure to work as intended.  This change avoids the noise message
"Memory error not recovered" and skips duplicate SIGBUSs.

[tony.luck@intel.com: reword some parts of commit message]

Link: https://lkml.kernel.org/r/20220113231117.1021405-1-naoya.horiguchi@linux.dev
Fixes: a3f5d80ea401 ("mm,hwpoison: send SIGBUS with error virutal address")
Signed-off-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
Reported-by: Youquan Song <youquan.song@intel.com>
Cc: Tony Luck <tony.luck@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 mm/memory-failure.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -705,8 +705,10 @@ static int kill_accessing_process(struct
 			      (void *)&priv);
 	if (ret == 1 && priv.tk.addr)
 		kill_proc(&priv.tk, pfn, flags);
+	else
+		ret = 0;
 	mmap_read_unlock(p->mm);
-	return ret ? -EFAULT : -EHWPOISON;
+	return ret > 0 ? -EHWPOISON : -EFAULT;
 }
 
 static const char *action_name[] = {



  parent reply	other threads:[~2022-05-13 14:31 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-13 14:23 [PATCH 5.15 00/21] 5.15.40-rc1 review Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.15 01/21] x86/lib/atomic64_386_32: Rename things Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.15 02/21] x86: Prepare asm files for straight-line-speculation Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.15 03/21] x86: Prepare inline-asm " Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.15 04/21] objtool: Add straight-line-speculation validation Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.15 05/21] x86/alternative: Relax text_poke_bp() constraint Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.15 06/21] kbuild: move objtool_args back to scripts/Makefile.build Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.15 07/21] x86: Add straight-line-speculation mitigation Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.15 08/21] tools arch: Update arch/x86/lib/mem{cpy,set}_64.S copies used in perf bench mem memcpy Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.15 09/21] kvm/emulate: Fix SETcc emulation function offsets with SLS Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.15 10/21] crypto: x86/poly1305 - Fixup SLS Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.15 11/21] objtool: Fix SLS validation for kcov tail-call replacement Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.15 12/21] Bluetooth: Fix the creation of hdev->name Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.15 13/21] rfkill: uapi: fix RFKILL_IOCTL_MAX_SIZE ioctl request definition Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.15 14/21] udf: Avoid using stale lengthOfImpUse Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.15 15/21] mm: fix missing cache flush for all tail pages of compound page Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.15 16/21] mm: hugetlb: fix missing cache flush in copy_huge_page_from_user() Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.15 17/21] mm: shmem: fix missing cache flush in shmem_mfill_atomic_pte() Greg Kroah-Hartman
2022-05-13 14:24 ` [PATCH 5.15 18/21] mm: userfaultfd: fix missing cache flush in mcopy_atomic_pte() and __mcopy_atomic() Greg Kroah-Hartman
2022-05-13 14:24 ` Greg Kroah-Hartman [this message]
2022-05-13 14:24 ` [PATCH 5.15 20/21] mm/mlock: fix potential imbalanced rlimit ucounts adjustment Greg Kroah-Hartman
2022-05-13 14:24 ` [PATCH 5.15 21/21] mm: fix invalid page pointer returned with FOLL_PIN gups Greg Kroah-Hartman
2022-05-13 16:40 ` [PATCH 5.15 00/21] 5.15.40-rc1 review Jon Hunter
2022-05-13 20:37 ` Shuah Khan
2022-05-14  3:19 ` Florian Fainelli
2022-05-14  5:35 ` Fox Chen
2022-05-14 11:38 ` Ron Economos
2022-05-14 11:41 ` Naresh Kamboju
2022-05-14 14:26 ` Sudip Mukherjee
2022-05-14 14:57 ` Guenter Roeck

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=20220513142230.431675712@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=naoya.horiguchi@nec.com \
    --cc=stable@vger.kernel.org \
    --cc=tony.luck@intel.com \
    --cc=torvalds@linux-foundation.org \
    --cc=youquan.song@intel.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