Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp1941670rdb; Tue, 5 Sep 2023 09:22:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG7b5crYa8mmN8PKnpvpnMZCVy2A7sKcuTeVAuYgvTfIfEPgwSyol26G/VnpDyDIxXJc/dW X-Received: by 2002:a17:907:7849:b0:9a0:9558:82a3 with SMTP id lb9-20020a170907784900b009a0955882a3mr256748ejc.58.1693930964991; Tue, 05 Sep 2023 09:22:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693930964; cv=none; d=google.com; s=arc-20160816; b=VX6iBTkDcHr1fEl+1m+RXTevMpS3UqDzm09i4JtvF3GRNtPR+AhCnJaOwnBU69qD0b 3UyI/i1T0kDFNqz8DYSGf6UkVLWoRiC33MgBsfguxo41J3qwjZVrD+O7hWAso8zn/1ux kz2kKGGuYqQ+D5yI3sSJw0QkhoLQBZJR3kvozeN6jO3D4LgKh8OsvTo9/zeh5qduRLNU 6+msuXsQ3ncCyF/MsoBYb5iBZ6rw0tF21Xp/RmyKNnyvs0e6evE+rcSGtttB8FH7ARfI aWytSUEMZs9IH6UEdA6AOaTUsyiM9qZXotYokVB+VohGklV2k0nPglD/5/WIIyBPy/Ij yu5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=Hf9SnXuceZoq/4/ofWf9A3vljxlLROGDFUiObueCNRA=; fh=g5yIVi+SPO3ajSHXdSEStn5LTcThSaZxjHkvi+qwBXA=; b=gS066nDcQd7WMjqxK9hygxp3Fjf00OcgLFSZgTHDXHRCNcyNuiIJh5BhgjpeumryFY v44sU6Y9/cPBL+Yiie/Hwx/W0WHUYYAt0SqllHw/D01nLSm3p3np6OfSxrJdy45UUtAF P11JxhoD7bUVeRTVqf7dV1oKRwCBaKZa9h3gD6J9uka2O6pQahzarruE683qA9vNUCsa qLAOAtVuEeLxUn4bimsVufk+meKaJULHEoQ1+8olzXhUmIdmm5u37foSurNysvbi8HRQ fz21/ahWP7M7haOD7s85LX+Vln4Onu2kXwpTychUkyhfXGGIcb5m3mBlPbhiQhcPsTsZ a5KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=fbpcM+2b; 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=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d16-20020a170906c21000b00988a13c6a90si7624317ejz.601.2023.09.05.09.22.39; Tue, 05 Sep 2023 09:22:44 -0700 (PDT) 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=@linux.microsoft.com header.s=default header.b=fbpcM+2b; 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=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241481AbjIAUnn (ORCPT + 9 others); Fri, 1 Sep 2023 16:43:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245611AbjIAUnm (ORCPT ); Fri, 1 Sep 2023 16:43:42 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E84F0E7F; Fri, 1 Sep 2023 13:43:38 -0700 (PDT) Received: from localhost.localdomain (unknown [4.155.48.116]) by linux.microsoft.com (Postfix) with ESMTPSA id 5FDA9212A77F; Fri, 1 Sep 2023 13:43:38 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5FDA9212A77F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1693601018; bh=Hf9SnXuceZoq/4/ofWf9A3vljxlLROGDFUiObueCNRA=; h=From:To:Cc:Subject:Date:From; b=fbpcM+2borID5F7aXvRUS8dbyap3lmwghhlvbZ4vyke2NDcgKfG6I11aazX3+MnBN /3gCurGAPs36iohHOK7EPXKH0OArug9ZrgbJlUH9TXa3v9Nt664JU7h/r/iJ2zT4L7 SSTbzQYvlJwGZboztLfZ+oG2xh7Rca1voJl9jN8w= From: Beau Belgrave To: rostedt@goodmis.org, mhiramat@kernel.org Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ast@kernel.org, dcook@linux.microsoft.com Subject: [PATCH 0/3] tracing/user_events: Allow events to persist for perfmon_capable users Date: Fri, 1 Sep 2023 20:43:29 +0000 Message-Id: <20230901204332.159-1-beaub@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-17.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are several scenarios that have come up where having a user_event persist even if the process that registered it exits. The main one is having a daemon create events on bootup that shouldn't get deleted if the daemon has to exit or reload. Another is within OpenTelemetry exporters, they wish to potentially check if a user_event exists on the system to determine if exporting the data out should occur. The user_event in this case must exist even in the absence of the owning process running (such as the above daemon case). Since persistent events aren't automatically cleaned up, we want to ensure only trusted users are allowed to do this. It seems reasonable to use CAP_PERFMON as that boundary, since those users can already do many things via perf_event_open without requiring full CAP_SYS_ADMIN. This patchset brings back the ability to use /sys/kernel/tracing/dynamic_events to create user_events, as persist is now back to being supported. Both the register and delete of events that persist require CAP_PERFMON, which prevents a non-perfmon user from making an event go away that a perfmon user decided should persist. Beau Belgrave (3): tracing/user_events: Allow events to persist for perfmon_capable users selftests/user_events: Test persist flag cases tracing/user_events: Document persist event flags Documentation/trace/user_events.rst | 21 ++++++- include/uapi/linux/user_events.h | 11 +++- kernel/trace/trace_events_user.c | 28 +++++----- .../testing/selftests/user_events/abi_test.c | 55 ++++++++++++++++++- .../testing/selftests/user_events/dyn_test.c | 54 +++++++++++++++++- 5 files changed, 149 insertions(+), 20 deletions(-) base-commit: f940e482b0f889e697372a22b6c15da87aa1f63a -- 2.34.1