All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: Cai Xinchen <caixinchen1@huawei.com>
Cc: mic@digikod.net, gnoack@google.com, paul@paul-moore.com,
	brauner@kernel.org, jack@suse.cz, amir73il@gmail.com,
	andrii@kernel.org, apparmor@lists.ubuntu.com, ast@kernel.org,
	axboe@kernel.dk, bpf@vger.kernel.org, casey@schaufler-ca.com,
	cel@kernel.org, cem@kernel.org, chenxiaosong@chenxiaosong.com,
	code@tyhicks.com, corbet@lwn.net, Dai.Ngo@oracle.com,
	dakr@kernel.org, daniel@iogearbox.net, dhowells@redhat.com,
	dlemoal@kernel.org, dmitry.kasatkin@gmail.com,
	driver-core@lists.linux.dev, dsterba@suse.com,
	ecryptfs@vger.kernel.org, eddyz87@gmail.com,
	emil@etsalapatis.com, eric.snowberg@oracle.com,
	exfat@lists.linux.dev, georgia.garcia@canonical.com,
	gregkh@linuxfoundation.org, hch@lst.de,
	hirofumi@mail.parknet.co.jp, hyc.lee@gmail.com,
	ihor.solodrai@linux.dev, jlayton@kernel.org, jmorris@namei.org,
	johan@kernel.org, john.fastabend@gmail.com,
	john.johansen@canonical.com, jolsa@kernel.org,
	kpsingh@kernel.org, linkinjeon@kernel.org,
	linux-api@vger.kernel.org, linux-block@vger.kernel.org,
	linux-btrfs@vger.kernel.org, linux-cifs@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, linux-nfs@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org,
	linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org,
	liubaolin12138@163.com, martin.lau@linux.dev, mason@kernel.org,
	mathieu.desnoyers@efficios.com, matt@bobrowski.net,
	memxor@gmail.com, mhiramat@kernel.org, miklos@szeredi.hu,
	neil@brown.name, netfs@lists.linux.dev, ntfs@lists.linux.dev,
	okorniev@redhat.com, omosnacek@gmail.com,
	penguin-kernel@i-love.sakura.ne.jp, rafael@kernel.org,
	rdunlap@infradead.org, roberto.sassu@huawei.com,
	rostedt@goodmis.org, selinux@vger.kernel.org,
	senozhatsky@chromium.org, serge@hallyn.com,
	sj1557.seo@samsung.com, skhan@linuxfoundation.org,
	song@kernel.org, stephen.smalley.work@gmail.com,
	takedakn@nttdata.co.jp, tom@talpey.com, yonghong.song@linux.dev,
	yuezhang.mo@sony.com, zohar@linux.ibm.com,
	utilityemal77@gmail.com, lujialin4@huawei.com
Subject: Re: [PATCH -next -v4 01/17] fs: pass struct path to notify_change()
Date: Tue, 17 Nov 2026 18:30:59 +0000	[thread overview]
Message-ID: <20261117183059.GP989762@ZenIV> (raw)
In-Reply-To: <20261117150542.1169451-2-caixinchen1@huawei.com>

On Tue, Nov 17, 2026 at 11:05:26PM +0800, Cai Xinchen wrote:

> +notify_change() and do_truncate() now take a const struct path * instead
> +of a struct dentry *.  They use path->dentry, so callers that only have a
> +dentry must provide a struct path.  struct iattr has a new ia_path member,
> +which notify_change() sets for the duration of the call; it must not be
> +stored beyond that.  Filesystems that forward a change to another inode
> +can use notify_change_target() to update the target dentry while keeping
> +the caller-supplied path in ia_path.

That needs a bit along the lines of "path MUST be consistent - don't combine
a dentry from one filesystem with mount of another".  All in-kernel callers
might have appropriate struct mount references on hand, but for out-of-tree
code that might be not true and we'd better be upfront about the headache
we are inflicting.

I'm not sure we really want to provide those mount references, TBH - it does
add a constraint not just on out-of-tree callers, but upon the future uses
in the kernel.  If NTFS is the only reason... ugh.

> diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
> index 11c70888f38b..410906a66ee9 100644
> --- a/drivers/base/devtmpfs.c
> +++ b/drivers/base/devtmpfs.c
> @@ -284,13 +284,14 @@ static int handle_create(const char *nodename, umode_t mode, kuid_t uid,
>  			dev->devt, NULL);
>  	if (!err) {
>  		struct iattr newattrs;
> +		struct path attr_path = { .mnt = path.mnt, .dentry = dentry };
>  
>  		newattrs.ia_mode = mode;
>  		newattrs.ia_uid = uid;
>  		newattrs.ia_gid = gid;
>  		newattrs.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID;
>  		inode_lock(d_inode(dentry));
> -		notify_change(&nop_mnt_idmap, dentry, &newattrs, NULL);
> +		notify_change(&nop_mnt_idmap, &attr_path, &newattrs, NULL);

BTW, why not something like

		notify_change(&nop_mnt_idmap,
			      &(struct path){.mnt = path.mnt, .dentry = dentry},
			      &newattrs, NULL);
instead of that named local?  Same question for other places like that...

> +int notify_change_target(const struct mnt_idmap *idmap,
> +			 const struct path *path, struct dentry *target,
> +			 struct iattr *attr,
> +			 struct delegated_inode *delegated_inode)
> +{
> +	if (WARN_ON_ONCE(!target))
> +		return -EINVAL;
> +	return do_notify_change(path, idmap, target, attr, delegated_inode);
> +}


  parent reply	other threads:[~2026-11-17 18:31 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 15:05 [PATCH -next -v4 00/17] landlock: Add READ_METADATA and WRITE_METADATA access rights Cai Xinchen
2026-11-17 15:05 ` [PATCH -next -v4 01/17] fs: pass struct path to notify_change() Cai Xinchen
2026-11-17 14:48   ` sashiko-bot
2026-11-17 18:30   ` Al Viro [this message]
2026-11-17 18:34     ` Al Viro
2026-11-17 15:05 ` [PATCH -next -v4 02/17] LSM: pass struct path to the inode_setsecctx hook Cai Xinchen
2026-11-17 14:43   ` sashiko-bot
2026-11-17 18:43   ` Al Viro
2026-11-18  0:16     ` Al Viro
2026-11-17 15:05 ` [PATCH -next -v4 03/17] fs: pass struct path to xattr helpers Cai Xinchen
2026-11-17 14:59   ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 04/17] fs: pass struct path to POSIX ACL helpers Cai Xinchen
2026-11-17 14:45   ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 05/17] LSM: pass struct path and struct file to the inode xattr hooks Cai Xinchen
2026-11-17 15:03   ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 06/17] LSM: pass struct path and struct file to the inode posix acl hooks Cai Xinchen
2026-11-17 15:07   ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 07/17] LSM: pass struct path and struct file to the inode fileattr hooks Cai Xinchen
2026-11-17 14:51   ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 08/17] LSM: rename inode_setattr to path_setattr and pass struct path and file Cai Xinchen
2026-11-17 15:11   ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 09/17] LSM: rename inode_getattr to path_getattr and pass struct file Cai Xinchen
2026-11-17 15:30   ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 10/17] LSM: rename the inode xattr hooks to path_xattr hooks Cai Xinchen
2026-11-17 14:55   ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 11/17] LSM: rename the inode posix acl hooks to path_*_acl hooks Cai Xinchen
2026-11-17 14:55   ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 12/17] LSM: rename the inode fileattr hooks to path_file_* hooks Cai Xinchen
2026-11-17 15:02   ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 13/17] LSM: rename inode_setsecctx to path_setsecctx Cai Xinchen
2026-11-17 14:59   ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 14/17] landlock: Add READ_METADATA and WRITE_METADATA access rights Cai Xinchen
2026-11-17 15:49   ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 15/17] selftests/landlock: Add tests for metadata " Cai Xinchen
2026-11-17 15:12   ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 16/17] samples/landlock: Add metadata rights to sandboxer Cai Xinchen
2026-11-17 15:04   ` sashiko-bot
2026-11-17 15:05 ` [PATCH -next -v4 17/17] Documentation: Update landlock doc for metadata rights Cai Xinchen
2026-11-17 15:05   ` sashiko-bot

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=20261117183059.GP989762@ZenIV \
    --to=viro@zeniv.linux.org.uk \
    --cc=Dai.Ngo@oracle.com \
    --cc=amir73il@gmail.com \
    --cc=andrii@kernel.org \
    --cc=apparmor@lists.ubuntu.com \
    --cc=ast@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=bpf@vger.kernel.org \
    --cc=brauner@kernel.org \
    --cc=caixinchen1@huawei.com \
    --cc=casey@schaufler-ca.com \
    --cc=cel@kernel.org \
    --cc=cem@kernel.org \
    --cc=chenxiaosong@chenxiaosong.com \
    --cc=code@tyhicks.com \
    --cc=corbet@lwn.net \
    --cc=dakr@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=dhowells@redhat.com \
    --cc=dlemoal@kernel.org \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=driver-core@lists.linux.dev \
    --cc=dsterba@suse.com \
    --cc=ecryptfs@vger.kernel.org \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=eric.snowberg@oracle.com \
    --cc=exfat@lists.linux.dev \
    --cc=georgia.garcia@canonical.com \
    --cc=gnoack@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@lst.de \
    --cc=hirofumi@mail.parknet.co.jp \
    --cc=hyc.lee@gmail.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=jack@suse.cz \
    --cc=jlayton@kernel.org \
    --cc=jmorris@namei.org \
    --cc=johan@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=john.johansen@canonical.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linkinjeon@kernel.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=liubaolin12138@163.com \
    --cc=lujialin4@huawei.com \
    --cc=martin.lau@linux.dev \
    --cc=mason@kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=matt@bobrowski.net \
    --cc=memxor@gmail.com \
    --cc=mhiramat@kernel.org \
    --cc=mic@digikod.net \
    --cc=miklos@szeredi.hu \
    --cc=neil@brown.name \
    --cc=netfs@lists.linux.dev \
    --cc=ntfs@lists.linux.dev \
    --cc=okorniev@redhat.com \
    --cc=omosnacek@gmail.com \
    --cc=paul@paul-moore.com \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=rafael@kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=roberto.sassu@huawei.com \
    --cc=rostedt@goodmis.org \
    --cc=selinux@vger.kernel.org \
    --cc=senozhatsky@chromium.org \
    --cc=serge@hallyn.com \
    --cc=sj1557.seo@samsung.com \
    --cc=skhan@linuxfoundation.org \
    --cc=song@kernel.org \
    --cc=stephen.smalley.work@gmail.com \
    --cc=takedakn@nttdata.co.jp \
    --cc=tom@talpey.com \
    --cc=utilityemal77@gmail.com \
    --cc=yonghong.song@linux.dev \
    --cc=yuezhang.mo@sony.com \
    --cc=zohar@linux.ibm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.