Received: by 10.213.65.68 with SMTP id h4csp2749604imn; Mon, 2 Apr 2018 13:20:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx49G3sCnVkHoAU1VPkXozZz2zAzidZnjVXNq5woGL6ndKHCPFb+6E4EcbfuS7I6W3/Zwuix7 X-Received: by 10.98.236.86 with SMTP id k83mr8360883pfh.84.1522700441004; Mon, 02 Apr 2018 13:20:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522700440; cv=none; d=google.com; s=arc-20160816; b=Fu4DQjkf66lEFSk6XwxiroNO1zKHLXWDiOtoCY1bJJ3OFV+qtJ2d0Efa62dLVQEoc0 34qm3RBBfDu/33vgHakyKrqkUDfoHnb5XM+eImQJdWF24PtFN8oG71jB/aA95wlnluwR 8YtHf37elFcWezY8Ub+u4xVjlTXObmD+ftOBZg8o01r4VfSy1TBbiCRD3mMDDBCDVtfo lOGRH3MB6L2OGl1QR9FSmXFcK1vPAT0jHTQqS+6lRMeH7Epb3c/DRUtvMBMyIrUROCLf zkt3OJxENJFxTfKJP3bEmHCZu8kiELp42a/IkexRB/wz5NP3l6HN9vjoF7H36ZPATsMy I7qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:mime-version:user-agent :message-id:in-reply-to:date:references:cc:to:from :arc-authentication-results; bh=P+iFFJjSHN6IDqEX0K5TNMQr1Xzb13BB9xEfIXsgk88=; b=cO5uoSb6wk4bp4A2RJkxq2G58iIEJHbTQ1CWsyLPGAR19TW1BIUkbD/XzCz+yO3HsG u5r9xp2c5m7IOBigI7LQ29i27HMxPbUQ+g6eTB5OSeUG0XINAHoCcqnMUa4XwdWhfyES PTCNHdW3Acum24OfdcdYhRdXlwAcVZtZXJsgm0YQWoD4lZnv+Xcb1ehqqiI0NTUGY4oK WR6ScLjMhHAeJXNtGU5qU5hiiWZ4AfduTj9EGNm7yjczwl6H2MQbk1Cdjfghq7tV3qxE KXPmlIW62OOfOTJOKgl01cbNxyuASoQPSH7iRj0LgxwQkniCjhFeo8o7XzUWE360Km4X WAgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s13-v6si991131plq.426.2018.04.02.13.20.24; Mon, 02 Apr 2018 13:20:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756649AbeDBUTK (ORCPT + 99 others); Mon, 2 Apr 2018 16:19:10 -0400 Received: from out02.mta.xmission.com ([166.70.13.232]:48106 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753382AbeDBUTH (ORCPT ); Mon, 2 Apr 2018 16:19:07 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]) by out02.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1f35v0-0006WG-2h; Mon, 02 Apr 2018 14:19:06 -0600 Received: from 67-3-145-25.omah.qwest.net ([67.3.145.25] helo=x220.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1f35uy-0008M8-Pq; Mon, 02 Apr 2018 14:19:05 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Eugene Syromiatnikov Cc: Linus Torvalds , linux-kernel@vger.kernel.org, linux-m68k@vger.kernel.org References: <87woypy8zc.fsf@xmission.com> <20180331105658.GA4332@asgard.redhat.com> Date: Mon, 02 Apr 2018 15:17:58 -0500 In-Reply-To: <20180331105658.GA4332@asgard.redhat.com> (Eugene Syromiatnikov's message of "Sat, 31 Mar 2018 12:56:58 +0200") Message-ID: <87woxpz7k9.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1f35uy-0008M8-Pq;;;mid=<87woxpz7k9.fsf@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=67.3.145.25;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1+/mcFXZqwXToOqzso4Wq/iGPEO0+gx2Oo= X-SA-Exim-Connect-IP: 67.3.145.25 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on sa02.xmission.com X-Spam-Level: ** X-Spam-Status: No, score=2.1 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,TVD_RCVD_IP,T_TM2_M_HEADER_IN_MSG,T_TooManySym_01, XMSubMetaSxObfu_03,XMSubMetaSx_00 autolearn=disabled version=3.4.0 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.0 TVD_RCVD_IP Message was received from an IP address * 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 * [sa02 1397; Body=1 Fuz1=1 Fuz2=1] * 1.0 XMSubMetaSx_00 1+ Sexy Words * 0.0 T_TooManySym_01 4+ unique symbols in subject * 1.2 XMSubMetaSxObfu_03 Obfuscated Sexy Noun-People X-Spam-DCC: XMission; sa02 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;Eugene Syromiatnikov X-Spam-Relay-Country: X-Spam-Timing: total 767 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 2.9 (0.4%), b_tie_ro: 1.89 (0.2%), parse: 1.41 (0.2%), extract_message_metadata: 27 (3.6%), get_uri_detail_list: 5 (0.7%), tests_pri_-1000: 10 (1.3%), tests_pri_-950: 2.1 (0.3%), tests_pri_-900: 1.66 (0.2%), tests_pri_-400: 39 (5.1%), check_bayes: 37 (4.8%), b_tokenize: 16 (2.0%), b_tok_get_all: 9 (1.2%), b_comp_prob: 4.8 (0.6%), b_tok_touch_all: 3.6 (0.5%), b_finish: 0.83 (0.1%), tests_pri_0: 669 (87.3%), check_dkim_signature: 0.96 (0.1%), check_dkim_adsp: 7 (0.9%), tests_pri_500: 8 (1.1%), rewrite_mail: 0.00 (0.0%) Subject: Re: [GIT PULL] siginfo fix for v4.16-rc5 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 in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Eugene Syromiatnikov writes: > So, the offset of the si_lower field is 20 at the current HEAD and was 18 at > commits v4.16-rc3~17^2 and v4.16-rc1~159^2~20. I believe this is due to > the fact that m68k uses 2-byte default alignment and not 4-byte. A 2-byte alignment for 4 byte pointers. That is a new one to me. Euguene can you test the patch below. It should be fully robust against this kind of craziness. It certainly passes my BUILD_BUG_ON tests for m68k. Eric From: "Eric W. Biederman" Date: Mon, 2 Apr 2018 14:45:42 -0500 Subject: [PATCH] signal: Correct the offset of si_pkey and si_lower in struct siginfo on m68k The change moving addr_lsb into the _sigfault union failed to take into account that _sigfault._addr_bnd._lower being a pointer forced the entire union to have pointer alignment. The fix for _sigfault._addr_bnd._lower having pointer alignment failed to take into account that m68k has a pointer alignment less than the size of a pointer. So simply making the padding members pointers changed the location of later members in the structure. Fix this by directly computing the needed size of the padding members, and making the padding members char arrays of the needed size. AKA if __alignof__(void *) is 1 sizeof(short) otherwise __alignof__(void *). Which should be exactly the same rules the compiler whould have used when computing the padding. I have tested this change by adding BUILD_BUG_ONs to m68k to verify the offset of every member of struct siginfo, and with those testing that the offsets of the fields in struct siginfo is the same before I changed the generic _sigfault member and after the correction to the _sigfault member. I have also verified that the x86 with it's own BUILD_BUG_ONs to verify the offsets of the siginfo members also compiles cleanly. Cc: stable@vger.kernel.org Reported-by: Eugene Syromiatnikov Fixes: 859d880cf544 ("signal: Correct the offset of si_pkey in struct siginfo") Fixes: b68a68d3dcc1 ("signal: Move addr_lsb into the _sigfault union for clarity") Signed-off-by: "Eric W. Biederman" --- include/linux/compat.h | 6 ++++-- include/uapi/asm-generic/siginfo.h | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/linux/compat.h b/include/linux/compat.h index e16d07eb08cf..d770e62632d7 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -221,6 +221,8 @@ typedef struct compat_siginfo { #ifdef __ARCH_SI_TRAPNO int _trapno; /* TRAP # which caused the signal */ #endif +#define __COMPAT_ADDR_BND_PKEY_PAD (__alignof__(compat_uptr_t) < sizeof(short) ? \ + sizeof(short) : __alignof__(compat_uptr_t)) union { /* * used when si_code=BUS_MCEERR_AR or @@ -229,13 +231,13 @@ typedef struct compat_siginfo { short int _addr_lsb; /* Valid LSB of the reported address. */ /* used when si_code=SEGV_BNDERR */ struct { - compat_uptr_t _dummy_bnd; + char _dummy_bnd[__COMPAT_ADDR_BND_PKEY_PAD]; compat_uptr_t _lower; compat_uptr_t _upper; } _addr_bnd; /* used when si_code=SEGV_PKUERR */ struct { - compat_uptr_t _dummy_pkey; + char _dummy_pkey[__COMPAT_ADDR_BND_PKEY_PAD]; u32 _pkey; } _addr_pkey; }; diff --git a/include/uapi/asm-generic/siginfo.h b/include/uapi/asm-generic/siginfo.h index 4b3520bf67ba..6d789648473d 100644 --- a/include/uapi/asm-generic/siginfo.h +++ b/include/uapi/asm-generic/siginfo.h @@ -94,6 +94,9 @@ typedef struct siginfo { unsigned int _flags; /* see ia64 si_flags */ unsigned long _isr; /* isr */ #endif + +#define __ADDR_BND_PKEY_PAD (__alignof__(void *) < sizeof(short) ? \ + sizeof(short) : __alignof__(void *)) union { /* * used when si_code=BUS_MCEERR_AR or @@ -102,13 +105,13 @@ typedef struct siginfo { short _addr_lsb; /* LSB of the reported address */ /* used when si_code=SEGV_BNDERR */ struct { - void *_dummy_bnd; + char _dummy_bnd[__ADDR_BND_PKEY_PAD]; void __user *_lower; void __user *_upper; } _addr_bnd; /* used when si_code=SEGV_PKUERR */ struct { - void *_dummy_pkey; + char _dummy_pkey[__ADDR_BND_PKEY_PAD]; __u32 _pkey; } _addr_pkey; }; -- 2.14.1