Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752225AbdGROTW (ORCPT ); Tue, 18 Jul 2017 10:19:22 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:35123 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751684AbdGROQH (ORCPT ); Tue, 18 Jul 2017 10:16:07 -0400 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: Andy Lutomirski , Linus Torvalds , Al Viro , Oleg Nesterov , Andrei Vagin , Thomas Gleixner , Greg KH , Andrey Vagin , Serge Hallyn , Pavel Emelyanov , Cyrill Gorcunov , Peter Zijlstra , Willy Tarreau , linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Linux Containers , Michael Kerrisk , "Eric W. Biederman" , "David S. Miller" , sparclinux@vger.kernel.org Date: Tue, 18 Jul 2017 09:06:47 -0500 Message-Id: <20170718140651.15973-3-ebiederm@xmission.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <87o9shg7t7.fsf_-_@xmission.com> References: <87o9shg7t7.fsf_-_@xmission.com> X-XM-SPF: eid=1dXTI6-0000EH-AO;;;mid=<20170718140651.15973-3-ebiederm@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=67.3.213.87;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX18Ge4QqYTWN7FnkOB8s9t1pnI7GHmmY+dQ= X-SA-Exim-Connect-IP: 67.3.213.87 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.7 XMSubLong Long Subject * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.1 URIBL_SBL_A Contains URL's A record listed in the SBL blocklist * [URIs: davemloft.net] * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa01 1397; Body=1 Fuz1=1 Fuz2=43] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa01 1397; Body=1 Fuz1=1 Fuz2=43 X-Spam-Combo: **;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 5706 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 3.7 (0.1%), b_tie_ro: 2.8 (0.0%), parse: 1.46 (0.0%), extract_message_metadata: 32 (0.6%), get_uri_detail_list: 3.5 (0.1%), tests_pri_-1000: 15 (0.3%), tests_pri_-950: 2.0 (0.0%), tests_pri_-900: 1.74 (0.0%), tests_pri_-400: 41 (0.7%), check_bayes: 39 (0.7%), b_tokenize: 18 (0.3%), b_tok_get_all: 8 (0.1%), b_comp_prob: 4.2 (0.1%), b_tok_touch_all: 3.0 (0.1%), b_finish: 0.80 (0.0%), tests_pri_0: 638 (11.2%), check_dkim_signature: 1.20 (0.0%), check_dkim_adsp: 4.4 (0.1%), tests_pri_500: 4963 (87.0%), poll_dns_idle: 4955 (86.8%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 3/7] signal/sparc: Document a conflict with SI_USER with SIGFPE X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2423 Lines: 68 Setting si_code to __SI_FAULT results in a userspace seeing an si_code of 0. This is the same si_code as SI_USER. Posix and common sense requires that SI_USER not be a signal specific si_code. As such this use of 0 for the si_code is a pretty horribly broken ABI. This was introduced in 2.3.41 so this mess has had a long time for people to be able to start depending on it. As this bug has existed for 17 years already I don't know if it is worth fixing. It is definitely worth documenting what is going on so that no one decides to copy this bad decision. Cc: "David S. Miller" Cc: sparclinux@vger.kernel.org Signed-off-by: "Eric W. Biederman" --- arch/sparc/include/uapi/asm/siginfo.h | 7 +++++++ arch/sparc/kernel/traps_32.c | 2 +- arch/sparc/kernel/traps_64.c | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/sparc/include/uapi/asm/siginfo.h b/arch/sparc/include/uapi/asm/siginfo.h index 2d9b79ccaa50..da2126e0c536 100644 --- a/arch/sparc/include/uapi/asm/siginfo.h +++ b/arch/sparc/include/uapi/asm/siginfo.h @@ -17,6 +17,13 @@ #define SI_NOINFO 32767 /* no information in siginfo_t */ /* + * SIGFPE si_codes + */ +#ifdef __KERNEL__ +#define FPE_FIXME (__SI_FAULT|0) /* Broken dup of SI_USER */ +#endif /* __KERNEL__ */ + +/* * SIGEMT si_codes */ #define EMT_TAGOVF (__SI_FAULT|1) /* tag overflow */ diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c index 466d4aed06c7..581cf35ee7e3 100644 --- a/arch/sparc/kernel/traps_32.c +++ b/arch/sparc/kernel/traps_32.c @@ -306,7 +306,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 = __SI_FAULT; + info.si_code = FPE_FIXME; if ((fsr & 0x1c000) == (1 << 14)) { if (fsr & 0x10) info.si_code = FPE_FLTINV; diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c index 196ee5eb4d48..e882e128faa3 100644 --- a/arch/sparc/kernel/traps_64.c +++ b/arch/sparc/kernel/traps_64.c @@ -2258,7 +2258,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 = __SI_FAULT; + info.si_code = FPE_FIXME; if ((fsr & 0x1c000) == (1 << 14)) { if (fsr & 0x10) info.si_code = FPE_FLTINV; -- 2.10.1