From: Christian Brauner <brauner@kernel.org>
To: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Cc: mszeredi@redhat.com, stgraber@stgraber.org,
linux-fsdevel@vger.kernel.org,
Seth Forshee <sforshee@kernel.org>,
Miklos Szeredi <miklos@szeredi.hu>,
Amir Goldstein <amir73il@gmail.com>,
Bernd Schubert <bschubert@ddn.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 6/9] fs/fuse: support idmapped ->setattr op
Date: Sat, 20 Jan 2024 16:23:38 +0100 [thread overview]
Message-ID: <20240120-zeitmanagement-abbezahlen-8a3e2b5de72a@brauner> (raw)
In-Reply-To: <20240108120824.122178-7-aleksandr.mikhalitsyn@canonical.com>
On Mon, Jan 08, 2024 at 01:08:21PM +0100, Alexander Mikhalitsyn wrote:
> Cc: Christian Brauner <brauner@kernel.org>
> Cc: Seth Forshee <sforshee@kernel.org>
> Cc: Miklos Szeredi <miklos@szeredi.hu>
> Cc: Amir Goldstein <amir73il@gmail.com>
> Cc: Bernd Schubert <bschubert@ddn.com>
> Cc: <linux-fsdevel@vger.kernel.org>
> Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
> ---
> fs/fuse/dir.c | 32 +++++++++++++++++++++-----------
> fs/fuse/file.c | 2 +-
> fs/fuse/fuse_i.h | 4 ++--
> 3 files changed, 24 insertions(+), 14 deletions(-)
>
> diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> index f7c2c54f7122..5fbb7100ad1c 100644
> --- a/fs/fuse/dir.c
> +++ b/fs/fuse/dir.c
> @@ -1739,17 +1739,27 @@ static bool update_mtime(unsigned ivalid, bool trust_local_mtime)
> return true;
> }
>
> -static void iattr_to_fattr(struct fuse_conn *fc, struct iattr *iattr,
> - struct fuse_setattr_in *arg, bool trust_local_cmtime)
> +static void iattr_to_fattr(struct mnt_idmap *idmap, struct fuse_conn *fc,
> + struct iattr *iattr, struct fuse_setattr_in *arg,
> + bool trust_local_cmtime)
> {
> unsigned ivalid = iattr->ia_valid;
>
> if (ivalid & ATTR_MODE)
> arg->valid |= FATTR_MODE, arg->mode = iattr->ia_mode;
> - if (ivalid & ATTR_UID)
> - arg->valid |= FATTR_UID, arg->uid = from_kuid(fc->user_ns, iattr->ia_uid);
> - if (ivalid & ATTR_GID)
> - arg->valid |= FATTR_GID, arg->gid = from_kgid(fc->user_ns, iattr->ia_gid);
> +
> + if (ivalid & ATTR_UID) {
> + kuid_t fsuid = from_vfsuid(idmap, fc->user_ns, iattr->ia_vfsuid);
> + arg->valid |= FATTR_UID;
> + arg->uid = from_kuid(fc->user_ns, fsuid);
> + }
> +
> + if (ivalid & ATTR_GID) {
> + kgid_t fsgid = from_vfsgid(idmap, fc->user_ns, iattr->ia_vfsgid);
> + arg->valid |= FATTR_GID;
> + arg->gid = from_kgid(fc->user_ns, fsgid);
> + }
> +
> if (ivalid & ATTR_SIZE)
> arg->valid |= FATTR_SIZE, arg->size = iattr->ia_size;
> if (ivalid & ATTR_ATIME) {
> @@ -1869,8 +1879,8 @@ int fuse_flush_times(struct inode *inode, struct fuse_file *ff)
> * vmtruncate() doesn't allow for this case, so do the rlimit checking
> * and the actual truncation by hand.
> */
> -int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
> - struct file *file)
> +int fuse_do_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> + struct iattr *attr, struct file *file)
> {
> struct inode *inode = d_inode(dentry);
> struct fuse_mount *fm = get_fuse_mount(inode);
> @@ -1890,7 +1900,7 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
> if (!fc->default_permissions)
> attr->ia_valid |= ATTR_FORCE;
>
> - err = setattr_prepare(&nop_mnt_idmap, dentry, attr);
> + err = setattr_prepare(idmap, dentry, attr);
> if (err)
> return err;
>
> @@ -1949,7 +1959,7 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,
>
> memset(&inarg, 0, sizeof(inarg));
> memset(&outarg, 0, sizeof(outarg));
> - iattr_to_fattr(fc, attr, &inarg, trust_local_cmtime);
> + iattr_to_fattr(idmap, fc, attr, &inarg, trust_local_cmtime);
> if (file) {
> struct fuse_file *ff = file->private_data;
> inarg.valid |= FATTR_FH;
> @@ -2084,7 +2094,7 @@ static int fuse_setattr(struct mnt_idmap *idmap, struct dentry *entry,
> if (!attr->ia_valid)
> return 0;
>
> - ret = fuse_do_setattr(entry, attr, file);
> + ret = fuse_do_setattr(idmap, entry, attr, file);
> if (!ret) {
> /*
> * If filesystem supports acls it may have updated acl xattrs in
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index a660f1f21540..e0fe5497a548 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -2870,7 +2870,7 @@ static void fuse_do_truncate(struct file *file)
> attr.ia_file = file;
> attr.ia_valid |= ATTR_FILE;
>
> - fuse_do_setattr(file_dentry(file), &attr, file);
> + fuse_do_setattr(&nop_mnt_idmap, file_dentry(file), &attr, file);
Same as for the other patch. Please leave a comment in the commit
message that briefly explains why it's ok to pass &nop_mnt_idmap here.
It'll help us later. :)
next prev parent reply other threads:[~2024-01-20 15:23 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-08 12:08 [PATCH v1 0/9] fuse: basic support for idmapped mounts Alexander Mikhalitsyn
2024-01-08 12:08 ` [PATCH v1 1/9] fs/namespace: introduce fs_type->allow_idmap hook Alexander Mikhalitsyn
2024-01-08 12:08 ` [PATCH v1 2/9] fs/fuse: add FUSE_OWNER_UID_GID_EXT extension Alexander Mikhalitsyn
2024-03-05 14:38 ` Miklos Szeredi
2024-07-18 19:12 ` Aleksandr Mikhalitsyn
2024-08-29 8:24 ` Miklos Szeredi
2024-08-29 12:08 ` Christian Brauner
2024-08-29 12:17 ` Aleksandr Mikhalitsyn
2024-08-29 12:21 ` Aleksandr Mikhalitsyn
2024-08-29 12:29 ` Miklos Szeredi
2024-08-29 14:39 ` Aleksandr Mikhalitsyn
2024-08-29 15:04 ` Miklos Szeredi
2024-08-29 17:40 ` Aleksandr Mikhalitsyn
2024-08-29 18:58 ` Miklos Szeredi
2024-08-30 10:57 ` Christian Brauner
2024-08-30 13:49 ` Miklos Szeredi
2024-09-03 15:22 ` Aleksandr Mikhalitsyn
2024-01-08 12:08 ` [PATCH v1 3/9] fs/fuse: support idmap for mkdir/mknod/symlink/create Alexander Mikhalitsyn
2024-01-08 12:08 ` [PATCH v1 4/9] fs/fuse: support idmapped getattr inode op Alexander Mikhalitsyn
2024-01-20 15:21 ` Christian Brauner
2024-01-29 15:42 ` Alexander Mikhalitsyn
2024-01-08 12:08 ` [PATCH v1 5/9] fs/fuse: support idmapped ->permission " Alexander Mikhalitsyn
2024-01-08 12:08 ` [PATCH v1 6/9] fs/fuse: support idmapped ->setattr op Alexander Mikhalitsyn
2024-01-20 15:23 ` Christian Brauner [this message]
2024-01-29 15:48 ` Alexander Mikhalitsyn
2024-01-30 9:52 ` Christian Brauner
2024-01-08 12:08 ` [PATCH v1 7/9] fs/fuse: drop idmap argument from __fuse_get_acl Alexander Mikhalitsyn
2024-01-20 15:24 ` Christian Brauner
2024-01-29 15:55 ` Alexander Mikhalitsyn
2024-01-08 12:08 ` [PATCH v1 8/9] fs/fuse: support idmapped ->set_acl Alexander Mikhalitsyn
2024-01-08 12:08 ` [PATCH v1 9/9] fs/fuse: allow idmapped mounts Alexander Mikhalitsyn
2024-01-21 17:50 ` [PATCH v1 0/9] fuse: basic support for " Christian Brauner
2024-01-22 21:13 ` Seth Forshee
2024-01-23 15:45 ` Christian Brauner
2024-01-29 16:52 ` Alexander Mikhalitsyn
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=20240120-zeitmanagement-abbezahlen-8a3e2b5de72a@brauner \
--to=brauner@kernel.org \
--cc=aleksandr.mikhalitsyn@canonical.com \
--cc=amir73il@gmail.com \
--cc=bschubert@ddn.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=mszeredi@redhat.com \
--cc=sforshee@kernel.org \
--cc=stgraber@stgraber.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