Skip to content

Commit

Permalink
signal/memory-failure: Use force_sig_mceerr and send_sig_mceerr
Browse files Browse the repository at this point in the history
Delegate filling out struct siginfo to functions in kernel/signal.c
to simplify the code.

Signed-off-by: "Eric W. Biederman" <[email protected]>
  • Loading branch information
ebiederm committed Jan 23, 2018
1 parent 83b5753 commit c0f4555
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions mm/memory-failure.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,28 +181,25 @@ EXPORT_SYMBOL_GPL(hwpoison_filter);
static int kill_proc(struct task_struct *t, unsigned long addr,
unsigned long pfn, struct page *page, int flags)
{
struct siginfo si;
short addr_lsb;
int ret;

pr_err("Memory failure: %#lx: Killing %s:%d due to hardware memory corruption\n",
pfn, t->comm, t->pid);
si.si_signo = SIGBUS;
si.si_errno = 0;
si.si_addr = (void *)addr;
si.si_addr_lsb = compound_order(compound_head(page)) + PAGE_SHIFT;
addr_lsb = compound_order(compound_head(page)) + PAGE_SHIFT;

if ((flags & MF_ACTION_REQUIRED) && t->mm == current->mm) {
si.si_code = BUS_MCEERR_AR;
ret = force_sig_info(SIGBUS, &si, current);
ret = force_sig_mceerr(BUS_MCEERR_AR, (void __user *)addr,
addr_lsb, current);
} else {
/*
* Don't use force here, it's convenient if the signal
* can be temporarily blocked.
* This could cause a loop when the user sets SIGBUS
* to SIG_IGN, but hopefully no one will do that?
*/
si.si_code = BUS_MCEERR_AO;
ret = send_sig_info(SIGBUS, &si, t); /* synchronous? */
ret = send_sig_mceerr(BUS_MCEERR_AO, (void __user *)addr,
addr_lsb, t); /* synchronous? */
}
if (ret < 0)
pr_info("Memory failure: Error sending signal to %s:%d: %d\n",
Expand Down

0 comments on commit c0f4555

Please sign in to comment.