Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp569148pxy; Fri, 30 Apr 2021 11:13:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbvMLI3OK5wyNpR8P2V4V6wN+yeDQ+uqV+YDwn67B0sgjJip4EahqD7HXHx61wMKsHhQox X-Received: by 2002:a17:90a:e645:: with SMTP id ep5mr16344260pjb.143.1619806424995; Fri, 30 Apr 2021 11:13:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619806424; cv=none; d=google.com; s=arc-20160816; b=JM9v9sP7KzulpjmToH9S4KgBUAlxW3EiVZNKUOA/sXgsFJZ1POBlBy36DgMotXQeQg v37wi9my2zVoCOg3PQ1XStX9K0qmBh2buRUj2RkvoHRfPan89zOUxaX8+MD9hpaTOPVI Ufy2GNnmiEiJevJJzuDW2bBlncJu1D8LPO8kS7FelzZgzX/nh4IDJ/WbxEeWv9jeH9Zn VdME0pvx1pq4GmApehmoUUO7+LXMGtd5A0YPZUNYc2DWHutKQrjwL6eVSPpbm3riuWrM dd+SbmnorBAdwx2VA+VS62bjD9Zony2PTHCgiGqdsN56Ti9X6UpQ+Z8e9z+vrNgTyDA0 dkSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=vf2+S1x6r/e/FcKWzWWIRvMeVi3Dg4asX+PnCt1Zm1M=; b=AZYahnARJOGN/I9sfuchCdc3OF0RB1RmA72KrQ0Z7nrio8Rqt9Y/cafGOmVPZaCGJW Vi+tqDEgg+dJ+QNwTkLhCba6z3UFRCoJL4AkdCkep2pu3r+Q8xPiuBSz3vvZT4yxZdt3 bXppJyHapZuS5AyAKfbt+8BiRCk0eSrJ7Y5slCexM7JyPi0K7ppK5m72VotiTMcv0/st x9lxmsLD/DnBLPdskqpfvrf6E4QXNRWBYCFhN1sqmT9Ob+GQ0oHQYgVWOvs3UIps6Uei E5rZhDtOoDId6dV89z83S4kLSnPDYxwYOV8YkRJTQZ/3qLRl/x9K05SF6aeMqFAjqwiE Rb7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=BdzY8EOh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k8si3165565pfd.141.2021.04.30.11.13.30; Fri, 30 Apr 2021 11:13:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=BdzY8EOh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230329AbhD3SM2 (ORCPT + 99 others); Fri, 30 Apr 2021 14:12:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230356AbhD3SM1 (ORCPT ); Fri, 30 Apr 2021 14:12:27 -0400 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0CDAC06138B for ; Fri, 30 Apr 2021 11:11:38 -0700 (PDT) Received: by mail-ot1-x331.google.com with SMTP id 65-20020a9d03470000b02902808b4aec6dso60424964otv.6 for ; Fri, 30 Apr 2021 11:11:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vf2+S1x6r/e/FcKWzWWIRvMeVi3Dg4asX+PnCt1Zm1M=; b=BdzY8EOhoBQLTLtrVJMYviKEWJlUGJb4q8AoIXnB9KZMggfTz9LDL3Lr9vOR6ZpH13 y4UMwzaN2tWVSm3h9bLgXcM8pjfp/EWXhNMJzrw8JweoLuSnFXFmmEut+vxb/RpxKPFk KS8edKMlFL6AF99NnjkC5H5mybGYPAnJRFUM+os1Iy+nppzVamfYx1Slf1+v2+c3Ymio 7ozrLVU/NDeeaM+/u0eQEw1IRf/WQ5xzq9Py5Crg0CPc7EcRbocZ505dcbP5QGk1U6xg GfqvB0CkXG42IOxTtquxQhWDBUp/sPEvlwrY91NI2vjO2AiVjmJqAaj8vT2Bml6fltMM VmuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vf2+S1x6r/e/FcKWzWWIRvMeVi3Dg4asX+PnCt1Zm1M=; b=eeQoV6FhGZHvweyTKF0Hv/kv5nhUw19ZgQnS6RWksXIKKU4MXj66/bMRC/EixICkct coNFjO943RZbRlSMQwHp0cV88wjtaOWXJOj3XsHg8GqssBhQ4JG7+mi+uHavKc4j8GKs qYjd67kDHk3IEC8rCVzeAx1nCXZog3pndhnZ5fhyiQSAk0086G/ZOUQ/riXgHnuDAAFJ 3e/NM2Z7vKTs4N3RNrhT6ZIvz+DO4linwBfJzxuxpP0Hv97jd/CqrSP0LI9o6FptUfN+ WLIzGKZ/0i13g4PGgQKxVB0ISBxMQscYeBbyi3gF/qp0WVNmOvMfQgRb3m9CcoDtoCXm dMTg== X-Gm-Message-State: AOAM530Ln6kJUqvE4gUy09VWD6gU0gerQfQ3tntEORNrBzgpFylieZMv RFR3m7AHoP2T69UWJ0lV8D+MZAMFATNizABEfnSXNyNFiw8= X-Received: by 2002:a9d:60c8:: with SMTP id b8mr4635783otk.17.1619806298042; Fri, 30 Apr 2021 11:11:38 -0700 (PDT) MIME-Version: 1.0 References: <20210429190734.624918-1-elver@google.com> In-Reply-To: From: Marco Elver Date: Fri, 30 Apr 2021 20:11:26 +0200 Message-ID: Subject: Re: [PATCH 1/3] sparc64: Add compile-time asserts for siginfo_t offsets To: "Eric W. Biederman" Cc: Russell King - ARM Linux admin , Catalin Marinas , Will Deacon , "David S. Miller" , Mark Rutland , Linux ARM , LKML , sparclinux@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 30 Apr 2021 at 19:42, Eric W. Biederman wrote: > > Marco Elver writes: > > > 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. > > Arnd Bergman recently pointed out that we can move si_trapno into the > union and make it specific to a handful of signals. Like we do other > items in the union. > > Given that the code of perf_sigtrap is pretty much broken if si_trapno > needs to be filled out. I think we should make that change before > we set this ABI in stone like this. > > Otherwise this looks good. Thanks, that's reasonable -- I'll reply to the other thread in a few minutes. -- Marco > Eric > > > Link: https://lkml.kernel.org/r/m11rat9f85.fsf@fess.ebiederm.org > > Suggested-by: Eric W. Biederman > > Signed-off-by: Marco Elver > > --- > > 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);