Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1091424pxy; Sat, 1 May 2021 03:34:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4O7nSfhztD4b/r0/CjS3cRZ49WfoIeFMEE5pqKjFu7sn2Pz4OMmoTO1xjV8Kl4xgd/1A8 X-Received: by 2002:a17:902:9349:b029:ed:2b9:5a02 with SMTP id g9-20020a1709029349b02900ed02b95a02mr10097461plp.54.1619865279392; Sat, 01 May 2021 03:34:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619865279; cv=none; d=google.com; s=arc-20160816; b=A8CX5qq3QpbvVta5hcKWy+Wd9Kf4e1PnvNjQ+HqaUDunFPcSLvY/fPiAdDdsr7hlLA YT0IyxTjojtbjU3ZrgUBb+IUDxq1dNogjNgZQsw3/I6c7ZvCxgN7s6nTiMSCtN4Q5qCk RDDyZ2DOo28+H7jngscv9dmyA/GDyULpEjDbNVsNDsi9KCaM02pN2GbB47V0iFk1Jpxy eHtQHWuM3p2D6EsO+/C/IFK+Bh0z0xCZfphZ0YtOo1hHigHmbXnGkNczm1li+EfHgGlq zmft7kjjFWNSgoWdId4QKugFWFInDNfJZ98UnmjazRPlyD5zdl1n0a/cQBJGtkVgul9D td+Q== 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=hdaqve5YvScbUJtoSM3sAOiUvwbsjnuFfVlCkD3R0H0=; b=CFjh/tunLol/WGyq50yCgoKyCDA65GiMdezBiFkpNNE4pjsjZwL96CJUcTfUrPq5ns 3Ra7pkowdKb8CMVWWHjK4VdhP8AU0OUjxt8FFolqO6IvBsZvz30ixpQBrq9ThN7H/uc2 UohZOj/51iGc76WzrLGooeNIzPy2wkThs06zWMemS5TqJdXVDKtETmfAHDdXvE5RP8iB vxMNHs4YDNmtOwK1oZn7vAlpgdWNzYO+6IaU++b0lMPw+4DvVkBFIqu3ooiBW8W19gC2 dt1cxq3X6WL+I4uD0zarGzf6LpahJwvIFv3+o9RoL08RqYdJMuR3tRBNJ3SuNZ8z8l5U Q4aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=q3Ci9b94; 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 a12si7133340pgh.414.2021.05.01.03.34.26; Sat, 01 May 2021 03:34:39 -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=q3Ci9b94; 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 S231912AbhEAKeb (ORCPT + 99 others); Sat, 1 May 2021 06:34:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231886AbhEAKea (ORCPT ); Sat, 1 May 2021 06:34:30 -0400 Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADD31C06138D for ; Sat, 1 May 2021 03:33:39 -0700 (PDT) Received: by mail-ot1-x32b.google.com with SMTP id f75-20020a9d03d10000b0290280def9ab76so772913otf.12 for ; Sat, 01 May 2021 03:33:39 -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=hdaqve5YvScbUJtoSM3sAOiUvwbsjnuFfVlCkD3R0H0=; b=q3Ci9b94QU8r2Q3Wig3IeSiM+ThYbLMl4dvL+/l4LsWoTx7alyreZZogQkWUqGWXkF hSUH0cRc5zXXvqB7FAASko94scJ8HAMZPdG8FRZfawbyG3arYtBy1glACGdOVj8DGqud j1e+aVpRRG3OziwM+0XDK1iyu2RBGv01I3/mEcW9+hy/+fgGEWDWdfDqBaW4lJD0wYDL uAPCYsNY+tTCZNv+AYzXROipzG+rTgfc0TriwWpW2UsDztX8FW5XjiEWnJqhPyspEGHg Ri5BJPh1TeDZwlPlNUV7r92O1PH20djtccFJQBBqtY0HKwmk+uIA42UEdTPGBBzJq51D DWuA== 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=hdaqve5YvScbUJtoSM3sAOiUvwbsjnuFfVlCkD3R0H0=; b=q0HIjUX83otl+iYepgSQ71VwhC8bxWPdmuJd2oAGhjVdntupfeRYX0ZF0TKvrZ155O CyXvUa9u9jRk0ytVcct9AyYffmDTkxzORWtZZPuF9/mZVwuT7drdZ9W/bYiHoaYou8oI UZAjJIgvNq6fv6kt2r+JHKsl0QZU+ObzaTMPeMKexW9ROy3u71hfoKKsrH910tLcUds3 h+BychIjHWYgfSNENofqZ91ohJUf2tVpf7JvOCDVvf8cfNvRtVgbHfRsPol1HF5RqvmS ak+n4E48XC4AtaaLJTWvOVUh/T7TyS4mj3vDYbBaLi5xpTD1QL1TQhlaAbOOrKh/cMDR 524A== X-Gm-Message-State: AOAM5329EfQTMU7BDjig7DtUWgABdu5CfNEKx9hT5/UNQFMGQmMAS4hF A62gvmjFUBp7lFtZ2gqKlI4MaSF/e9t74STsfMi5hw== X-Received: by 2002:a05:6830:410e:: with SMTP id w14mr5442391ott.251.1619865218745; Sat, 01 May 2021 03:33:38 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Marco Elver Date: Sat, 1 May 2021 12:33:27 +0200 Message-ID: Subject: Re: [PATCH 2/3] signal: Implement SIL_FAULT_TRAPNO To: "Eric W. Biederman" Cc: Arnd Bergmann , Florian Weimer , "David S. Miller" , Peter Zijlstra , Ingo Molnar , Thomas Gleixner , Peter Collingbourne , Dmitry Vyukov , Alexander Potapenko , sparclinux , linux-arch , Linux Kernel Mailing List , Linux API , kasan-dev Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 1 May 2021 at 00:54, Eric W. Biederman wrote: > > Now that si_trapno is part of the union in _si_fault and available on > all architectures, add SIL_FAULT_TRAPNO and update siginfo_layout to > return SIL_FAULT_TRAPNO when si_trapno is actually used. > > Update the code that uses siginfo_layout to deal with SIL_FAULT_TRAPNO > and have the same code ignore si_trapno in in all other cases. > > Signed-off-by: "Eric W. Biederman" > --- > fs/signalfd.c | 7 ++----- > include/linux/signal.h | 1 + > kernel/signal.c | 36 ++++++++++++++---------------------- > 3 files changed, 17 insertions(+), 27 deletions(-) > > diff --git a/fs/signalfd.c b/fs/signalfd.c > index 040a1142915f..126c681a30e7 100644 > --- a/fs/signalfd.c > +++ b/fs/signalfd.c > @@ -123,15 +123,12 @@ static int signalfd_copyinfo(struct signalfd_siginfo __user *uinfo, > */ > case SIL_FAULT: > new.ssi_addr = (long) kinfo->si_addr; > -#ifdef __ARCH_SI_TRAPNO > + case SIL_FAULT_TRAPNO: > + new.ssi_addr = (long) kinfo->si_addr; > new.ssi_trapno = kinfo->si_trapno; > -#endif > break; > case SIL_FAULT_MCEERR: > new.ssi_addr = (long) kinfo->si_addr; > -#ifdef __ARCH_SI_TRAPNO > - new.ssi_trapno = kinfo->si_trapno; > -#endif > new.ssi_addr_lsb = (short) kinfo->si_addr_lsb; > break; > case SIL_PERF_EVENT: > diff --git a/include/linux/signal.h b/include/linux/signal.h > index 1e98548d7cf6..5160fd45e5ca 100644 > --- a/include/linux/signal.h > +++ b/include/linux/signal.h > @@ -40,6 +40,7 @@ enum siginfo_layout { > SIL_TIMER, > SIL_POLL, > SIL_FAULT, > + SIL_FAULT_TRAPNO, > SIL_FAULT_MCEERR, > SIL_FAULT_BNDERR, > SIL_FAULT_PKUERR, > diff --git a/kernel/signal.c b/kernel/signal.c > index c3017aa8024a..7b2d61cb7411 100644 > --- a/kernel/signal.c > +++ b/kernel/signal.c > @@ -1194,6 +1194,7 @@ static inline bool has_si_pid_and_uid(struct kernel_siginfo *info) > case SIL_TIMER: > case SIL_POLL: > case SIL_FAULT: > + case SIL_FAULT_TRAPNO: > case SIL_FAULT_MCEERR: > case SIL_FAULT_BNDERR: > case SIL_FAULT_PKUERR: > @@ -2527,6 +2528,7 @@ static void hide_si_addr_tag_bits(struct ksignal *ksig) > { > switch (siginfo_layout(ksig->sig, ksig->info.si_code)) { > case SIL_FAULT: > + case SIL_FAULT_TRAPNO: > case SIL_FAULT_MCEERR: > case SIL_FAULT_BNDERR: > case SIL_FAULT_PKUERR: > @@ -3206,6 +3208,12 @@ enum siginfo_layout siginfo_layout(unsigned sig, int si_code) > if ((sig == SIGBUS) && > (si_code >= BUS_MCEERR_AR) && (si_code <= BUS_MCEERR_AO)) > layout = SIL_FAULT_MCEERR; > + else if (IS_ENABLED(ALPHA) && > + ((sig == SIGFPE) || > + ((sig == SIGTRAP) && (si_code == TRAP_UNK)))) > + layout = SIL_FAULT_TRAPNO; > + else if (IS_ENABLED(SPARC) && (sig == SIGILL) && (si_code == ILL_ILLTRP)) > + layout = SIL_FAULT_TRAPNO; The breakage isn't apparent here, but in later patches. These need to become CONFIG_SPARC and CONFIG_ALPHA. > else if ((sig == SIGSEGV) && (si_code == SEGV_BNDERR)) > layout = SIL_FAULT_BNDERR; > #ifdef SEGV_PKUERR > @@ -3317,30 +3325,22 @@ void copy_siginfo_to_external32(struct compat_siginfo *to, > break; > case SIL_FAULT: > to->si_addr = ptr_to_compat(from->si_addr); > -#ifdef __ARCH_SI_TRAPNO > + break; > + case SIL_FAULT_TRAPNO: > + to->si_addr = ptr_to_compat(from->si_addr); > to->si_trapno = from->si_trapno; > -#endif > break; > case SIL_FAULT_MCEERR: > to->si_addr = ptr_to_compat(from->si_addr); > -#ifdef __ARCH_SI_TRAPNO > - to->si_trapno = from->si_trapno; > -#endif > to->si_addr_lsb = from->si_addr_lsb; > break; > case SIL_FAULT_BNDERR: > to->si_addr = ptr_to_compat(from->si_addr); > -#ifdef __ARCH_SI_TRAPNO > - to->si_trapno = from->si_trapno; > -#endif > to->si_lower = ptr_to_compat(from->si_lower); > to->si_upper = ptr_to_compat(from->si_upper); > break; > case SIL_FAULT_PKUERR: > to->si_addr = ptr_to_compat(from->si_addr); > -#ifdef __ARCH_SI_TRAPNO > - to->si_trapno = from->si_trapno; > -#endif > to->si_pkey = from->si_pkey; > break; > case SIL_PERF_EVENT: > @@ -3401,30 +3401,22 @@ static int post_copy_siginfo_from_user32(kernel_siginfo_t *to, > break; > case SIL_FAULT: > to->si_addr = compat_ptr(from->si_addr); > -#ifdef __ARCH_SI_TRAPNO > + break; > + case SIL_FAULT_TRAPNO: > + to->si_addr = compat_ptr(from->si_addr); > to->si_trapno = from->si_trapno; > -#endif > break; > case SIL_FAULT_MCEERR: > to->si_addr = compat_ptr(from->si_addr); > -#ifdef __ARCH_SI_TRAPNO > - to->si_trapno = from->si_trapno; > -#endif > to->si_addr_lsb = from->si_addr_lsb; > break; > case SIL_FAULT_BNDERR: > to->si_addr = compat_ptr(from->si_addr); > -#ifdef __ARCH_SI_TRAPNO > - to->si_trapno = from->si_trapno; > -#endif > to->si_lower = compat_ptr(from->si_lower); > to->si_upper = compat_ptr(from->si_upper); > break; > case SIL_FAULT_PKUERR: > to->si_addr = compat_ptr(from->si_addr); > -#ifdef __ARCH_SI_TRAPNO > - to->si_trapno = from->si_trapno; > -#endif > to->si_pkey = from->si_pkey; > break; > case SIL_PERF_EVENT: > -- > 2.30.1