Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2714018pxb; Thu, 3 Feb 2022 12:33:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJwydKXQmGiE++6DQB7x65x/yKe/r+BtTBh/VyjosNt0O7Lypw4eyZO0lj8F8Kcb7uKFuoIs X-Received: by 2002:a17:90b:4a4c:: with SMTP id lb12mr15580717pjb.211.1643920410729; Thu, 03 Feb 2022 12:33:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643920410; cv=none; d=google.com; s=arc-20160816; b=K8zleNiPv9+oytErZnLj5rYZnPTZzR1xI2w8P1mQcM1I1uPnLyO1G8oajYNVW10A7B 3ZsdxZe7FgoZ5P4s5xl87+C+rjqTbc3XvEhYI2HuZA8qaN4f+NIRzQdfElCm2YilBp/L SAeV4/kEh8k43feSXNIdoLDFttQMj93nAfLgBrrkUmlCVeK31VmDH8I3nuBVL4YK3N+u N0UMlW+Oy1gVWnTeusKa3PjERFmW/YjnrcLRX7jKgeQAGG76GwVWd5m1tpam9hYoGSjo F90U227EYgeLhlOgW0gjV+u6Zl43anSZliDCByIiZFNXqHjuPbSOPcblbjWhdyIlmh4N 4kqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=syUutp0w1EE9/WDnLShnHZRoAbLvsxwnkGM9FWJyhC8=; b=VWUgbLR5v9I5Ewlezl8nUVJj9YUoRb/sUNQ2KTd5ebYsSAb9GrvhXyWnV0QRj9ebHH TQx8roZH+ao83G/cfXUOha5uDw2T2YP0K8kL5WAgb/z+FNVA3rv2W4qax4kWiAKu+pHz wMYfUUe0fb940oPLSJ0sJ5DTkr2gIMgv8+97t9sXDFrWoxZaJGeCi83GRJJC+XylPh5k DOohZMPtO+ZctR1Ll36GHpmu9swPSATXWU0BDh0sEsQj46p5Slnv25IGlua5rUfZEcBZ +WQ9I1lZcDkbPmMUim4H87X04UMDyDI1MONeSnc7by3CAZQGdpA5Os3ILb6Z+y6lvtN0 GQlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=AdoDhzWH; dkim=neutral (no key) header.i=@linutronix.de header.b=oKUKaCnu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h14si24559636pfc.358.2022.02.03.12.33.19; Thu, 03 Feb 2022 12:33:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=AdoDhzWH; dkim=neutral (no key) header.i=@linutronix.de header.b=oKUKaCnu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351751AbiBCOfn (ORCPT + 99 others); Thu, 3 Feb 2022 09:35:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351320AbiBCOdk (ORCPT ); Thu, 3 Feb 2022 09:33:40 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F465C06175C; Thu, 3 Feb 2022 06:33:36 -0800 (PST) Date: Thu, 03 Feb 2022 14:33:33 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1643898814; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=syUutp0w1EE9/WDnLShnHZRoAbLvsxwnkGM9FWJyhC8=; b=AdoDhzWHNN6hfxcFel02XPkF9QBUydM9jyR8F3Wvb5SHp+qEJtlaZcIT9i9NXrkQ1LzENG IZYitKbLOpHtd02zAaWIUCV00N+d78wuZh74rC4lMrV2DKf6p/P3rFN1xQkElg3tdJqiFZ ZFHdMAMDGicq6ev0YXSIpImPj1NflSaAUva+WYqExJbVgP6WuRtGdi6Go8X6Q+hVOauSH2 ByZBhaEqK9EYcaFw3PgV1TpbCx3+GZzi1ZyZslRJhx9XjDKu5nlg2NwXeUaKTnafwMh4Tq if0NOTN8PlRlDu5gWb/hjd9QZZPO3JYwqyXMecMdGZV97QH2YWTJQPqz6QXX7w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1643898814; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=syUutp0w1EE9/WDnLShnHZRoAbLvsxwnkGM9FWJyhC8=; b=oKUKaCnudKncwHN20c7iQaLScpAqVQWYOEsunQGEW38Bba8yO5HlVzGr1V5BtaG5vQ0VJv +1HZz54hhGDQyaDA== From: "tip-bot2 for Marco Elver" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/urgent] perf: Copy perf_event_attr::sig_data on modification Cc: Dmitry Vyukov , Marco Elver , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220131103407.1971678-1-elver@google.com> References: <20220131103407.1971678-1-elver@google.com> MIME-Version: 1.0 Message-ID: <164389881392.16921.6632551424370921603.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/urgent branch of tip: Commit-ID: 3c25fc97f5590060464cabfa25710970ecddbc96 Gitweb: https://git.kernel.org/tip/3c25fc97f5590060464cabfa25710970ecddbc96 Author: Marco Elver AuthorDate: Mon, 31 Jan 2022 11:34:05 +01:00 Committer: Peter Zijlstra CommitterDate: Wed, 02 Feb 2022 13:11:40 +01:00 perf: Copy perf_event_attr::sig_data on modification The intent has always been that perf_event_attr::sig_data should also be modifiable along with PERF_EVENT_IOC_MODIFY_ATTRIBUTES, because it is observable by user space if SIGTRAP on events is requested. Currently only PERF_TYPE_BREAKPOINT is modifiable, and explicitly copies relevant breakpoint-related attributes in hw_breakpoint_copy_attr(). This misses copying perf_event_attr::sig_data. Since sig_data is not specific to PERF_TYPE_BREAKPOINT, introduce a helper to copy generic event-type-independent attributes on modification. Fixes: 97ba62b27867 ("perf: Add support for SIGTRAP on perf events") Reported-by: Dmitry Vyukov Signed-off-by: Marco Elver Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Dmitry Vyukov Link: https://lore.kernel.org/r/20220131103407.1971678-1-elver@google.com --- kernel/events/core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index 76c754e..57c7197 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -3238,6 +3238,15 @@ static int perf_event_modify_breakpoint(struct perf_event *bp, return err; } +/* + * Copy event-type-independent attributes that may be modified. + */ +static void perf_event_modify_copy_attr(struct perf_event_attr *to, + const struct perf_event_attr *from) +{ + to->sig_data = from->sig_data; +} + static int perf_event_modify_attr(struct perf_event *event, struct perf_event_attr *attr) { @@ -3260,10 +3269,17 @@ static int perf_event_modify_attr(struct perf_event *event, WARN_ON_ONCE(event->ctx->parent_ctx); mutex_lock(&event->child_mutex); + /* + * Event-type-independent attributes must be copied before event-type + * modification, which will validate that final attributes match the + * source attributes after all relevant attributes have been copied. + */ + perf_event_modify_copy_attr(&event->attr, attr); err = func(event, attr); if (err) goto out; list_for_each_entry(child, &event->child_list, child_list) { + perf_event_modify_copy_attr(&child->attr, attr); err = func(child, attr); if (err) goto out;