Skip to content

Commit

Permalink
sparc: fix compat siginfo ABI regression
Browse files Browse the repository at this point in the history
Starting with commit v4.14-rc1~60^2^2~1, a SIGFPE signal sent via kill
results to wrong values in si_pid and si_uid fields of compat siginfo_t.

This happens due to FPE_FIXME being defined to 0 for sparc, and at the
same time siginfo_layout() introduced by the same commit returns
SIL_FAULT for SIGFPE if si_code == SI_USER and FPE_FIXME is defined to 0.

Fix this regression by removing FPE_FIXME macro and changing all its users
to assign FPE_FLTUNK to si_code instead of FPE_FIXME.

Note that FPE_FLTUNK is a new macro introduced by commit
266da65.

Tested with commit v4.16-11958-g16e205cf42da.

This bug was found by strace test suite.

Link: https://github.com/strace/strace/issues/21
Fixes: cc73152 ("signal: Remove kernel interal si_code magic")
Thanks-to: Anatoly Pugachev <matorola@gmail.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Dmitry V. Levin authored and David S. Miller committed Jun 5, 2018
1 parent 2b1f6a0 commit 1c1ff29
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 9 deletions.
7 changes: 0 additions & 7 deletions arch/sparc/include/uapi/asm/siginfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@

#define SI_NOINFO 32767 /* no information in siginfo_t */

/*
* SIGFPE si_codes
*/
#ifdef __KERNEL__
#define FPE_FIXME 0 /* Broken dup of SI_USER */
#endif /* __KERNEL__ */

/*
* SIGEMT si_codes
*/
Expand Down
2 changes: 1 addition & 1 deletion arch/sparc/kernel/traps_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ void do_fpe_trap(struct pt_regs *regs, unsigned long pc, unsigned long npc,
info.si_errno = 0;
info.si_addr = (void __user *)pc;
info.si_trapno = 0;
info.si_code = FPE_FIXME;
info.si_code = FPE_FLTUNK;
if ((fsr & 0x1c000) == (1 << 14)) {
if (fsr & 0x10)
info.si_code = FPE_FLTINV;
Expand Down
2 changes: 1 addition & 1 deletion arch/sparc/kernel/traps_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -2372,7 +2372,7 @@ static void do_fpe_common(struct pt_regs *regs)
info.si_errno = 0;
info.si_addr = (void __user *)regs->tpc;
info.si_trapno = 0;
info.si_code = FPE_FIXME;
info.si_code = FPE_FLTUNK;
if ((fsr & 0x1c000) == (1 << 14)) {
if (fsr & 0x10)
info.si_code = FPE_FLTINV;
Expand Down

0 comments on commit 1c1ff29

Please sign in to comment.