Received: by 2002:a05:7412:d024:b0:f9:90c9:de9f with SMTP id bd36csp26945rdb; Wed, 20 Dec 2023 05:30:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGzNEOt6+g4cpGLvidk5KKe6PYE201fX0oniczx6MIIixAvjWMRcqNun2ICEJsXbZudUZTZ X-Received: by 2002:a17:902:820b:b0:1d0:437a:35ac with SMTP id x11-20020a170902820b00b001d0437a35acmr8741568pln.37.1703079003311; Wed, 20 Dec 2023 05:30:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703079003; cv=none; d=google.com; s=arc-20160816; b=XCX4UUVze/OxJc4OcCCvBdREU5MYxiee2OGGDDGjYIW5ltJ9wdP6R2u+VVWd0zVySV Nc6biMlqA3/3MK66XoUIZmkCrk/W52vsC6oTRjdJy2zxvej/0CLT/NCS4ZTx/Kqt4R3S BdfZhj23SzjeexhMA53qD/lX8547V4TVQz49uNrddaKzS5chWfFu+MrO+wrpExjp66xS zII4pcUsb+7Y3Qa3AW1psXHCuEzenT7Glbdpg8BAsLFgkI0/3S6NTPthj9VKMw92H+zo NP49qsVMCd9SgogyKS8rHgqd5L/7heNmdy0RW4yy5DX+ZutCBntew0DI2INKJGn0TivY D7Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date; bh=7IDONXPPyye+55pYmNFlZb29uNxugIWWrH9R7lxG5BU=; fh=0h0g2gUCzGdnhbml2Wad3AdcT0pcA/7J/ngkDFQYDgA=; b=QXA0ynilAT9FB2SXOnRqauJ8cmHW2dYDC57TDV/yRto2L55adQ6FB8+DFmyL1QfgEP 5nt+89NlHYFwOyDISEV0b0gDGJwcMP8r9BPpQApwTaCItJzIQetC0S91xJvDFMIlKAqz FExj2eaDlqrvaI045PsB+/wAXc5SoninLBZjchCLB3VzT+eqDXeeyi3QqB70L61yeyiq UO80NqYyL0G3fjCvEmp60ho2PdiNDw/3UxAKQCaV+wl5subTnjcTxyr25x3pJli/urWR NS63BsA5b+/ShTijZGywKr8oRdrEQQJCqS/S/+25Ht4dmq8PcZR73LGuak0wRsU++nwq kPSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-6960-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6960-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id jk13-20020a170903330d00b001d3aa22894dsi6634211plb.50.2023.12.20.05.30.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 05:30:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6960-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-6960-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6960-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7D71A280F72 for ; Wed, 20 Dec 2023 13:30:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4640234569; Wed, 20 Dec 2023 13:30:00 +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 CA6382D638; Wed, 20 Dec 2023 13:29:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6AAEBC433C8; Wed, 20 Dec 2023 13:29:58 +0000 (UTC) Date: Wed, 20 Dec 2023 08:30:58 -0500 From: Steven Rostedt To: Dongliang Cui Cc: Masami Hiramatsu , Mathieu Desnoyers , , , Dongliang Cui , Hongyu Jin Subject: Re: [PATCH]eventfs: Apply the gid in the mounting parameters to all files Message-ID: <20231220083058.09196546@gandalf.local.home> In-Reply-To: <1703063706-30539-1-git-send-email-dongliang.cui@unisoc.com> References: <1703063706-30539-1-git-send-email-dongliang.cui@unisoc.com> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 20 Dec 2023 17:15:06 +0800 Dongliang Cui wrote: > 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 Thanks for the report, can you try this fix instead? -- Steve 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;