From patchwork Thu Apr 29 19:07:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Elver X-Patchwork-Id: 12231797 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08EF7C433ED for ; Thu, 29 Apr 2021 19:09:56 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6506B6143E for ; Thu, 29 Apr 2021 19:09:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6506B6143E Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Cc:To:From:Subject:References:Mime-Version: Message-Id:In-Reply-To:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=W0ZiUx1xmsHgHsiInGL5QF7sPcYdPAMmIIexyMzvjzY=; b=Up/SLSlJlZQ9qx Y0xWwC8SZDgkSGBkL3M3UcqX55s6x/qiJovgJa6SbCoAfOAMypk0FU848CYrHP8SVOqCNLIggX1Hs NDcm/7+akgr2LfWsZcJP9BJrUtaLv6PIDMMj2xlieecm14bNMbadzVS+SWQ+DFHp+1vJyaDPyRU1k 5X6NLl1Is2/W22HcTIWG7Jt8nn5YzyQTn0zCClZRtDrM/EHfdvn++KPsGllfadkvT35+WRqjGvOzI QYRthjrsdLpwdtmdW1Pnmrf0JuG0systL1Sm2hAWsS+vRnGd0Muz1vvm1dp8tcRJuOzYTZDF/ocOs kZEPvtbMRKfkd1PDV7HQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lcC1P-006EuB-At; Thu, 29 Apr 2021 19:08:23 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lcC14-006ErR-Ml for linux-arm-kernel@desiato.infradead.org; Thu, 29 Apr 2021 19:08:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:Cc:To:From:Subject: References:Mime-Version:Message-Id:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=oJ+no8MxPlbWvHNFDInBiefJ29F4R5wPVNRQJ5Temnc=; b=1GgUZCvqql2cy9LcD42IOlrzqc 2uEtv+nyIqvaXx20SatslSxveCRdMvsfP/X/4Jm+vm+3sO5c07Z0pEyHEmFlZ8twjaUGhilnsOiBg UCMqSguH79BvNT7+WYuCDNKIaQBmJ4Mf5Cqu1K6IMeIZKiV3x4VorbLkaqQnFPDxv8DmTY5GCIahz OAfz8wtZyd7i/siTCpwzHPmRMvbLMvIydRbdlG44ef2bq0Cfm15xOAoBzktWPoyMhla8gBTN5+ZLw UQmOVYenWnpjdsDkUwq+va1y3jF/oqzu6c+M0QtjWGVCGnyGMtFEwxKFIJt7r41KmvxQy8xgLPPSa MExHIygw==; Received: from mail-qv1-xf4a.google.com ([2607:f8b0:4864:20::f4a]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lcC11-000sVF-2I for linux-arm-kernel@lists.infradead.org; Thu, 29 Apr 2021 19:08:01 +0000 Received: by mail-qv1-xf4a.google.com with SMTP id l5-20020a0ce0850000b02901c37c281207so1528607qvk.11 for ; Thu, 29 Apr 2021 12:07:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=oJ+no8MxPlbWvHNFDInBiefJ29F4R5wPVNRQJ5Temnc=; b=IVeFbxHDXug434UKphPgczOKwvBRYS+qQ3fyCutaafHrNWOhDI3D5G1ZPU8weSCrVC ABDK1RhMbqsnhiEEFS3k5cbzHTCjpGoeVgufqnrRZYRCIRVtVfM3chH2F4fiRTBIPfzI G6BzqDLSVSo2axo2BBYhHeCzzt56m7iBIXYbKmgSDW5JitqNoKVE4JEQOP5PODUS0OvR WG38zAx2LelmrKLC/gyGPqP3Hbx2rP9I3UEgYSa7M+ssrXqXDEMu13GJBz9No/dPV6Fu G44EDYlVZ1+BMoZeTtmv/KLMMe9DzNEs4vpFMC6NyEaj/xd6o0WU9sf2wf+Ik1e490hS PCjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=oJ+no8MxPlbWvHNFDInBiefJ29F4R5wPVNRQJ5Temnc=; b=JykG7OVMxvrlJGrZR6ZsGgZLu3Ws+Va2bHagdERrRD32NTSGP4QG0rewEwAoxw8dFc zHzfQ74VFrlmdR1Lq0dUpLaXwy7zS+13hI3Sbq/IY0WJ8McVjFefxkmPYtqvJ4YTk8k7 2zEZPVRUG/eQAbWybfQVIl8gNkaoc7feCO3/2MM4NEFxYVW04KokndvjjSwbh0tqyGHQ uhvgeaLMHbnjrYOGknFiRvlOqLlccCA37V9X6QXvlNldCpmkEgkCbUk6UfjzZ3UTiX6M BU0fwxrDP8DZKUrpJtcmVEaGzUoGabDmw4AMxd1/J73JZXdPx84cENwRw4gAuXgBVgNv h6Bw== X-Gm-Message-State: AOAM531eb1l/glv5aW0NB7EMtqJW1cO47eMuyx4cBgh6xxlfXRyizqk1 24TZqbacbEAiAxJUZTdlV4UitfKeDA== X-Google-Smtp-Source: ABdhPJxGZ1gI1KYcCkyLOWFD7/FydYwghLH2n8i8xsMDPoyRpEKqciCBIAxyuvsP3DQKuWqOzQ1+/M10Cw== X-Received: from elver.muc.corp.google.com ([2a00:79e0:15:13:4399:f8b0:aefa:628]) (user=elver job=sendgmr) by 2002:a0c:be92:: with SMTP id n18mr1138333qvi.31.1619723277227; Thu, 29 Apr 2021 12:07:57 -0700 (PDT) Date: Thu, 29 Apr 2021 21:07:34 +0200 In-Reply-To: <20210429190734.624918-1-elver@google.com> Message-Id: <20210429190734.624918-3-elver@google.com> Mime-Version: 1.0 References: <20210429190734.624918-1-elver@google.com> X-Mailer: git-send-email 2.31.1.527.g47e6f16901-goog Subject: [PATCH 3/3] arm64: Add compile-time asserts for siginfo_t offsets From: Marco Elver To: elver@google.com, ebiederm@xmission.com Cc: linux@armlinux.org.uk, catalin.marinas@arm.com, will@kernel.org, davem@davemloft.net, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210429_120759_127870_C4E9DB41 X-CRM114-Status: UNSURE ( 8.72 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org To help catch ABI breaks at compile-time, add compile-time assertions to verify the siginfo_t layout. Signed-off-by: Marco Elver --- arch/arm64/kernel/signal.c | 36 ++++++++++++++++++++++++++++++++++++ arch/arm64/kernel/signal32.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 6237486ff6bb..af8bd2af1298 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -973,3 +973,39 @@ void __init minsigstksz_setup(void) round_up(sizeof(struct frame_record), 16) + 16; /* max alignment padding */ } + +/* + * Compile-time assertions for siginfo_t offsets. Check NSIG* as well, as + * changes likely come with new fields that should be added below. + */ +static_assert(NSIGILL == 11); +static_assert(NSIGFPE == 15); +static_assert(NSIGSEGV == 9); +static_assert(NSIGBUS == 5); +static_assert(NSIGTRAP == 6); +static_assert(NSIGCHLD == 6); +static_assert(NSIGSYS == 2); +static_assert(offsetof(siginfo_t, si_signo) == 0x00); +static_assert(offsetof(siginfo_t, si_errno) == 0x04); +static_assert(offsetof(siginfo_t, si_code) == 0x08); +static_assert(offsetof(siginfo_t, si_pid) == 0x10); +static_assert(offsetof(siginfo_t, si_uid) == 0x14); +static_assert(offsetof(siginfo_t, si_tid) == 0x10); +static_assert(offsetof(siginfo_t, si_overrun) == 0x14); +static_assert(offsetof(siginfo_t, si_status) == 0x18); +static_assert(offsetof(siginfo_t, si_utime) == 0x20); +static_assert(offsetof(siginfo_t, si_stime) == 0x28); +static_assert(offsetof(siginfo_t, si_value) == 0x18); +static_assert(offsetof(siginfo_t, si_int) == 0x18); +static_assert(offsetof(siginfo_t, si_ptr) == 0x18); +static_assert(offsetof(siginfo_t, si_addr) == 0x10); +static_assert(offsetof(siginfo_t, si_addr_lsb) == 0x18); +static_assert(offsetof(siginfo_t, si_lower) == 0x20); +static_assert(offsetof(siginfo_t, si_upper) == 0x28); +static_assert(offsetof(siginfo_t, si_pkey) == 0x20); +static_assert(offsetof(siginfo_t, si_perf) == 0x18); +static_assert(offsetof(siginfo_t, si_band) == 0x10); +static_assert(offsetof(siginfo_t, si_fd) == 0x18); +static_assert(offsetof(siginfo_t, si_call_addr) == 0x10); +static_assert(offsetof(siginfo_t, si_syscall) == 0x18); +static_assert(offsetof(siginfo_t, si_arch) == 0x1c); diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c index 2f507f565c48..b6afb646515f 100644 --- a/arch/arm64/kernel/signal32.c +++ b/arch/arm64/kernel/signal32.c @@ -457,3 +457,39 @@ void compat_setup_restart_syscall(struct pt_regs *regs) { regs->regs[7] = __NR_compat_restart_syscall; } + +/* + * Compile-time assertions for siginfo_t offsets. Check NSIG* as well, as + * changes likely come with new fields that should be added below. + */ +static_assert(NSIGILL == 11); +static_assert(NSIGFPE == 15); +static_assert(NSIGSEGV == 9); +static_assert(NSIGBUS == 5); +static_assert(NSIGTRAP == 6); +static_assert(NSIGCHLD == 6); +static_assert(NSIGSYS == 2); +static_assert(offsetof(compat_siginfo_t, si_signo) == 0x00); +static_assert(offsetof(compat_siginfo_t, si_errno) == 0x04); +static_assert(offsetof(compat_siginfo_t, si_code) == 0x08); +static_assert(offsetof(compat_siginfo_t, si_pid) == 0x0c); +static_assert(offsetof(compat_siginfo_t, si_uid) == 0x10); +static_assert(offsetof(compat_siginfo_t, si_tid) == 0x0c); +static_assert(offsetof(compat_siginfo_t, si_overrun) == 0x10); +static_assert(offsetof(compat_siginfo_t, si_status) == 0x14); +static_assert(offsetof(compat_siginfo_t, si_utime) == 0x18); +static_assert(offsetof(compat_siginfo_t, si_stime) == 0x1c); +static_assert(offsetof(compat_siginfo_t, si_value) == 0x14); +static_assert(offsetof(compat_siginfo_t, si_int) == 0x14); +static_assert(offsetof(compat_siginfo_t, si_ptr) == 0x14); +static_assert(offsetof(compat_siginfo_t, si_addr) == 0x0c); +static_assert(offsetof(compat_siginfo_t, si_addr_lsb) == 0x10); +static_assert(offsetof(compat_siginfo_t, si_lower) == 0x14); +static_assert(offsetof(compat_siginfo_t, si_upper) == 0x18); +static_assert(offsetof(compat_siginfo_t, si_pkey) == 0x14); +static_assert(offsetof(compat_siginfo_t, si_perf) == 0x10); +static_assert(offsetof(compat_siginfo_t, si_band) == 0x0c); +static_assert(offsetof(compat_siginfo_t, si_fd) == 0x10); +static_assert(offsetof(compat_siginfo_t, si_call_addr) == 0x0c); +static_assert(offsetof(compat_siginfo_t, si_syscall) == 0x10); +static_assert(offsetof(compat_siginfo_t, si_arch) == 0x14);