Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1098272pxy; Sat, 1 May 2021 03:49:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyyfsnJD7NftMgl65WP7gLmRcoadx6Jx01aYkH1ogiBk84eCHUR/koFz6RnQ8fGybPzq1H X-Received: by 2002:a17:90a:ad09:: with SMTP id r9mr20233967pjq.2.1619866144952; Sat, 01 May 2021 03:49:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619866144; cv=none; d=google.com; s=arc-20160816; b=Vrv3xEJcK7hRMufUpX8cu3H/Bo2RyuutsCaieKN5/joCpFcXxrQ//kxJHjKId3s5eT aqajvjMKUsdsJ2cu0MijY3Aj0as/F30n1/WPV4x/jXAgkOxwVytvMLE+JPQxNq4JEtuQ J97Ba+JPuARmE2JpM8nWzgninSHx8jizBK0m6DIDKRf3h0QXD9cVQZTOOaqj8JTX6uDw pgNyRu0tBw8toL02qAUWf6/2jus5WJtxnTwzGlJxqYT8SsUBqiy4fxNI97XlKNWw48rF mmRwnyMf6Cg1EzAKGRsDHs0mJVOkuTUXYdFKHjyTCEf5esqZ3wLsZZf/NOE4KI7x6cGS xX4g== 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=dogrgVKo+eUYaN7DWgb4gh1G07uaLoO2fYWTRss9iAI=; b=lHZMV6nT7ML/G7Ixt4/W3RDMGoSiIB+B/Xo9giCbFje/7N1ra0p3oIfDMF9K5gRGxn 82hOd29grgv9/+23TjsfVX13xR58FjjQCGqBzdEQoNIpFhgU3RJq155y7BRqEaK76Awk 5t4smWLiYZ9IdKM5WuaD2r6J0qU39KtuP4r7spaQ9HwjJNZbt7jmMrWTtQxFF+wZIgCw GPUudHIWQPr0LQ7PMFgisOAh+tTS0MGJqqdz3pXBfhlWsJZhCElMBKxGDZLSVlcJXQS7 xT4iH4gCrGaFZ/TzThkkz99pQ6JwrZFkbQOFFjtrpYJnfpt77UyfFvf5XmYNTIrz9rcl mvjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RXd7Pa84; 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 j1si5689564pfr.175.2021.05.01.03.48.51; Sat, 01 May 2021 03:49:04 -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=RXd7Pa84; 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 S231937AbhEAKs0 (ORCPT + 99 others); Sat, 1 May 2021 06:48:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231843AbhEAKsY (ORCPT ); Sat, 1 May 2021 06:48:24 -0400 Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 783E5C06138B for ; Sat, 1 May 2021 03:47:33 -0700 (PDT) Received: by mail-ot1-x336.google.com with SMTP id 65-20020a9d03470000b02902808b4aec6dso827245otv.6 for ; Sat, 01 May 2021 03:47:33 -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=dogrgVKo+eUYaN7DWgb4gh1G07uaLoO2fYWTRss9iAI=; b=RXd7Pa84UaPsvv1WQUd+2tNTlRkVdTPn98cB2vGqVnBlHOjczQJiPboEyiACRXd3Nn /wkaBA65VO+ykvAgkTl+/bnxgAJMIUKivUCglsdMkib4o1v0zJ/PljiH813uGRna55Fi LMVWNlYGYBUQFgjmvURMSs5dt7oi8W4DG0Wel9bNFRqFBbBaGJSpjqfCqrC37oPUDvhg Ba2J5y6CWKlu5D0YfBzwY/pzHuvKBa12lhhBFkquRd9ciO/txWOuIfpSgxVY0UU6LtS7 z+v1T143HIaSFDe4noB+sC1Tqu3fQeGduSkkBdJixWTCcEuZXvPObrZwHQOGyRQzhuN8 PpEQ== 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=dogrgVKo+eUYaN7DWgb4gh1G07uaLoO2fYWTRss9iAI=; b=Xz9AWRh3S9vTPvhlFfv5Eyv90FTUonuNPhBf9H3QAg3uMGoAWe14vZK4Z309rDPkd9 C8YJtQFa9hZSBbvcYC5FiS/b6oiXCd2gw00Qndsuwdx9kiFN9q2FNUvulFZ186vhslXk bbiRW7UK4RviczYudNP0BEE2wwLg2j6VzcXNspiLTq1WfOxThz/LGCbbfIgxCkAV8XqM JDK2o+qIOhHV+SQtjb3qnvgIRZhBfIPRuyLlRcKIHtWWiKrdqGumdvBKuzq1yBZFfTU8 LRVLnrbv4ZhqxfDNKNDkL42Y7TzD8sU4gF0mJFZE1WpVS+HPP0K59nQ/9K5dks/NyKzd QV+A== X-Gm-Message-State: AOAM532xh11gAd9pexqcgMQMFXba0CYXAsOdDXpQMtF429CjJk/O2qBS DBZf/fYzxMGYmccdXNtNtginiUl7G2qR131rBxLRdQ== X-Received: by 2002:a9d:1ea9:: with SMTP id n38mr7373221otn.233.1619866052694; Sat, 01 May 2021 03:47:32 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Marco Elver Date: Sat, 1 May 2021 12:47:21 +0200 Message-ID: Subject: Re: [PATCH 7/3] signal: Deliver all of the perf_data in si_perf 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 01:44, Eric W. Biederman wrote: > > Don't abuse si_errno and deliver all of the perf data in si_perf. > > Signed-off-by: "Eric W. Biederman" > --- Thank you for the fix, this looks cleaner. Just note that this patch needs to include updates to tools/testing/selftests/perf_events. This should do it: > sed -i 's/si_perf/si_perf.data/g; s/si_errno/si_perf.type/g' tools/testing/selftests/perf_events/*.c Subject: s/perf_data/perf data/ ? For uapi, need to switch to __u32, see below. > fs/signalfd.c | 3 ++- > include/linux/compat.h | 5 ++++- > include/uapi/asm-generic/siginfo.h | 5 ++++- > include/uapi/linux/signalfd.h | 4 ++-- > kernel/signal.c | 18 +++++++++++------- > 5 files changed, 23 insertions(+), 12 deletions(-) > > diff --git a/fs/signalfd.c b/fs/signalfd.c > index 83130244f653..9686af56f073 100644 > --- a/fs/signalfd.c > +++ b/fs/signalfd.c > @@ -134,7 +134,8 @@ static int signalfd_copyinfo(struct signalfd_siginfo __user *uinfo, > break; > case SIL_FAULT_PERF_EVENT: > new.ssi_addr = (long) kinfo->si_addr; > - new.ssi_perf = kinfo->si_perf; > + new.ssi_perf_type = kinfo->si_perf.type; > + new.ssi_perf_data = kinfo->si_perf.data; > break; > case SIL_CHLD: > new.ssi_pid = kinfo->si_pid; > diff --git a/include/linux/compat.h b/include/linux/compat.h > index 24462ed63af4..0726f9b3a57c 100644 > --- a/include/linux/compat.h > +++ b/include/linux/compat.h > @@ -235,7 +235,10 @@ typedef struct compat_siginfo { > u32 _pkey; > } _addr_pkey; > /* used when si_code=TRAP_PERF */ > - compat_ulong_t _perf; > + struct { > + compat_ulong_t data; > + u32 type; > + } _perf; > }; > } _sigfault; > > diff --git a/include/uapi/asm-generic/siginfo.h b/include/uapi/asm-generic/siginfo.h > index 2abdf1d19aad..19b6310021a3 100644 > --- a/include/uapi/asm-generic/siginfo.h > +++ b/include/uapi/asm-generic/siginfo.h > @@ -90,7 +90,10 @@ union __sifields { > __u32 _pkey; > } _addr_pkey; > /* used when si_code=TRAP_PERF */ > - unsigned long _perf; > + struct { > + unsigned long data; > + u32 type; This needs to be __u32. > + } _perf; > }; > } _sigfault; > > diff --git a/include/uapi/linux/signalfd.h b/include/uapi/linux/signalfd.h > index 7e333042c7e3..e78dddf433fc 100644 > --- a/include/uapi/linux/signalfd.h > +++ b/include/uapi/linux/signalfd.h > @@ -39,8 +39,8 @@ struct signalfd_siginfo { > __s32 ssi_syscall; > __u64 ssi_call_addr; > __u32 ssi_arch; > - __u32 __pad3; > - __u64 ssi_perf; > + __u32 ssi_perf_type; > + __u64 ssi_perf_data; > > /* > * Pad strcture to 128 bytes. Remember to update the > diff --git a/kernel/signal.c b/kernel/signal.c > index 5b1ad7f080ab..cb3574b7319c 100644 > --- a/kernel/signal.c > +++ b/kernel/signal.c > @@ -1758,11 +1758,13 @@ int force_sig_perf(void __user *pending_addr, u32 type, u64 sig_data) > struct kernel_siginfo info; > > clear_siginfo(&info); > - info.si_signo = SIGTRAP; > - info.si_errno = type; > - info.si_code = TRAP_PERF; > - info.si_addr = pending_addr; > - info.si_perf = sig_data; > + info.si_signo = SIGTRAP; > + info.si_errno = 0; > + info.si_code = TRAP_PERF; > + info.si_addr = pending_addr; > + info.si_perf.data = sig_data; > + info.si_perf.type = type; > + > return force_sig_info(&info); > } > > @@ -3379,7 +3381,8 @@ void copy_siginfo_to_external32(struct compat_siginfo *to, > break; > case SIL_FAULT_PERF_EVENT: > to->si_addr = ptr_to_compat(from->si_addr); > - to->si_perf = from->si_perf; > + to->si_perf.data = from->si_perf.data; > + to->si_perf.type = from->si_perf.type; > break; > case SIL_CHLD: > to->si_pid = from->si_pid; > @@ -3455,7 +3458,8 @@ static int post_copy_siginfo_from_user32(kernel_siginfo_t *to, > break; > case SIL_FAULT_PERF_EVENT: > to->si_addr = compat_ptr(from->si_addr); > - to->si_perf = from->si_perf; > + to->si_perf.data = from->si_perf.data; > + to->si_perf.type = from->si_perf.type; > break; > case SIL_CHLD: > to->si_pid = from->si_pid; > -- > 2.30.1