Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm/memory-failure.c-failure: send right signal code to correct thread

When a thread in a multi-threaded application hits a machine check because
of an uncorrectable error in memory - we want to send the SIGBUS with
si.si_code = BUS_MCEERR_AR to that thread. Currently we fail to do that
if the active thread is not the primary thread in the process.
collect_procs() just finds primary threads and this test:

if ((flags & MF_ACTION_REQUIRED) && t == current) {

will see that the thread we found isn't the current thread and so send a
si.si_code = BUS_MCEERR_AO to the primary (and nothing to the active
thread at this time).

We can fix this by checking whether "current" shares the same mm with the
process that collect_procs() said owned the page. If so, we send the
SIGBUS to current (with code BUS_MCEERR_AR).

Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Reported-by: Otto Bruggeman <otto.g.bruggeman@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Borislav Petkov <bp@suse.de>
Cc: Chen Gong <gong.chen@linux.jf.intel.com>
Cc: <stable@vger.kernel.org> [3.2+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Tony Luck and committed by
Linus Torvalds
a70ffcac d2f31028

+2 -2
+2 -2
mm/memory-failure.c
··· 204 204 #endif 205 205 si.si_addr_lsb = compound_order(compound_head(page)) + PAGE_SHIFT; 206 206 207 - if ((flags & MF_ACTION_REQUIRED) && t == current) { 207 + if ((flags & MF_ACTION_REQUIRED) && t->mm == current->mm) { 208 208 si.si_code = BUS_MCEERR_AR; 209 - ret = force_sig_info(SIGBUS, &si, t); 209 + ret = force_sig_info(SIGBUS, &si, current); 210 210 } else { 211 211 /* 212 212 * Don't use force here, it's convenient if the signal