From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752734AbcAQVBG (ORCPT ); Sun, 17 Jan 2016 16:01:06 -0500 Received: from mout.gmx.net ([212.227.17.21]:64446 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752554AbcAQVBE (ORCPT ); Sun, 17 Jan 2016 16:01:04 -0500 Date: Sun, 17 Jan 2016 22:00:46 +0100 From: Helge Deller To: Linus Torvalds , Andrew Morton , linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Stephen Rothwell , Michael Ellerman Subject: [PATCH] Add compile-time check for __ARCH_SI_PREAMBLE_SIZE Message-ID: <20160117210046.GA11472@ls3530.box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Provags-ID: V03:K0:JQKwnbDSHwD5VkkTJZm0pxdbcDhTlpaOH25RZ3mYbu2ujkSwO7N A4ku4729j+uDpZPmM1y11xAo5o0wDKuTYx8DmEbaaVZrTFwanOdnGAyYCzC9Eex67+91EE/ vRyKU8ZAgUUYUM6VIAC+pqSj8f9JJtCNOugX69pwlpt4VPxA9uMn9pHRWpeAhRMuO4irfnX qN+tFhqxnOYkuyi4lLj5Q== X-UI-Out-Filterresults: notjunk:1;V01:K0:zbqBTUEdpg8=:gvDHZ973RNE8pj6RAOuVl0 RjfpKGhhA8YE3vBXIPbYOnkeOEfTdJhm4Tm7hZKdpOITzt0Z5oCuE0Rcv+j2i8NSSTb4sPVWB kckRWP9xMuaA8Wln9voiUcC6/ZRJIGK9XXpdmbiMpniHICIzs7vbLYoP5PkVtpamG2Epmior8 n22yI489sf1nmb64Lcl44LUT4dUQIAKPTxQCMXl6cY2YpX+FCPBwHWmSBsQHyPu2ujkhQG/o7 AoJFQBkgSHbDSMmqjXDNe8zxuSZJVjx3Ij3YwnRTIOyw7GVawlQ7EJzGjP9/Pv15FekFWr6oG 397bgy2ErhuaFTKtzv3tXrCbw+6RHHYWY0M9i11226UU0Kv1YlwBJT1XXw+BGAuLWeJFvpS2B pDAo/sQoZnMQiO94WVZQ+WegTa2IdrPE+T3AxckoTY1ugzsmIYkl4vY2Gm80X5aLviHkO0eyu stYYFn2s8WW6v1QphHVIQdeIAtlCAYq28Np90Qp8y/BJFx7NtXd5XDGb7w7CHkhW25OgvgNNR AEHCDrcGuB3SN/6VF6ia70tqA56dm1yDL8/D2Jcen99HFvVgWNtEx9vuhenWYRGnTz2by0/Xs JLRJF2ZJty2BfX6WijrofB+K4oC/R5SbAj2mkbqPD8uXh1BfXJZcfYw0+xgmJrx/dSm4Qj4Oi VaUsjjIcXsCscCFaHdV0Q18Cmo3LB1cYohMoKM1hswT8QRS9X1aS2kMxoPvPW3Bh1u+BtTQ5w ahkF9pJfAHuucx67TlEEMC15JwFDWI/frH4qB7ohtBC/WnllF2GtMNtO7mk= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The value of __ARCH_SI_PREAMBLE_SIZE defines the size (including padding) of the part of the struct siginfo that is before the union, and it is then used to calculate the needed padding (SI_PAD_SIZE) to make the size of struct siginfo equal to 128 (SI_MAX_SIZE) bytes. Depending on the target architecture and word width it equals to either 3 or 4 times sizeof int. Since the very beginning we had __ARCH_SI_PREAMBLE_SIZE wrong on the parisc architecture for the 64bit kernel build. It's even more frustrating, because it can easily be checked at compile time if the value was defined correctly. This patch adds such a check for the correctness of __ARCH_SI_PREAMBLE_SIZE in the hope that it will prevent existing and future architectures from running into the same problem. I refrained from replacing __ARCH_SI_PREAMBLE_SIZE by offsetof() in copy_siginfo() in include/asm-generic/siginfo.h, because a) it doesn't make any difference and b) it's used in the Documentation/kmemcheck.txt example. I ran this patch through the 0-DAY kernel test infrastructure and only the parisc architecture triggered as expected. That means that this patch should be OK for all major architectures. Signed-off-by: Helge Deller diff --git a/kernel/signal.c b/kernel/signal.c index f3f1f7a..1ccd218 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -3579,6 +3579,10 @@ __weak const char *arch_vma_name(struct vm_area_struct *vma) void __init signals_init(void) { + /* If this check fails, the __ARCH_SI_PREAMBLE_SIZE value is wrong! */ + BUILD_BUG_ON(__ARCH_SI_PREAMBLE_SIZE + != offsetof(struct siginfo, _sifields._pad)); + sigqueue_cachep = KMEM_CACHE(sigqueue, SLAB_PANIC); }