Received: by 10.213.65.68 with SMTP id h4csp652451imn; Fri, 6 Apr 2018 06:48:50 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/62WTe2jTFzfOjP9jKazSyfE/GbkpYish28kHaVeoNX71SiSavZo2m4vatSQntmSNjUG6P X-Received: by 10.101.99.193 with SMTP id n1mr10651899pgv.446.1523022530809; Fri, 06 Apr 2018 06:48:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523022530; cv=none; d=google.com; s=arc-20160816; b=uBEYdydefAjcwdJxaFOFMSRLT7A5M0KXU1w3nE1rx6qPxc0q7cANBBZQKmD3ld/u3r n8uFOsfKgQW4dngtYc1x2Za/z2dPXsAiK/1My8FAyDTkqsBxddqsvaeRxyXh9q57aH/l Bojs09VpoMyE7UdTcWKgwp7//sV2lIVqbqIH+aqp1xHi21bk6ybGkV0KyjEo51pHKvo9 JdVrzF8IIDJm4r6He4XVvZtTxZchDnKu5bxrZZQHrZmD3IIs1wgG/SG0J0WDE+zScY6A qsgGK1oN/UEv0GOfoBQe6bKkCgb7i9PclyM2RNN0vuAJ5GanZFW1W8f8+5BphpQ1SbaL pQzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=btgRWoHiAyCRJWI9H4KW6dPjZSKVfYlce/4uKDOmvxM=; b=FfaJs91NyV/YsUcVAmnMp97Sa4yQU5a3e0pujv9DLkFYtopJWDA7Cq2Avq/3vyumEc hv7Vp+qYzY3l1LY2hFHDrN3XZ/FQmFDr4Spqm8ty0JO8iJREdVdMnhOqHmFCTcZ9PSzv EUZUaH2j7gKl6670w3lecZxprSMILOEFicCF945r1NbU7yqs9o0FCH+w4934Jv/ATNzQ HvzgiUjyTGabwe+VDyMCv3Sr+ZxGQv/+6y9OVl3aM4RbeE/8B/O5gzLFNaIBDgRzf2fE x273c5VRl29Qxni9RqGXUL6vjD1wj9rMqLP1mskotBj0UJERFQtWg5wWl2s3fzbEaAeF muDw== 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 z131si7339902pgz.184.2018.04.06.06.48.36; Fri, 06 Apr 2018 06:48:50 -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 S933050AbeDFNpX (ORCPT + 99 others); Fri, 6 Apr 2018 09:45:23 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38066 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756966AbeDFNpV (ORCPT ); Fri, 6 Apr 2018 09:45:21 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 78CE2E1D; Fri, 6 Apr 2018 13:45:20 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eugene Syromiatnikov , "Eric W. Biederman" Subject: [PATCH 4.16 31/31] signal: Correct the offset of si_pkey and si_lower in struct siginfo on m68k Date: Fri, 6 Apr 2018 15:24:56 +0200 Message-Id: <20180406084345.131141646@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084340.999820380@linuxfoundation.org> References: <20180406084340.999820380@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric W. Biederman commit 8420f71943ae96dcd78da5bd4a5c2827419d340c upstream. 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" Signed-off-by: Greg Kroah-Hartman --- include/linux/compat.h | 6 ++++-- include/uapi/asm-generic/siginfo.h | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -222,6 +222,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 @@ -230,13 +232,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; }; --- 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; };