From patchwork Thu Dec 21 15:09:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 182289 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp476467dyi; Thu, 21 Dec 2023 07:12:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IFwdXLKH1xbJwsIQJwzXch1EcwUbg7GUWQ5hEI078mTYqtSRheFotVv1bY8QZ59NuBdjFTV X-Received: by 2002:a05:6808:2e48:b0:3bb:5d7f:1d0a with SMTP id gp8-20020a0568082e4800b003bb5d7f1d0amr4739803oib.86.1703171535210; Thu, 21 Dec 2023 07:12:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703171535; cv=none; d=google.com; s=arc-20160816; b=A2D9ZY4sGxT5xgt49EWvrlM+BO+1zuipdEt70TxXHgYZJMLEH+neft8upScRaON3bX qHbs9+P44Pi/n+OtbAuTR4T+W6nZs0TS/1PuzkK84W/9hxbn7FZrepggnUouS8+QI/PA TJmOpU2af2YEmfZkL/YwVjz62u8wR7ACJiF43juImTgscv6NPbSD1DfNxjUcqnshwOMg QpMq0JRGzYxS+tAhnpWGFeExW+cD0QXxOpJL2RYOlov+UfXwqGxTDar1MlB0nkxCg9d3 BEpb5nn6fcAFy3bv67d7K5wUBxNRMk89xnfX3JkTl2ccfmsHQieB2EAgm/A5XvALqKS3 EjkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:subject:cc:to:from:date:user-agent:message-id; bh=W94AeR4vjIAjjO786taVkell5EWb6tp3VGAaOeMEAxY=; fh=vLBuawAV7E7Ty/f2EVtcMY6Amr7fIBhej5UPFEg4990=; b=sRcfaBfFjdVetatSL7AHHai8DLV8+ZhiR0wMzpZfo6fQ6tuQ3c38NqO35mCit4bapI M70DHrLuTR6qgqJ+I+Ilv8+Ds3/WEyVfSrI/vapo8HgkqoDs3KPFd1Vkqu5JkhhzrSKn TSwDj5Zvd7cQIA16Q0W/oBVw6qIY6mNs3+oyaQdltaSipJVThlrDwjnV6mJBsKq+MZYb 2vaMY50AuFSCGXAA4m6v1Abl8ehcKXGa8iTI4a0eTzQBLlWJWQ8rMDwzkGktZucd2bcV +XJKq1Vu6BRFY6CjMoHXiWGIsDEzwdGs0Y+9lB2v5kL663Zzs9cnsIfvMQ4e+luqUvMM BmJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-8623-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8623-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id y23-20020a05610207d700b00466b59c2e7dsi298831vsg.736.2023.12.21.07.12.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 07:12:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8623-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-8623-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8623-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E9E421C23E6D for ; Thu, 21 Dec 2023 15:12:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C61AC55E53; Thu, 21 Dec 2023 15:11:31 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 509D6539E8 for ; Thu, 21 Dec 2023 15:11:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D70FAC433CB; Thu, 21 Dec 2023 15:11:29 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rGKiv-000000040VK-2JWM; Thu, 21 Dec 2023 10:12:33 -0500 Message-ID: <20231221151233.336510377@goodmis.org> User-Agent: quilt/0.67 Date: Thu, 21 Dec 2023 10:09:23 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Randy Dunlap Subject: [for-linus][PATCH 1/3] tracing/synthetic: fix kernel-doc warnings References: <20231221150922.017965539@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785904795646137415 X-GMAIL-MSGID: 1785904795646137415 From: Randy Dunlap scripts/kernel-doc warns about using @args: for variadic arguments to functions. Documentation/doc-guide/kernel-doc.rst says that this should be written as @...: instead, so update the source code to match that, preventing the warnings. trace_events_synth.c:1165: warning: Excess function parameter 'args' description in '__synth_event_gen_cmd_start' trace_events_synth.c:1714: warning: Excess function parameter 'args' description in 'synth_event_trace' Link: https://lore.kernel.org/linux-trace-kernel/20231220061226.30962-1-rdunlap@infradead.org Cc: Mathieu Desnoyers Fixes: 35ca5207c2d11 ("tracing: Add synthetic event command generation functions") Fixes: 8dcc53ad956d2 ("tracing: Add synth_event_trace() and related functions") Acked-by: Masami Hiramatsu (Google) Signed-off-by: Randy Dunlap Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_events_synth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c index 846e02c0fb59..e7af286af4f1 100644 --- a/kernel/trace/trace_events_synth.c +++ b/kernel/trace/trace_events_synth.c @@ -1137,7 +1137,7 @@ EXPORT_SYMBOL_GPL(synth_event_add_fields); * @cmd: A pointer to the dynevent_cmd struct representing the new event * @name: The name of the synthetic event * @mod: The module creating the event, NULL if not created from a module - * @args: Variable number of arg (pairs), one pair for each field + * @...: Variable number of arg (pairs), one pair for each field * * NOTE: Users normally won't want to call this function directly, but * rather use the synth_event_gen_cmd_start() wrapper, which @@ -1695,7 +1695,7 @@ __synth_event_trace_end(struct synth_event_trace_state *trace_state) * synth_event_trace - Trace a synthetic event * @file: The trace_event_file representing the synthetic event * @n_vals: The number of values in vals - * @args: Variable number of args containing the event values + * @...: Variable number of args containing the event values * * Trace a synthetic event using the values passed in the variable * argument list. From patchwork Thu Dec 21 15:09:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 182290 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp476505dyi; Thu, 21 Dec 2023 07:12:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IHQDUbq+0NDT5zQi3vsKnec/R/NF2Xm8ofOlNiLJGMI+YKYGanYAullL9ep7siUUygOQ5RC X-Received: by 2002:a05:6808:1910:b0:3b9:ee8a:b440 with SMTP id bf16-20020a056808191000b003b9ee8ab440mr27302514oib.47.1703171537776; Thu, 21 Dec 2023 07:12:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703171537; cv=none; d=google.com; s=arc-20160816; b=Uwi67q5W+HQi+TSZ6xhw8SYytGcN6IaVMgNLV0xrbKIrscYhKYDI2EVsan9WVlHeic 2/DZfF2LeRsdleOcNA+XgyLHbKCiwI+fomN23J3KBX2H1tNQDhwftFRZRwtjcDbgd/23 O620drWdr/TnnV0RHCmeuuGDuEGV8K5ftTJu+xYsYVR/pVSRSZxpHTxbJbzF26aya2rs gP7SD7j4oIchdSm/F8R7kIzkCr6zKs5KWZzuFxd3VHApDwgk9sWYFoaUJvaRnyQHZss9 5kc9FoVnGd+/rWoS5qgJWGEKXebr5mIThCvs57CM4lre94gh5xrnmliCq+qx7wSHOVBV B3gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:subject:cc:to:from:date:user-agent:message-id; bh=MwPBwKrgtMFvGyAEOwAoOLY4/itsxR9ny86e4yfuQsQ=; fh=/fZ4Zlp6PXqhpzsIp1iHWR4kXEStFSwRrPTs9PRKbMk=; b=VwV6EBIIWqprOxYZcN0QYNr6dEkby2fzsKOBbszcjq2etnIMbQ56bAqWtKSAO42yvX quZ1snSJnr1qJ3G8Y9IDPOoa2Kv48WxUO4GoTDJUbxnGnSfu3uJr9vrlOoNEMlVDi86c aKLffnCR3TZiFaVmC+71dvbkkRRlTOKMfbmr0sax2qR/1CeQieE8MEoHjlT3tRTvH5SE yGXJliS0fLIbSjTeZOEEwmlmkXz5canqdoWWIAi7JBkM/RvLdRzLShRl8uDO8zXz/inS Bn/q6K8W1rpDUKGLYIxcvACNqNFP+TbAwdbFb/lhjVs6uxTx5xS293OKvfZd2MPP/v8r DYJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-8624-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8624-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id e7-20020a67eb87000000b004667be4e1a1si315257vso.44.2023.12.21.07.12.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 07:12:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8624-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-8624-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8624-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 852DF1C23D96 for ; Thu, 21 Dec 2023 15:12:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D96D755E5A; Thu, 21 Dec 2023 15:11:31 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A47F539EC; Thu, 21 Dec 2023 15:11:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EEF66C433CD; Thu, 21 Dec 2023 15:11:29 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rGKiv-000000040Vo-3Vx0; Thu, 21 Dec 2023 10:12:33 -0500 Message-ID: <20231221151233.624191677@goodmis.org> User-Agent: quilt/0.67 Date: Thu, 21 Dec 2023 10:09:24 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , stable@vger.kernel.org, Hongyu Jin , Dongliang Cui Subject: [for-linus][PATCH 2/3] eventfs: Have event files and directories default to parent uid and gid References: <20231221150922.017965539@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785904798064419678 X-GMAIL-MSGID: 1785904798064419678 From: "Steven Rostedt (Google)" Dongliang reported: I found that in the latest version, the nodes of tracefs have been changed to dynamically created. This has caused me to encounter a problem where the gid I specified in the mounting parameters cannot apply to all files, as in the following situation: /data/tmp/events # mount | grep tracefs tracefs on /data/tmp type tracefs (rw,seclabel,relatime,gid=3012) gid 3012 = readtracefs /data/tmp # ls -lh total 0 -r--r----- 1 root readtracefs 0 1970-01-01 08:00 README -r--r----- 1 root readtracefs 0 1970-01-01 08:00 available_events ums9621_1h10:/data/tmp/events # ls -lh total 0 drwxr-xr-x 2 root root 0 2023-12-19 00:56 alarmtimer drwxr-xr-x 2 root root 0 2023-12-19 00:56 asoc It will prevent certain applications from accessing tracefs properly, I try to avoid this issue by making the following modifications. To fix this, have the files created default to taking the ownership of the parent dentry unless the ownership was previously set by the user. Link: https://lore.kernel.org/linux-trace-kernel/1703063706-30539-1-git-send-email-dongliang.cui@unisoc.com/ Link: https://lore.kernel.org/linux-trace-kernel/20231220105017.1489d790@gandalf.local.home Cc: stable@vger.kernel.org Cc: Mathieu Desnoyers Cc: Hongyu Jin Fixes: 28e12c09f5aa0 ("eventfs: Save ownership and mode") Acked-by: Masami Hiramatsu (Google) Reported-by: Dongliang Cui Signed-off-by: Steven Rostedt (Google) --- fs/tracefs/event_inode.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 43e237864a42..2ccc849a5bda 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -148,7 +148,8 @@ static const struct file_operations eventfs_file_operations = { .release = eventfs_release, }; -static void update_inode_attr(struct inode *inode, struct eventfs_attr *attr, umode_t mode) +static void update_inode_attr(struct dentry *dentry, struct inode *inode, + struct eventfs_attr *attr, umode_t mode) { if (!attr) { inode->i_mode = mode; @@ -162,9 +163,13 @@ static void update_inode_attr(struct inode *inode, struct eventfs_attr *attr, um if (attr->mode & EVENTFS_SAVE_UID) inode->i_uid = attr->uid; + else + inode->i_uid = d_inode(dentry->d_parent)->i_uid; if (attr->mode & EVENTFS_SAVE_GID) inode->i_gid = attr->gid; + else + inode->i_gid = d_inode(dentry->d_parent)->i_gid; } /** @@ -206,7 +211,7 @@ static struct dentry *create_file(const char *name, umode_t mode, return eventfs_failed_creating(dentry); /* If the user updated the directory's attributes, use them */ - update_inode_attr(inode, attr, mode); + update_inode_attr(dentry, inode, attr, mode); inode->i_op = &eventfs_file_inode_operations; inode->i_fop = fop; @@ -242,7 +247,8 @@ static struct dentry *create_dir(struct eventfs_inode *ei, struct dentry *parent return eventfs_failed_creating(dentry); /* If the user updated the directory's attributes, use them */ - update_inode_attr(inode, &ei->attr, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO); + update_inode_attr(dentry, inode, &ei->attr, + S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO); inode->i_op = &eventfs_root_dir_inode_operations; inode->i_fop = &eventfs_file_operations; From patchwork Thu Dec 21 15:09:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 182291 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp476630dyi; Thu, 21 Dec 2023 07:12:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IHkD31czEGl8b0REvrVgBCN3P3WnhJjIKTzSTtWkwDBttZPKXXxyM21HEeDdueRc8UomV/u X-Received: by 2002:a05:6102:4189:b0:466:bc9b:44d4 with SMTP id cd9-20020a056102418900b00466bc9b44d4mr1242237vsb.21.1703171549093; Thu, 21 Dec 2023 07:12:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703171549; cv=none; d=google.com; s=arc-20160816; b=VT7dzGQQ5E7YNf6hB+ETNjUnSEYbcLGlhhNdVW0hEH0iVVzka9TaPD148fZhr1fXiP QvuR73uaOgOmgn89bsoiQ+zT4nLY2eEEM4YTa7UbDhozn7C2tYI1b+2s/n704HwToFLV 4rrGDq4fyQXYHaNfJ+R08pF+OVVjAeBFV8zbK+ZX++QBX5dtBziZsP35QWxpE1WV1RAd DS72osiPC9XSmlO1AVOuIK+10L6Dtl6eV4s3DU9MdpBm7iVMNYxaF1tCT+XrPJXraMWc 1eYjLFup9qNyKvVEtT9G4iF6Z02cJ/QLD6DXjX5xrbvYVlI57Fe+OQpTFvRvlBP4BLfX LR4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:subject:cc:to:from:date:user-agent:message-id; bh=JOQaKPVNe+VAynlIG8g+ENdsBO73Md5zJNvgldrQT38=; fh=M1rK97+mm993K7gOF8eFmc5n1x3hEM6QL4veL4632qw=; b=0xEc46c7JZCgRCO0oyqTYME6rrb/ZT3QuHtx28jeOaN32Jjr/hzGEG450qaCdcc3yi GvbXDCA5nqbEXIQrnosHhAlzkDhvV5pr39CiAzMMqU2vxVvd6JqLCdtFuTTOAV7ukdnb HtMiHpiC12wGG6LPJYtHgcbvv1i5zzJDT3QURyhoOAss/AVKjRVhMUyFaNrI0ePSj3tY Mkfa0HTJyoXG0Lz3lu/91BOW8fzhajycUmFpG6FgrQ/lPPgzxAxDTkOlMwn85QOy1Bc6 qpKkJ5LqwS/lQxIFEsFf1ekzZZZPNm7LcVJ2yjG7dXafi3tJtnFpk1+E0xwKugyuppcS nY4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-8625-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8625-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g9-20020a67e209000000b00466b147de90si339303vsa.317.2023.12.21.07.12.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 07:12:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8625-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-8625-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8625-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DD1D31C24291 for ; Thu, 21 Dec 2023 15:12:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CF68E55E6F; Thu, 21 Dec 2023 15:11:32 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F2C153A0F; Thu, 21 Dec 2023 15:11:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4742DC433C7; Thu, 21 Dec 2023 15:11:30 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rGKiw-000000040WI-0VB9; Thu, 21 Dec 2023 10:12:34 -0500 Message-ID: <20231221151233.903914320@goodmis.org> User-Agent: quilt/0.67 Date: Thu, 21 Dec 2023 10:09:25 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , stable@vger.kernel.org, Tom Zanussi , Alexander Graf Subject: [for-linus][PATCH 3/3] tracing / synthetic: Disable events after testing in synth_event_gen_test_init() References: <20231221150922.017965539@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785904810009238542 X-GMAIL-MSGID: 1785904810009238542 From: "Steven Rostedt (Google)" The synth_event_gen_test module can be built in, if someone wants to run the tests at boot up and not have to load them. The synth_event_gen_test_init() function creates and enables the synthetic events and runs its tests. The synth_event_gen_test_exit() disables the events it created and destroys the events. If the module is builtin, the events are never disabled. The issue is, the events should be disable after the tests are run. This could be an issue if the rest of the boot up tests are enabled, as they expect the events to be in a known state before testing. That known state happens to be disabled. When CONFIG_SYNTH_EVENT_GEN_TEST=y and CONFIG_EVENT_TRACE_STARTUP_TEST=y a warning will trigger: Running tests on trace events: Testing event create_synth_test: Enabled event during self test! ------------[ cut here ]------------ WARNING: CPU: 2 PID: 1 at kernel/trace/trace_events.c:4150 event_trace_self_tests+0x1c2/0x480 Modules linked in: CPU: 2 PID: 1 Comm: swapper/0 Not tainted 6.7.0-rc2-test-00031-gb803d7c664d5-dirty #276 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014 RIP: 0010:event_trace_self_tests+0x1c2/0x480 Code: bb e8 a2 ab 5d fc 48 8d 7b 48 e8 f9 3d 99 fc 48 8b 73 48 40 f6 c6 01 0f 84 d6 fe ff ff 48 c7 c7 20 b6 ad bb e8 7f ab 5d fc 90 <0f> 0b 90 48 89 df e8 d3 3d 99 fc 48 8b 1b 4c 39 f3 0f 85 2c ff ff RSP: 0000:ffffc9000001fdc0 EFLAGS: 00010246 RAX: 0000000000000029 RBX: ffff88810399ca80 RCX: 0000000000000000 RDX: 0000000000000000 RSI: ffffffffb9f19478 RDI: ffff88823c734e64 RBP: ffff88810399f300 R08: 0000000000000000 R09: fffffbfff79eb32a R10: ffffffffbcf59957 R11: 0000000000000001 R12: ffff888104068090 R13: ffffffffbc89f0a0 R14: ffffffffbc8a0f08 R15: 0000000000000078 FS: 0000000000000000(0000) GS:ffff88823c700000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 00000001f6282001 CR4: 0000000000170ef0 Call Trace: ? __warn+0xa5/0x200 ? event_trace_self_tests+0x1c2/0x480 ? report_bug+0x1f6/0x220 ? handle_bug+0x6f/0x90 ? exc_invalid_op+0x17/0x50 ? asm_exc_invalid_op+0x1a/0x20 ? tracer_preempt_on+0x78/0x1c0 ? event_trace_self_tests+0x1c2/0x480 ? __pfx_event_trace_self_tests_init+0x10/0x10 event_trace_self_tests_init+0x27/0xe0 do_one_initcall+0xd6/0x3c0 ? __pfx_do_one_initcall+0x10/0x10 ? kasan_set_track+0x25/0x30 ? rcu_is_watching+0x38/0x60 kernel_init_freeable+0x324/0x450 ? __pfx_kernel_init+0x10/0x10 kernel_init+0x1f/0x1e0 ? _raw_spin_unlock_irq+0x33/0x50 ret_from_fork+0x34/0x60 ? __pfx_kernel_init+0x10/0x10 ret_from_fork_asm+0x1b/0x30 This is because the synth_event_gen_test_init() left the synthetic events that it created enabled. By having it disable them after testing, the other selftests will run fine. Link: https://lore.kernel.org/linux-trace-kernel/20231220111525.2f0f49b0@gandalf.local.home Cc: stable@vger.kernel.org Cc: Mathieu Desnoyers Cc: Tom Zanussi Fixes: 9fe41efaca084 ("tracing: Add synth event generation test module") Acked-by: Masami Hiramatsu (Google) Reported-by: Alexander Graf Tested-by: Alexander Graf Signed-off-by: Steven Rostedt (Google) --- kernel/trace/synth_event_gen_test.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kernel/trace/synth_event_gen_test.c b/kernel/trace/synth_event_gen_test.c index 8dfe85499d4a..354c2117be43 100644 --- a/kernel/trace/synth_event_gen_test.c +++ b/kernel/trace/synth_event_gen_test.c @@ -477,6 +477,17 @@ static int __init synth_event_gen_test_init(void) ret = test_trace_synth_event(); WARN_ON(ret); + + /* Disable when done */ + trace_array_set_clr_event(gen_synth_test->tr, + "synthetic", + "gen_synth_test", false); + trace_array_set_clr_event(empty_synth_test->tr, + "synthetic", + "empty_synth_test", false); + trace_array_set_clr_event(create_synth_test->tr, + "synthetic", + "create_synth_test", false); out: return ret; }