Received: by 10.213.65.68 with SMTP id h4csp3585122imn; Tue, 3 Apr 2018 07:30:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/xGfpDcmFn5uiMqDDiFS3KHfs8Cmp5hM61X2MCACfwdfB5fBd/yDb0kAWz4zlmyvf2e3ia X-Received: by 2002:a17:902:ba81:: with SMTP id k1-v6mr14562689pls.170.1522765802427; Tue, 03 Apr 2018 07:30:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522765802; cv=none; d=google.com; s=arc-20160816; b=SphiSuXqZM2BcINyPqJw3KwZQDmILfKXP+/uI22od5y5Z8hA2hI4lq2N724wTjd8lk 7h0HxzG+0ZgdxA5VvHuTu9qdaoSpWn0HEfcs2kYOIpjwEiRwta11tVZnbGTcJ83pD3U3 dawLFHwxgdoZNa7dAcMLomTl3skktH1EEVv7D4bXM8qymvRf72Rd5j0g3bfpiRibmPk6 0RXtVQKA+xIVI+e0QWAA8STZCr4UDl00R7hKUaneggS9Fu8X8q3Ic7xXqKlrQSWow6rl 87zyql91/QQYkDvvlh4JMfTpTX9ZI0R0009QVBsGyYKV97mhCL8Rh8La4her63Jq6n/o l72g== 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=iCvhgkgACgHcfJQ0mxLW47WHLtE/zKVP08nmI+DGbaE=; b=FHZVe2//mWtTp29mqhIxdxXNHi8QO7/gwQQ12AhJ7x0tOKZKhQnFvpmAjYxpay4RQF MlFhLRpBBCNUOblFRbPRWfsXEqN8D3FZXIq9PWVuuZudUZpvoKVdOGvAEN+iOUTB8JNl ybp0Lgcph/Dqb2rttKAIDOr9Tfd5BcJJxUo2yJ5ruQplVW61t4i8EbSicJRJ+jFoS+XA INJ9LdGLl36jg8b8gweHbwco7OJEztPB6m6KFpkmQGfrIf8d+D2k8u1tE07am63gtQBO VMy93SyIjHSDv03O3hauBqTqEEbCox5JW2QGzVoU9AAL8IP1KFl3e4+7Qk5mP/UZ/Xn+ zPgw== 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 y12-v6si699161pll.318.2018.04.03.07.29.46; Tue, 03 Apr 2018 07:30:02 -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 S1751346AbeDCO2b (ORCPT + 99 others); Tue, 3 Apr 2018 10:28:31 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:58197 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750786AbeDCO21 (ORCPT ); Tue, 3 Apr 2018 10:28:27 -0400 Received: from in01.mta.xmission.com ([166.70.13.51]) by out01.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1f3MvC-0007qr-6O; Tue, 03 Apr 2018 08:28:26 -0600 Received: from 67-3-145-25.omah.qwest.net ([67.3.145.25] helo=x220.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1f3MvB-00039X-75; Tue, 03 Apr 2018 08:28:25 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Geert Uytterhoeven Cc: Eugene Syromiatnikov , Linus Torvalds , Linux Kernel Mailing List , "Linux\/m68k" References: <87woypy8zc.fsf@xmission.com> <20180331105658.GA4332@asgard.redhat.com> <87woxpz7k9.fsf@xmission.com> Date: Tue, 03 Apr 2018 09:27:18 -0500 In-Reply-To: (Geert Uytterhoeven's message of "Tue, 3 Apr 2018 09:30:36 +0200") Message-ID: <87in98xt4p.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=1f3MvB-00039X-75;;;mid=<87in98xt4p.fsf@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=67.3.145.25;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1+ddgsCL4Dwtb/AD3nALiPHJriQZ2JzMRs= X-SA-Exim-Connect-IP: 67.3.145.25 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa04.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.1 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 * [sa04 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject * 1.2 XMSubMetaSxObfu_03 Obfuscated Sexy Noun-People * 1.0 XMSubMetaSx_00 1+ Sexy Words X-Spam-DCC: XMission; sa04 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;Geert Uytterhoeven X-Spam-Relay-Country: X-Spam-Timing: total 401 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 2.7 (0.7%), b_tie_ro: 1.80 (0.4%), parse: 1.01 (0.3%), extract_message_metadata: 16 (4.1%), get_uri_detail_list: 4.1 (1.0%), tests_pri_-1000: 7 (1.7%), tests_pri_-950: 1.25 (0.3%), tests_pri_-900: 0.97 (0.2%), tests_pri_-400: 36 (9.1%), check_bayes: 35 (8.8%), b_tokenize: 12 (2.9%), b_tok_get_all: 13 (3.1%), b_comp_prob: 2.8 (0.7%), b_tok_touch_all: 5 (1.3%), b_finish: 2.00 (0.5%), tests_pri_0: 326 (81.2%), check_dkim_signature: 0.57 (0.1%), check_dkim_adsp: 3.0 (0.7%), tests_pri_500: 7 (1.6%), 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 in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Geert Uytterhoeven writes: > Hi Eric, > > On Mon, Apr 2, 2018 at 10:17 PM, Eric W. Biederman > wrote: >> 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. > > Not just for pointers, also for int and long. > And m68k is not the only architecture having such alignment rules. The smallest I have seen previously has been 64bit integers having 32bit alignment. 32bit entities having only 16bit alignment on a 32bit arch was simply a surprise. Even when it works there tend to be good reasons not to do that by default. >> 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. > > __alignof__(void *) is 2 not 1 on m68k. I was not expecting __alignof__(void *) to be 1 on m68k. I was testing for anything crazier than m68k. Since there used to be a short in the hole. If your alignment is less than sizeof(short) aka 2 we do need two bytes of pad in there. >> 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)) > > On m68k, __alignof__(compat_uptr_t) == 2, so it will use > __alignof__(compat_uptr_t) padding bytes. > > Note that while the test is wrong, the end result is correct :-) > > Hence you could just use __alignof__(compat_uptr_t) padding bytes > unconditionally? Unless there is something crazier than m68k that only needs 1 byte alignment for pointers. In which case this code really needs 2 padding bytes to avoid introducing a regression there as historically there was a short in the padding hole. So I don't see anything wrong with the test. >> 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 *)) > > Likewise. > >> 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; >> }; > > Gr{oetje,eeting}s, > > Geert