Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1311186

[PATCH] Add compile-time check for __ARCH_SI_PREAMBLE_SIZE

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From Helge Deller <deller@gmx.de>
Newsgroups linux.kernel
Subject [PATCH] Add compile-time check for __ARCH_SI_PREAMBLE_SIZE
Date Sun, 17 Jan 2016 22:10:01 +0100
Message-ID <qS2Kd-7RE-1@gated-at.bofh.it> (permalink)
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 robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 41
Organization linux.* mail to news gateway
X-Original-Cc Stephen Rothwell <sfr@canb.auug.org.au>, Michael Ellerman <mpe@ellerman.id.au>
X-Original-Date Sun, 17 Jan 2016 22:00:46 +0100
X-Original-Message-ID <20160117210046.GA11472@ls3530.box>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1311186

Show key headers only | View raw


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 <deller@gmx.de>
 
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);
 }
 

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH] Add compile-time check for __ARCH_SI_PREAMBLE_SIZE Helge Deller <deller@gmx.de> - 2016-01-17 22:10 +0100

csiph-web