From patchwork Mon Mar 19 16:03:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 10293579 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D865B602BD for ; Mon, 19 Mar 2018 17:38:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7B2329402 for ; Mon, 19 Mar 2018 17:38:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB79529483; Mon, 19 Mar 2018 17:38:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 413C529402 for ; Mon, 19 Mar 2018 17:38:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966013AbeCSRiv (ORCPT ); Mon, 19 Mar 2018 13:38:51 -0400 Received: from mail-sn1nam02on0103.outbound.protection.outlook.com ([104.47.36.103]:60917 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965964AbeCSQGl (ORCPT ); Mon, 19 Mar 2018 12:06:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=uU+FQ5QakxWZTiLJBULLAM4NJdOJXNABoI9VEZyPLa0=; b=cl4DncyIq6vFUK7R4oqZgqhDLBQEeXkDnQBt8ju8r3FIFJFVFftLvpUTo0/zauKclHoXVO6hCLc6BXzmdOJt+pBW/N1WwwTte6EUctaoKvAv8KOYTtjEg6EMjZTcLW0VzAcSG6GUqZ9mPliihIq2C21kiwL/pj1H+eM12tU8vOs= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0728.namprd21.prod.outlook.com (10.167.110.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.631.0; Mon, 19 Mar 2018 16:06:36 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62%5]) with mapi id 15.20.0631.004; Mon, 19 Mar 2018 16:06:36 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: "Eric W. Biederman" , "James E.J. Bottomley" , Helge Deller , "linux-parisc@vger.kernel.org" , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 277/281] signal/parisc: Document a conflict with SI_USER with SIGFPE Thread-Topic: [PATCH AUTOSEL for 4.9 277/281] signal/parisc: Document a conflict with SI_USER with SIGFPE Thread-Index: AQHTv5vOFxYanGBkD0Sqyh/xG5YjMw== Date: Mon, 19 Mar 2018 16:03:23 +0000 Message-ID: <20180319155742.13731-277-alexander.levin@microsoft.com> References: <20180319155742.13731-1-alexander.levin@microsoft.com> In-Reply-To: <20180319155742.13731-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DM5PR2101MB0728; 7:+IT1WUFk1te+fKgwwRMwqqke79KEx/KQZ2Epjjl2iQpWqLoTPWP/JDdfLSuhgMn/inYRX+fD5sRLSVCGEovzoor7C/4kvjCPIu1YYHmKzB+hqKBQWgzrwJvHzS08ORx89lDxRg+6qO3dm7AjTpyLVH2h5wTIoryT3U/rjIkSSMyXt8oJGXcEfkIN+jxOIKEaM1Zn6lisZi5vvmOKD+jxh5+cF34ejnnUby0p9p4FxikplOi0gpW2NwS2DmGKxpFy; 20:vU/rpYX/8097UeodEvwfLjtynLo+hGI5OdyScT7Qn2loRoimhBOA9ACNRe/USXg9MYuB8BN2E4VluQC//YCbDcfee6K8iBUKvDCzIMxRYW6ZTFEFfV/H+Cgf24y3xeRW/vczvIMrw33Q6qf3YSZ96pI+IZWIsZoZ4dU8LtrYUN8= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 3ab1836b-1300-47b8-1f0e-08d58db36449 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020); SRVR:DM5PR2101MB0728; x-ms-traffictypediagnostic: DM5PR2101MB0728: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(26323138287068)(89211679590171)(9452136761055)(84791874153150); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(3231221)(944501300)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(6072148)(201708071742011); SRVR:DM5PR2101MB0728; BCL:0; PCL:0; RULEID:; SRVR:DM5PR2101MB0728; x-forefront-prvs: 06167FAD59 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(39380400002)(346002)(376002)(39860400002)(396003)(199004)(189003)(8936002)(99286004)(478600001)(53936002)(107886003)(966005)(110136005)(86612001)(72206003)(97736004)(76176011)(316002)(3280700002)(5250100002)(2501003)(36756003)(2906002)(105586002)(1076002)(86362001)(14454004)(6436002)(54906003)(8666007)(6512007)(6116002)(6486002)(6306002)(106356001)(3846002)(22452003)(3660700001)(186003)(59450400001)(68736007)(66066001)(25786009)(102836004)(4326008)(10290500003)(26005)(6666003)(305945005)(2950100002)(7736002)(10090500001)(81156014)(81166006)(8676002)(6506007)(5660300001)(2900100001)(22906009)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB0728; H:DM5PR2101MB1032.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: SW2A2b8FEXY7NVtKvihgVLTCmHaHqG90nRRH1bpLCn0SqyEsCOnfrSUozxmeenzdpUuqzFvL7JONr09Qt5qPnXtwOBWunfUasl+vRIsyX3FMr0KxuQ3YNgu3vF25QFOCjHVtUsTrZYkVVAJIoqogo2XtxU8flDDmbA2MLckTbRzp8NfJlNavvzX6tOQHQs37tzCM6Bz9GE06LifRmvTo+cdEaLBscDOkVlrlCNBRqIWe742hAde/Pme1k8gQs5gQ2i+bSJedyLDtWOyTp3KPhKYq3aVia8B5wJhdNiRSAEZsHopYKVcfNFYN1uiowrYH54ehHUdVQSMuFnkb6YZcXQ== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3ab1836b-1300-47b8-1f0e-08d58db36449 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Mar 2018 16:03:23.7694 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0728 Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Eric W. Biederman" [ Upstream commit b5daf2b9d1c9a2b4f03ca93f75913ba2da3b3eaa ] Setting si_code to 0 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. Further use of si_code == 0 guaranteed that copy_siginfo_to_user saw a value of __SI_KILL and now sees a value of SIL_KILL with the result that uid and pid fields are copied and which might copying the si_addr field by accident but certainly not by design. Making this a very flakey implementation. Utilizing FPE_FIXME siginfo_layout will now return SIL_FAULT and the appropriate fields will reliably be copied. This bug is 13 years old and parsic machines are no longer being built so I don't know if it possible or worth fixing it. But it is at least worth documenting this so other architectures don't make the same mistake. Possible ABI fixes includee: - Send the signal without siginfo - Don't generate a signal - Possibly assign and use an appropriate si_code - Don't handle cases which can't happen Cc: "James E.J. Bottomley" Cc: Helge Deller Cc: linux-parisc@vger.kernel.org Ref: 313c01d3e3fd ("[PATCH] PA-RISC update for 2.6.0") Histroy Tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git Signed-off-by: "Eric W. Biederman" Signed-off-by: Sasha Levin --- arch/parisc/include/uapi/asm/siginfo.h | 7 +++++++ arch/parisc/kernel/traps.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/parisc/include/uapi/asm/siginfo.h b/arch/parisc/include/uapi/asm/siginfo.h index 8fd10f85c50e..882a8775441f 100644 --- a/arch/parisc/include/uapi/asm/siginfo.h +++ b/arch/parisc/include/uapi/asm/siginfo.h @@ -7,4 +7,11 @@ #include +/* + * SIGFPE si_codes + */ +#ifdef __KERNEL__ +#define FPE_FIXME 0 /* Broken dup of SI_USER */ +#endif /* __KERNEL__ */ + #endif diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c index 378df9207406..3172cb52f703 100644 --- a/arch/parisc/kernel/traps.c +++ b/arch/parisc/kernel/traps.c @@ -627,7 +627,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs) si.si_signo = SIGFPE; /* Set to zero, and let the userspace app figure it out from the insn pointed to by si_addr */ - si.si_code = 0; + si.si_code = FPE_FIXME; si.si_addr = (void __user *) regs->iaoq[0]; force_sig_info(SIGFPE, &si, current); return;