linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dongliang Cui <dongliang.cui@unisoc.com>
To: Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	<linux-kernel@vger.kernel.org>,
	<linux-trace-kernel@vger.kernel.org>
Cc: Dongliang Cui <cuidongliang390@gmail.com>,
	Hongyu Jin <hongyu.jin@unisoc.com>
Subject: [PATCH]eventfs: Apply the gid in the mounting parameters to all files
Date: Wed, 20 Dec 2023 17:15:06 +0800	[thread overview]
Message-ID: <1703063706-30539-1-git-send-email-dongliang.cui@unisoc.com> (raw)

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.

Signed-off-by: Dongliang Cui <dongliang.cui@unisoc.com>
---
 fs/tracefs/inode.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index ae648de..5296ff7 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -560,6 +560,16 @@ struct dentry *eventfs_failed_creating(struct dentry *dentry)
  */
 struct dentry *eventfs_end_creating(struct dentry *dentry)
 {
+	struct tracefs_fs_info *fsi;
+	struct tracefs_mount_opts *opts;
+
+	if (dentry && dentry->d_inode) {
+		fsi = dentry->d_inode->i_sb->s_fs_info;
+		opts = &fsi->mount_opts;
+		if (opts->opts & BIT(Opt_gid))
+			change_gid(dentry, opts->gid);
+	}
+
 	return dentry;
 }
 
-- 
2.7.4



             reply	other threads:[~2023-12-20  9:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-20  9:15 Dongliang Cui [this message]
2023-12-20 13:30 ` [PATCH]eventfs: Apply the gid in the mounting parameters to all files Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1703063706-30539-1-git-send-email-dongliang.cui@unisoc.com \
    --to=dongliang.cui@unisoc.com \
    --cc=cuidongliang390@gmail.com \
    --cc=hongyu.jin@unisoc.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).