mm-commits.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* incoming
@ 2020-06-12  0:30 Andrew Morton
  2020-06-12  0:34 ` [patch 1/5] mm/memory-failure: prioritize prctl(PR_MCE_KILL) over vm.memory_failure_early_kill Andrew Morton
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Andrew Morton @ 2020-06-12  0:30 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-mm, mm-commits


A few fixes and stragglers.


5 patches, based on 623f6dc593eaf98b91916836785278eddddaacf8.

Subsystems affected by this patch series:

  mm/memory-failure
  ocfs2
  lib/lzo
  misc

Subsystem: mm/memory-failure

    Naoya Horiguchi <nao.horiguchi@gmail.com>:
    Patch series "hwpoison: fixes signaling on memory error":
      mm/memory-failure: prioritize prctl(PR_MCE_KILL) over vm.memory_failure_early_kill
      mm/memory-failure: send SIGBUS(BUS_MCEERR_AR) only to current thread

Subsystem: ocfs2

    Tom Seewald <tseewald@gmail.com>:
      ocfs2: fix build failure when TCP/IP is disabled

Subsystem: lib/lzo

    Dave Rodgman <dave.rodgman@arm.com>:
      lib/lzo: fix ambiguous encoding bug in lzo-rle

Subsystem: misc

    Christoph Hellwig <hch@lst.de>:
      amdgpu: a NULL ->mm does not mean a thread is a kthread

 Documentation/lzo.txt                      |    8 ++++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h |    2 -
 fs/ocfs2/Kconfig                           |    2 -
 lib/lzo/lzo1x_compress.c                   |   13 ++++++++
 mm/memory-failure.c                        |   43 +++++++++++++++++------------
 5 files changed, 47 insertions(+), 21 deletions(-)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [patch 1/5] mm/memory-failure: prioritize prctl(PR_MCE_KILL) over vm.memory_failure_early_kill
  2020-06-12  0:30 incoming Andrew Morton
@ 2020-06-12  0:34 ` Andrew Morton
  2020-06-12  0:34 ` [patch 2/5] mm/memory-failure: send SIGBUS(BUS_MCEERR_AR) only to current thread Andrew Morton
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Andrew Morton @ 2020-06-12  0:34 UTC (permalink / raw)
  To: akpm, linux-mm, mm-commits, nao.horiguchi, naoya.horiguchi,
	pankaj.gupta.linux, tony.luck, torvalds

From: Naoya Horiguchi <nao.horiguchi@gmail.com>
Subject: mm/memory-failure: prioritize prctl(PR_MCE_KILL) over vm.memory_failure_early_kill

Patch series "hwpoison: fixes signaling on memory error"

This is a small patchset to solve issues in memory error handler to
send SIGBUS to proper process/thread as expected in configuration.
Please see descriptions in individual patches for more details.


This patch (of 2):

Early-kill policy is controlled from two types of settings, one is
per-process setting prctl(PR_MCE_KILL) and the other is system-wide
setting vm.memory_failure_early_kill.  Users expect per-process setting to
override system-wide setting as many other settings do, but early-kill
setting doesn't work as such.  For example, if a system configures
vm.memory_failure_early_kill to 1 (enabled), a process receives SIGBUS
even if it's configured to explicitly disable PF_MCE_KILL by prctl(). 
That's not desirable for applications with their own policies.

This patch is suggesting to change the priority of these two types of
settings, by checking sysctl_memory_failure_early_kill only when a given
process has the default kill policy.

Note that this patch is solving a thread choice issue too.  Originally,
collect_procs() always chooses the main thread when
vm.memory_failure_early_kill is 1, even if the process has a dedicated
thread for memory error handling.  SIGBUS should be sent to the dedicated
thread if early-kill is enabled via vm.memory_failure_early_kill as we are
doing for PR_MCE_KILL_EARLY processes.

Link: http://lkml.kernel.org/r/1591321039-22141-1-git-send-email-naoya.horiguchi@nec.com
Link: http://lkml.kernel.org/r/1591321039-22141-2-git-send-email-naoya.horiguchi@nec.com
Signed-off-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/memory-failure.c |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

--- a/mm/memory-failure.c~mm-memory-failure-prioritize-prctlpr_mce_kill-over-vmmemory_failure_early_kill
+++ a/mm/memory-failure.c
@@ -402,9 +402,15 @@ static struct task_struct *find_early_ki
 {
 	struct task_struct *t;
 
-	for_each_thread(tsk, t)
-		if ((t->flags & PF_MCE_PROCESS) && (t->flags & PF_MCE_EARLY))
-			return t;
+	for_each_thread(tsk, t) {
+		if (t->flags & PF_MCE_PROCESS) {
+			if (t->flags & PF_MCE_EARLY)
+				return t;
+		} else {
+			if (sysctl_memory_failure_early_kill)
+				return t;
+		}
+	}
 	return NULL;
 }
 
@@ -417,17 +423,11 @@ static struct task_struct *find_early_ki
 static struct task_struct *task_early_kill(struct task_struct *tsk,
 					   int force_early)
 {
-	struct task_struct *t;
 	if (!tsk->mm)
 		return NULL;
 	if (force_early)
 		return tsk;
-	t = find_early_kill_thread(tsk);
-	if (t)
-		return t;
-	if (sysctl_memory_failure_early_kill)
-		return tsk;
-	return NULL;
+	return find_early_kill_thread(tsk);
 }
 
 /*
_

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [patch 2/5] mm/memory-failure: send SIGBUS(BUS_MCEERR_AR) only to current thread
  2020-06-12  0:30 incoming Andrew Morton
  2020-06-12  0:34 ` [patch 1/5] mm/memory-failure: prioritize prctl(PR_MCE_KILL) over vm.memory_failure_early_kill Andrew Morton
@ 2020-06-12  0:34 ` Andrew Morton
  2020-06-12  0:34 ` [patch 3/5] ocfs2: fix build failure when TCP/IP is disabled Andrew Morton
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Andrew Morton @ 2020-06-12  0:34 UTC (permalink / raw)
  To: akpm, linux-mm, mm-commits, nao.horiguchi, naoya.horiguchi,
	pankaj.gupta.linux, tony.luck, torvalds

From: Naoya Horiguchi <nao.horiguchi@gmail.com>
Subject: mm/memory-failure: send SIGBUS(BUS_MCEERR_AR) only to current thread

Action Required memory error should happen only when a processor is about
to access to a corrupted memory, so it's synchronous and only affects
current process/thread.  Recently commit 872e9a205c84 ("mm,
memory_failure: don't send BUS_MCEERR_AO for action required error") fixed
the issue that Action Required memory could unnecessarily send SIGBUS to
the processes which share the error memory.  But we still have another
issue that we could send SIGBUS to a wrong thread.

This is because collect_procs() and task_early_kill() fails to add the
current process to "to-kill" list.  So this patch is suggesting to fix it.
With this fix, SIGBUS(BUS_MCEERR_AR) is never sent to non-current
process/thread.

Link: http://lkml.kernel.org/r/1591321039-22141-3-git-send-email-naoya.horiguchi@nec.com
Signed-off-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
Acked-by: Tony Luck <tony.luck@intel.com>
Acked-by: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/memory-failure.c |   23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

--- a/mm/memory-failure.c~mm-memory-failure-send-sigbusbus_mceerr_ar-only-to-current-thread
+++ a/mm/memory-failure.c
@@ -212,15 +212,13 @@ static int kill_proc(struct to_kill *tk,
 	short addr_lsb = tk->size_shift;
 	int ret = 0;
 
-	if ((t->mm == current->mm) || !(flags & MF_ACTION_REQUIRED))
-		pr_err("Memory failure: %#lx: Sending SIGBUS to %s:%d due to hardware memory corruption\n",
+	pr_err("Memory failure: %#lx: Sending SIGBUS to %s:%d due to hardware memory corruption\n",
 			pfn, t->comm, t->pid);
 
 	if (flags & MF_ACTION_REQUIRED) {
-		if (t->mm == current->mm)
-			ret = force_sig_mceerr(BUS_MCEERR_AR,
+		WARN_ON_ONCE(t != current);
+		ret = force_sig_mceerr(BUS_MCEERR_AR,
 					 (void __user *)tk->addr, addr_lsb);
-		/* send no signal to non-current processes */
 	} else {
 		/*
 		 * Don't use force here, it's convenient if the signal
@@ -419,14 +417,25 @@ static struct task_struct *find_early_ki
  * to be signaled when some page under the process is hwpoisoned.
  * Return task_struct of the dedicated thread (main thread unless explicitly
  * specified) if the process is "early kill," and otherwise returns NULL.
+ *
+ * Note that the above is true for Action Optional case, but not for Action
+ * Required case where SIGBUS should sent only to the current thread.
  */
 static struct task_struct *task_early_kill(struct task_struct *tsk,
 					   int force_early)
 {
 	if (!tsk->mm)
 		return NULL;
-	if (force_early)
-		return tsk;
+	if (force_early) {
+		/*
+		 * Comparing ->mm here because current task might represent
+		 * a subthread, while tsk always points to the main thread.
+		 */
+		if (tsk->mm == current->mm)
+			return current;
+		else
+			return NULL;
+	}
 	return find_early_kill_thread(tsk);
 }
 
_

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [patch 3/5] ocfs2: fix build failure when TCP/IP is disabled
  2020-06-12  0:30 incoming Andrew Morton
  2020-06-12  0:34 ` [patch 1/5] mm/memory-failure: prioritize prctl(PR_MCE_KILL) over vm.memory_failure_early_kill Andrew Morton
  2020-06-12  0:34 ` [patch 2/5] mm/memory-failure: send SIGBUS(BUS_MCEERR_AR) only to current thread Andrew Morton
@ 2020-06-12  0:34 ` Andrew Morton
  2020-06-12  0:34 ` [patch 4/5] lib/lzo: fix ambiguous encoding bug in lzo-rle Andrew Morton
  2020-06-12  0:34 ` [patch 5/5] amdgpu: a NULL ->mm does not mean a thread is a kthread Andrew Morton
  4 siblings, 0 replies; 7+ messages in thread
From: Andrew Morton @ 2020-06-12  0:34 UTC (permalink / raw)
  To: akpm, davem, gechangwei, ghe, hch, jgg, jlbec, joseph.qi,
	junxiao.bi, linux-mm, mark, mm-commits, piaojun, sagi, torvalds,
	tseewald

From: Tom Seewald <tseewald@gmail.com>
Subject: ocfs2: fix build failure when TCP/IP is disabled

After commit 12abc5ee7873 ("tcp: add tcp_sock_set_nodelay") and commit
c488aeadcbd0 ("tcp: add tcp_sock_set_user_timeout"), building the kernel
with OCFS2_FS=y but without INET=y causes it to fail with:

ld: fs/ocfs2/cluster/tcp.o: in function `o2net_accept_many':
tcp.c:(.text+0x21b1): undefined reference to `tcp_sock_set_nodelay'
ld: tcp.c:(.text+0x21c1): undefined reference to `tcp_sock_set_user_timeout
'
ld: fs/ocfs2/cluster/tcp.o: in function `o2net_start_connect':
tcp.c:(.text+0x2633): undefined reference to `tcp_sock_set_nodelay'
ld: tcp.c:(.text+0x2643): undefined reference to `tcp_sock_set_user_timeout
'

This is due to tcp_sock_set_nodelay() and tcp_sock_set_user_timeout()
being declared in linux/tcp.h and defined in net/ipv4/tcp.c, which depend
on TCP/IP being enabled.

To fix this, make OCFS2_FS depend on INET=y which already requires NET=y.

Link: http://lkml.kernel.org/r/20200606190827.23954-1-tseewald@gmail.com
12abc5ee7873 ("tcp: add tcp_sock_set_nodelay") and commit
Signed-off-by: Tom Seewald <tseewald@gmail.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: Jason Gunthorpe <jgg@mellanox.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Gang He <ghe@suse.com>
Cc: Jun Piao <piaojun@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 fs/ocfs2/Kconfig |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/fs/ocfs2/Kconfig~fix-build-failure-of-ocfs2-when-tcp-ip-is-disabled
+++ a/fs/ocfs2/Kconfig
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 config OCFS2_FS
 	tristate "OCFS2 file system support"
-	depends on NET && SYSFS && CONFIGFS_FS
+	depends on INET && SYSFS && CONFIGFS_FS
 	select JBD2
 	select CRC32
 	select QUOTA
_

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [patch 4/5] lib/lzo: fix ambiguous encoding bug in lzo-rle
  2020-06-12  0:30 incoming Andrew Morton
                   ` (2 preceding siblings ...)
  2020-06-12  0:34 ` [patch 3/5] ocfs2: fix build failure when TCP/IP is disabled Andrew Morton
@ 2020-06-12  0:34 ` Andrew Morton
  2020-06-12  0:34 ` [patch 5/5] amdgpu: a NULL ->mm does not mean a thread is a kthread Andrew Morton
  4 siblings, 0 replies; 7+ messages in thread
From: Andrew Morton @ 2020-06-12  0:34 UTC (permalink / raw)
  To: akpm, dave.rodgman, linux-mm, mark.rutland, markus, minchan,
	mm-commits, ngupta, sergey.senozhatsky.work, stable, torvalds, w,
	yuchao0

From: Dave Rodgman <dave.rodgman@arm.com>
Subject: lib/lzo: fix ambiguous encoding bug in lzo-rle

In some rare cases, for input data over 32 KB, lzo-rle could encode two
different inputs to the same compressed representation, so that
decompression is then ambiguous (i.e.  data may be corrupted - although
zram is not affected because it operates over 4 KB pages).

This modifies the compressor without changing the decompressor or the
bitstream format, such that:

- there is no change to how data produced by the old compressor is
  decompressed

- an old decompressor will correctly decode data from the updated
  compressor

- performance and compression ratio are not affected

- we avoid introducing a new bitstream format

In testing over 12.8M real-world files totalling 903 GB, three files were
affected by this bug.  I also constructed 37M semi-random 64 KB files
totalling 2.27 TB, and saw no affected files.  Finally I tested over files
constructed to contain each of the ~1024 possible bad input sequences; for
all of these cases, updated lzo-rle worked correctly.

There is no significant impact to performance or compression ratio.

Link: http://lkml.kernel.org/r/20200507100203.29785-1-dave.rodgman@arm.com
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Dave Rodgman <dave.rodgman@arm.com>
Cc: Willy Tarreau <w@1wt.eu>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: Markus F.X.J. Oberhumer <markus@oberhumer.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Cc: Chao Yu <yuchao0@huawei.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 Documentation/lzo.txt    |    8 ++++++--
 lib/lzo/lzo1x_compress.c |   13 +++++++++++++
 2 files changed, 19 insertions(+), 2 deletions(-)

--- a/Documentation/lzo.txt~lib-lzo-fix-ambiguous-encoding-bug-in-lzo-rle
+++ a/Documentation/lzo.txt
@@ -159,11 +159,15 @@ Byte sequences
            distance = 16384 + (H << 14) + D
            state = S (copy S literals after this block)
            End of stream is reached if distance == 16384
+           In version 1 only, to prevent ambiguity with the RLE case when
+           ((distance & 0x803f) == 0x803f) && (261 <= length <= 264), the
+           compressor must not emit block copies where distance and length
+           meet these conditions.
 
         In version 1 only, this instruction is also used to encode a run of
-        zeros if distance = 0xbfff, i.e. H = 1 and the D bits are all 1.
+           zeros if distance = 0xbfff, i.e. H = 1 and the D bits are all 1.
            In this case, it is followed by a fourth byte, X.
-           run length = ((X << 3) | (0 0 0 0 0 L L L)) + 4.
+           run length = ((X << 3) | (0 0 0 0 0 L L L)) + 4
 
       0 0 1 L L L L L  (32..63)
            Copy of small block within 16kB distance (preferably less than 34B)
--- a/lib/lzo/lzo1x_compress.c~lib-lzo-fix-ambiguous-encoding-bug-in-lzo-rle
+++ a/lib/lzo/lzo1x_compress.c
@@ -268,6 +268,19 @@ m_len_done:
 				*op++ = (M4_MARKER | ((m_off >> 11) & 8)
 						| (m_len - 2));
 			else {
+				if (unlikely(((m_off & 0x403f) == 0x403f)
+						&& (m_len >= 261)
+						&& (m_len <= 264))
+						&& likely(bitstream_version)) {
+					// Under lzo-rle, block copies
+					// for 261 <= length <= 264 and
+					// (distance & 0x80f3) == 0x80f3
+					// can result in ambiguous
+					// output. Adjust length
+					// to 260 to prevent ambiguity.
+					ip -= m_len - 260;
+					m_len = 260;
+				}
 				m_len -= M4_MAX_LEN;
 				*op++ = (M4_MARKER | ((m_off >> 11) & 8));
 				while (unlikely(m_len > 255)) {
_

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [patch 5/5] amdgpu: a NULL ->mm does not mean a thread is a kthread
  2020-06-12  0:30 incoming Andrew Morton
                   ` (3 preceding siblings ...)
  2020-06-12  0:34 ` [patch 4/5] lib/lzo: fix ambiguous encoding bug in lzo-rle Andrew Morton
@ 2020-06-12  0:34 ` Andrew Morton
  4 siblings, 0 replies; 7+ messages in thread
From: Andrew Morton @ 2020-06-12  0:34 UTC (permalink / raw)
  To: akpm, alexander.deucher, axboe, balbi, Felix.Kuehling, gregkh,
	hch, jasowang, linux-mm, mm-commits, mst, torvalds, viro,
	zhenyuw, zhi.a.wang

From: Christoph Hellwig <hch@lst.de>
Subject: amdgpu: a NULL ->mm does not mean a thread is a kthread

Use the proper API instead.

Link: http://lkml.kernel.org/r/20200404094101.672954-1-hch@lst.de
Link: http://lkml.kernel.org/r/20200404094101.672954-2-hch@lst.de
Fixes: 70539bd795002 ("drm/amd: Update MEC HQD loading code for KFD")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Tested-by: Jens Axboe <axboe@kernel.dk>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
Cc: Zhi Wang <zhi.a.wang@intel.com>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h~amdgpu-a-null-mm-does-not-mean-a-thread-is-a-kthread
+++ a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
@@ -196,7 +196,7 @@ uint8_t amdgpu_amdkfd_get_xgmi_hops_coun
 			pagefault_disable();				\
 			if ((mmptr) == current->mm) {			\
 				valid = !get_user((dst), (wptr));	\
-			} else if (current->mm == NULL) {		\
+			} else if (current->flags & PF_KTHREAD) {	\
 				kthread_use_mm(mmptr);			\
 				valid = !get_user((dst), (wptr));	\
 				kthread_unuse_mm(mmptr);		\
_

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [patch 2/5] mm/memory-failure: send SIGBUS(BUS_MCEERR_AR) only to current thread
       [not found] <20200611172827.bc85320ccf09b4c7e401d3f3@linux-foundation.org>
@ 2020-06-12  0:30 ` Andrew Morton
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Morton @ 2020-06-12  0:30 UTC (permalink / raw)
  To: akpm, linux-mm, mm-commits, nao.horiguchi, naoya.horiguchi,
	pankaj.gupta.linux, tony.luck, torvalds

From: Naoya Horiguchi <nao.horiguchi@gmail.com>
Subject: mm/memory-failure: send SIGBUS(BUS_MCEERR_AR) only to current thread

Action Required memory error should happen only when a processor is about
to access to a corrupted memory, so it's synchronous and only affects
current process/thread.  Recently commit 872e9a205c84 ("mm,
memory_failure: don't send BUS_MCEERR_AO for action required error") fixed
the issue that Action Required memory could unnecessarily send SIGBUS to
the processes which share the error memory.  But we still have another
issue that we could send SIGBUS to a wrong thread.

This is because collect_procs() and task_early_kill() fails to add the
current process to "to-kill" list.  So this patch is suggesting to fix it.
With this fix, SIGBUS(BUS_MCEERR_AR) is never sent to non-current
process/thread.

Link: http://lkml.kernel.org/r/1591321039-22141-3-git-send-email-naoya.horiguchi@nec.com
Signed-off-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
Acked-by: Tony Luck <tony.luck@intel.com>
Acked-by: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/memory-failure.c |   23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

--- a/mm/memory-failure.c~mm-memory-failure-send-sigbusbus_mceerr_ar-only-to-current-thread
+++ a/mm/memory-failure.c
@@ -212,15 +212,13 @@ static int kill_proc(struct to_kill *tk,
 	short addr_lsb = tk->size_shift;
 	int ret = 0;
 
-	if ((t->mm == current->mm) || !(flags & MF_ACTION_REQUIRED))
-		pr_err("Memory failure: %#lx: Sending SIGBUS to %s:%d due to hardware memory corruption\n",
+	pr_err("Memory failure: %#lx: Sending SIGBUS to %s:%d due to hardware memory corruption\n",
 			pfn, t->comm, t->pid);
 
 	if (flags & MF_ACTION_REQUIRED) {
-		if (t->mm == current->mm)
-			ret = force_sig_mceerr(BUS_MCEERR_AR,
+		WARN_ON_ONCE(t != current);
+		ret = force_sig_mceerr(BUS_MCEERR_AR,
 					 (void __user *)tk->addr, addr_lsb);
-		/* send no signal to non-current processes */
 	} else {
 		/*
 		 * Don't use force here, it's convenient if the signal
@@ -419,14 +417,25 @@ static struct task_struct *find_early_ki
  * to be signaled when some page under the process is hwpoisoned.
  * Return task_struct of the dedicated thread (main thread unless explicitly
  * specified) if the process is "early kill," and otherwise returns NULL.
+ *
+ * Note that the above is true for Action Optional case, but not for Action
+ * Required case where SIGBUS should sent only to the current thread.
  */
 static struct task_struct *task_early_kill(struct task_struct *tsk,
 					   int force_early)
 {
 	if (!tsk->mm)
 		return NULL;
-	if (force_early)
-		return tsk;
+	if (force_early) {
+		/*
+		 * Comparing ->mm here because current task might represent
+		 * a subthread, while tsk always points to the main thread.
+		 */
+		if (tsk->mm == current->mm)
+			return current;
+		else
+			return NULL;
+	}
 	return find_early_kill_thread(tsk);
 }
 
_

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-06-12  0:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-12  0:30 incoming Andrew Morton
2020-06-12  0:34 ` [patch 1/5] mm/memory-failure: prioritize prctl(PR_MCE_KILL) over vm.memory_failure_early_kill Andrew Morton
2020-06-12  0:34 ` [patch 2/5] mm/memory-failure: send SIGBUS(BUS_MCEERR_AR) only to current thread Andrew Morton
2020-06-12  0:34 ` [patch 3/5] ocfs2: fix build failure when TCP/IP is disabled Andrew Morton
2020-06-12  0:34 ` [patch 4/5] lib/lzo: fix ambiguous encoding bug in lzo-rle Andrew Morton
2020-06-12  0:34 ` [patch 5/5] amdgpu: a NULL ->mm does not mean a thread is a kthread Andrew Morton
     [not found] <20200611172827.bc85320ccf09b4c7e401d3f3@linux-foundation.org>
2020-06-12  0:30 ` [patch 2/5] mm/memory-failure: send SIGBUS(BUS_MCEERR_AR) only to current thread Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).