From patchwork Thu Apr 29 19:07:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Elver X-Patchwork-Id: 12231795 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 1DA19C43460 for ; Thu, 29 Apr 2021 19:09:54 +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 90E4B61449 for ; Thu, 29 Apr 2021 19:09:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 90E4B61449 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:Mime-Version:Message-Id:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=DG/qQL497qLO5nt+d4TK4LfM4SyMNU031GM4Vtxgq4g=; b=bBoOC206/Rj6Eon9bBDrSDq8XE Ya0OhHmP7q7Fb8rWPhlSLHOrA66JY6qWjWrOo2YUXthz8ihubvPXw7cD001QsilhixGKioeO82BOW eoELPhSmMvH7j4sW+PkdXiHIcA8WEQi1A2yslu1mNz4heMp+e4Jvw4qcf3WBIzo4V3pqCLyBM2UmB VQQhMN0o82H/6saFnySYSOTp+L89r16ZZc2kbZ9XbrMfaxP6hDfQ9ccsnKtU9vSvHkSkYBD5y3Uzu +N2SbxbTyf+NDVyKKcllblhKpazE35y8NuM0nUEI+I9NlvlGDv0HoHT/aa5YLf8O0CQ0EwO9/AVS5 93DMmE0g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lcC1F-006EsD-NQ; Thu, 29 Apr 2021 19:08:14 +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 1lcC13-006ErM-P4 for linux-arm-kernel@desiato.infradead.org; Thu, 29 Apr 2021 19:08:01 +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: Mime-Version:Message-Id:Date:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To:References; bh=a+M03Ojo2ep3ZRi34mKtUekE+PIXB83y3AJCXMraWzo=; b=u4t8IxZpob9W0rF0vvNXMyp5ty +nlnXxYVhZQQxGbRBL8jEfmXGUKKi/VKAsRJ+muB1Y4pFZI63+ZTwokZ+t5GtQRd0vU+ARwpeCX32 yQ8QnsP4TSyYIV7bqysh/pw/eoCnnPtz9OtTdm8rix+iyVx3FKE5504uT1kfH65uKl3rn3d/wDAnO JsXft1SwnDA8InqZfgHnPvbkwqOKbLIgucgb5LGTZXx6804xp+N29LcFDhJUEmZGmQFT0+95u8HZC Mg+h1c4NDWEwQ80wAJV834ppKTRLyjjwXoRf9+qK22VsKM/RsEImZwfDog2nq9aaHxB15bBtBwSPe xXYAj3cg==; Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lcC10-000sVC-Jh for linux-arm-kernel@lists.infradead.org; Thu, 29 Apr 2021 19:08:00 +0000 Received: by mail-wr1-x44a.google.com with SMTP id 93-20020adf83660000b029010d6b1e0949so3710269wrd.3 for ; Thu, 29 Apr 2021 12:07:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=a+M03Ojo2ep3ZRi34mKtUekE+PIXB83y3AJCXMraWzo=; b=dF9WJLioSQrbRuzCoNwwUPt/Vr8RLQvQyQyo0LOsjAWYk3FM7a+nBqYqettaUNAlHa LiiTz1VGyiB+mykTMwMpeky8vvhoXMMUkWzQhh9qLmw34bugTcqySao7tleast8c469n mKLzci3S4T7bmY+tjxRBZkJVvu3H0vxlySV1fPvpHl/g+2NuEs0zv5XxBIkqwaLWX5Xf tE/a6xOOsLQ7ukUvb0tNay98YLQrFMVfm8vBxxuj+gkBPTue2rY2GErFnLTLjYr0C6pP h40iwUYuB60pwe4+YNd7YDP/yNBBflO0HATK8xylCNstpMKY4Vaw9pnIRfR9tjWRti+M gtdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=a+M03Ojo2ep3ZRi34mKtUekE+PIXB83y3AJCXMraWzo=; b=hQzMq7uXk4Hhf8FiJFHDcq9+7g4J+5wrndM/8FbZ0BLYyC0oXgbxWYZC2tXKdK8O3E mvSTITo938c/D+A+/OhfeZ1pxu2m8A8I85JG/eTyMq9SqLc3aBOLCQoHhE1HY8A/1suq P28X2QnpLskj0L6+Ta9Sj2pCQQz9q+t5VDYdnI7T07BoGBpSxItaMbNELtkbutOqx6fr kZvSSWTKAMwLybBT0hVUrGAYaItVllMDkoxMcx9wWSkF4VIpfjh6eNPLAMsObZtabjvk q15AuKKdxTxfOnkjUCRp4NLg+VtAPO3bO1426HFafZM1E/gjwdjkl+VdHU9OPYgDoJoU Y3TA== X-Gm-Message-State: AOAM5325k1H0oADsFCNzVWOZA+YQcyA1PDBnzEXLZ86gKbeaJ9KIlx92 3juQ2vg6TqXIZnhH2kA8hrcPMEbCrw== X-Google-Smtp-Source: ABdhPJzlg1wh/uLXKKhwRP5BcTAKO6bbMsP7iOQaaVlBytkU4SUateXusjlaHr17ej3J+IyJeoI9N2H4hA== X-Received: from elver.muc.corp.google.com ([2a00:79e0:15:13:4399:f8b0:aefa:628]) (user=elver job=sendgmr) by 2002:a1c:c915:: with SMTP id f21mr1249320wmb.0.1619723271698; Thu, 29 Apr 2021 12:07:51 -0700 (PDT) Date: Thu, 29 Apr 2021 21:07:32 +0200 Message-Id: <20210429190734.624918-1-elver@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.1.527.g47e6f16901-goog Subject: [PATCH 1/3] sparc64: 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_120758_669099_BB7DD8AA X-CRM114-Status: UNSURE ( 9.14 ) 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. Unlike other architectures, sparc64 is special, because it is one of few architectures requiring si_trapno. ABI breaks around that field would only be caught here. Link: https://lkml.kernel.org/r/m11rat9f85.fsf@fess.ebiederm.org Suggested-by: Eric W. Biederman Signed-off-by: Marco Elver Acked-by: David S. Miller --- arch/sparc/kernel/signal32.c | 34 ++++++++++++++++++++++++++++++++++ arch/sparc/kernel/signal_64.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/arch/sparc/kernel/signal32.c b/arch/sparc/kernel/signal32.c index e9695a06492f..778ed5c26d4a 100644 --- a/arch/sparc/kernel/signal32.c +++ b/arch/sparc/kernel/signal32.c @@ -745,3 +745,37 @@ asmlinkage int do_sys32_sigstack(u32 u_ssptr, u32 u_ossptr, unsigned long sp) out: return ret; } + +/* + * 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_trapno) == 0x10); +static_assert(offsetof(compat_siginfo_t, si_addr_lsb) == 0x14); +static_assert(offsetof(compat_siginfo_t, si_lower) == 0x18); +static_assert(offsetof(compat_siginfo_t, si_upper) == 0x1c); +static_assert(offsetof(compat_siginfo_t, si_pkey) == 0x18); +static_assert(offsetof(compat_siginfo_t, si_perf) == 0x14); +static_assert(offsetof(compat_siginfo_t, si_band) == 0x0c); +static_assert(offsetof(compat_siginfo_t, si_fd) == 0x10); diff --git a/arch/sparc/kernel/signal_64.c b/arch/sparc/kernel/signal_64.c index a0eec62c825d..c9bbf5f29078 100644 --- a/arch/sparc/kernel/signal_64.c +++ b/arch/sparc/kernel/signal_64.c @@ -556,3 +556,36 @@ void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0, unsigned long user_enter(); } +/* + * 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_trapno) == 0x18); +static_assert(offsetof(siginfo_t, si_addr_lsb) == 0x20); +static_assert(offsetof(siginfo_t, si_lower) == 0x28); +static_assert(offsetof(siginfo_t, si_upper) == 0x30); +static_assert(offsetof(siginfo_t, si_pkey) == 0x28); +static_assert(offsetof(siginfo_t, si_perf) == 0x20); +static_assert(offsetof(siginfo_t, si_band) == 0x10); +static_assert(offsetof(siginfo_t, si_fd) == 0x14);