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); From patchwork Thu Apr 29 19:07:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Elver X-Patchwork-Id: 12231793 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 BBE62C433ED for ; Thu, 29 Apr 2021 19:09:44 +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 239B061441 for ; Thu, 29 Apr 2021 19:09:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 239B061441 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=3ErNz7VsJNhpvKUPa1UnmyB/lBQdrZ6od2BdvcJ0n+Q=; b=Ujif8evSL9veFd ZxvdxENY6kB/xF1zlbBkhW9My9OXatSG8TBDUYe1VeG+HefzZxt7j+SnTLKRK8HICm39Ai4JUE6Mu F+N2Bi286w7Av00pFKrd6vhPMdV7/lybJtF86In5fN/KwzGIVHiDZnZGuePXKj9EQsonhKUHPjg4a C3wtZpJCwpGMRM3SLYqJVSLOgW5oZeSMEKBJsk7fVnxcSh4qxgVtd15+JOigGyw/Z+kkdbsWYVacg J8bspJoalckV5GytqUhM8HGg1g4898GlHrsCXc8CDM5w6G3ZOdCeKoUsUQuNj0e/OGd8nwKHjkwHU wKSSxdbM+/gnyfmUQ7Qw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lcC15-006ErX-OD; Thu, 29 Apr 2021 19:08:03 +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-006ErL-HC 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: References:Mime-Version:Message-Id:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=zxaAMw4akhCbciRHPnpZSHUl30YIRQsaz3gXR9kG1Po=; b=VEdauYLLx8mFy4+j9VXGPoBK8q WcocnOZ/hQ2znv1z6Hn2hu/l6h1X/lau1iXDpq/01C6J/6M3Fcc2QziaEg6P7gzmvHi15RYf+HG3v CS63QnhLPo6qgi8x9sUKkopkigjv3XtBkzENK2cNsgWpnQ5/yJKNfPFAG9zrwzEeFZm+Od4s5zcSF dqGyOiyH6S859klUz8ZYxoZXPtjIJifyY/VmBlnED9RMAD/IcZv2xwYUAJmzb+awv40Yk2vp6QJZN oChH2TNR/AJGMLaEpHLICaJyiB8rOtmFM1AFaB21b1B6CmKH9tKJIRaE3bUEFYKW94f2XOAC6SmP2 pgLANB8g==; Received: from mail-qt1-x849.google.com ([2607:f8b0:4864:20::849]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lcC10-000sVD-Hp for linux-arm-kernel@lists.infradead.org; Thu, 29 Apr 2021 19:08:00 +0000 Received: by mail-qt1-x849.google.com with SMTP id p8-20020a05622a0488b02901bab8dfa0c5so7988712qtx.1 for ; Thu, 29 Apr 2021 12:07:55 -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=zxaAMw4akhCbciRHPnpZSHUl30YIRQsaz3gXR9kG1Po=; b=d2dcs4BQqMnuAq7Rr2xTHD45zjt6wGFRFpEysevYk2/CGmmxeZMMpXnHYBKDqseXlR BcPpXMVzceP84eBbiOpZI1KIEKAgozCL4pT3/6KT2j2FZ8ODykcyIvKDurPZ8A1zQPQv uawZnMPzGMGpBe9kdh9k44bxDYQ8gNA4DN6IxqUqxuTu2OpoBLeAe0W0AvnxrX6bDjCJ x8HGM7mUjGdt3dFAKlyzhHDLNuaTY0QMI3Qj1M5+2pb/Rm1gkAYyDCHGoptvR/KV/Jnt sZ+hySRgaLsOjMFtDXg65EyqMhCS+J2zK0CX9D8HTPcLa4/9drV1aljrr73oITrCC/nq QMSw== 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=zxaAMw4akhCbciRHPnpZSHUl30YIRQsaz3gXR9kG1Po=; b=W6YNrp8GGm1Q42aVcs/ypthcg+mrZIHMvLEtIbd1ZwRjY5BDJVdkmVKlmQGjwVP6b6 6cW3zlOtAYmZiEzWP50YQ3L6re4vK8Mn9upT+xxcUARL0E6GzOAZIXK7fm67y7twuTc9 Q90QBjgULrGaoKru77ijKYr6R4qfFyDB0PxF84LBre/OacDTWkOwfUSV7rR7QvHk0ph4 KHqXerUAuiRf3L7qxdxtcM7VSdO5EWcTpr0iV5ELHfqQW8YxkWSEbDFieE7z2rtdxOX+ SgqWNs7yUGdD5O0PeV1Jh91UXqc53BLp8FXywYppxbinxTZL32DXvnnXi4AdliSsu0wK v0rg== X-Gm-Message-State: AOAM532vTuS7AKMX4RaEDHsDhFE1PKy1jib74/vX8eX7AChWqxN/F25x 3vA23dGnRf/Q4I05aWRd6A3AigKq0Q== X-Google-Smtp-Source: ABdhPJy/xmZl4EBaLLb/PjEuNHU5XmzVn22MP13ocH+LwGQaeM9nB5FZ38e86gmKR5VieNOLBxZqjEgobw== X-Received: from elver.muc.corp.google.com ([2a00:79e0:15:13:4399:f8b0:aefa:628]) (user=elver job=sendgmr) by 2002:a0c:be11:: with SMTP id k17mr1312693qvg.42.1619723274382; Thu, 29 Apr 2021 12:07:54 -0700 (PDT) Date: Thu, 29 Apr 2021 21:07:33 +0200 In-Reply-To: <20210429190734.624918-1-elver@google.com> Message-Id: <20210429190734.624918-2-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 2/3] arm: 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_627438_0D0A1429 X-CRM114-Status: UNSURE ( 9.26 ) 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. This could have caught that we cannot portably add 64-bit integers to siginfo_t on 32-bit architectures like Arm before reaching -next: https://lkml.kernel.org/r/20210422191823.79012-1-elver@google.com Signed-off-by: Marco Elver --- arch/arm/kernel/signal.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c index a3a38d0a4c85..2dac5d2c5cf6 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -725,3 +725,39 @@ asmlinkage void do_rseq_syscall(struct pt_regs *regs) rseq_syscall(regs); } #endif + +/* + * 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) == 0x0c); +static_assert(offsetof(siginfo_t, si_uid) == 0x10); +static_assert(offsetof(siginfo_t, si_tid) == 0x0c); +static_assert(offsetof(siginfo_t, si_overrun) == 0x10); +static_assert(offsetof(siginfo_t, si_status) == 0x14); +static_assert(offsetof(siginfo_t, si_utime) == 0x18); +static_assert(offsetof(siginfo_t, si_stime) == 0x1c); +static_assert(offsetof(siginfo_t, si_value) == 0x14); +static_assert(offsetof(siginfo_t, si_int) == 0x14); +static_assert(offsetof(siginfo_t, si_ptr) == 0x14); +static_assert(offsetof(siginfo_t, si_addr) == 0x0c); +static_assert(offsetof(siginfo_t, si_addr_lsb) == 0x10); +static_assert(offsetof(siginfo_t, si_lower) == 0x14); +static_assert(offsetof(siginfo_t, si_upper) == 0x18); +static_assert(offsetof(siginfo_t, si_pkey) == 0x14); +static_assert(offsetof(siginfo_t, si_perf) == 0x10); +static_assert(offsetof(siginfo_t, si_band) == 0x0c); +static_assert(offsetof(siginfo_t, si_fd) == 0x10); +static_assert(offsetof(siginfo_t, si_call_addr) == 0x0c); +static_assert(offsetof(siginfo_t, si_syscall) == 0x10); +static_assert(offsetof(siginfo_t, si_arch) == 0x14); 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);