From patchwork Mon Jan 8 12:08:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13513350 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) (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 1D6B93FB28 for ; Mon, 8 Jan 2024 12:10:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="jy6tpFZh" Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 8C9473F743 for ; Mon, 8 Jan 2024 12:09:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1704715799; bh=GtdhYLDKs9o20JRSF0JGIkdiKLo4c8K8/G8DvoYAW44=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jy6tpFZhfYdMKPc2T1yw/AlsYk6up/wkEUIJGDNovxV5t6t5jdqH99sS/u2QstfSR XRWa6kEVslGqkz6HSenY6qhAQwB9IcvOsozqhqZBYKjdYqO1I5is1AT20cLWGcc0FR 94v1aUoxtjwlszZabirRWKWCYdZX0bhFYi6WlLjpDQm2WBR/bFAUFfSWbtfClfn//O HYp+zsuN3z6K9SWM59S7F6zwSeryFxcrUhRz9R4xH9DnBWmhChaqvMIQhjTWBVWyTj EERJcFeZ0B5GBr3iY+ZhC5k4HLCm7Q6D8+ZlQf2QDVC/oM6ycmcp6tQub6dRFPTXk0 G114XajQD8jqA== Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-50e58b37aebso862120e87.1 for ; Mon, 08 Jan 2024 04:09:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704715798; x=1705320598; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GtdhYLDKs9o20JRSF0JGIkdiKLo4c8K8/G8DvoYAW44=; b=A76k7g5LomkbnyjrmMDYUant/D79wa/EHxaYpaCsaP0JWyXPlSKkimUsfDD8S7V4b3 RGJBNY71/VDdGwBEWQ6pGqcH4iOi7dqpZJ1LscqmCAxjh8qceyIhC5d5y9FWCLpP9zI6 bzLMuBi7m02yOqgyl7zKPV6eS2y23zbe10bGdp5QeLyC4eoY6p2qQrMzp6JWRuLw267B 7xOMra8k4bLurmgeTI2TkIMXUN+1Hik0xiTPdU/f+26X78RKiK/ik+6y8H4sw2Ijwy8j Ev63zfaxrOrK6S3ax6jk7UXYUUc/MXj5cp3hVj8dCM326EwhMTFCouS0w0P/tDbVKwxa LosA== X-Gm-Message-State: AOJu0YxnCKrMXOPGFFRjqsJHYLbN+Zttx0xuo+qzMaXjbJcO7jjt4ZBx ABRe+4Op3jdQR8wagFQc0vsKVLyAnIkfVfuoZpCnYObAO6pObRXrZj7iRc3qgg3jzQBJSYNW5cm R83TfPxogaELzP48MT6gmnF+NWwdwAiFGTzcI3e4ORu6s1KGGaw== X-Received: by 2002:a05:6512:10d6:b0:50e:75ee:ec46 with SMTP id k22-20020a05651210d600b0050e75eeec46mr795190lfg.2.1704715798663; Mon, 08 Jan 2024 04:09:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IFUqcUNjknvfP6Ue7/xRuCDchF5ew85PuPQCa7e/qAm97tSZSidsvc4p703nLWJuX0caRvEzw== X-Received: by 2002:a05:6512:10d6:b0:50e:75ee:ec46 with SMTP id k22-20020a05651210d600b0050e75eeec46mr795186lfg.2.1704715798368; Mon, 08 Jan 2024 04:09:58 -0800 (PST) Received: from localhost.localdomain ([91.64.72.41]) by smtp.gmail.com with ESMTPSA id fi21-20020a056402551500b005578b816f20sm1767959edb.29.2024.01.08.04.09.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 04:09:57 -0800 (PST) From: Alexander Mikhalitsyn To: mszeredi@redhat.com Cc: brauner@kernel.org, stgraber@stgraber.org, linux-fsdevel@vger.kernel.org, Seth Forshee , Miklos Szeredi , Amir Goldstein , Bernd Schubert , Alexander Mikhalitsyn , Alexander Viro , linux-kernel@vger.kernel.org Subject: [PATCH v1 1/9] fs/namespace: introduce fs_type->allow_idmap hook Date: Mon, 8 Jan 2024 13:08:16 +0100 Message-Id: <20240108120824.122178-2-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240108120824.122178-1-aleksandr.mikhalitsyn@canonical.com> References: <20240108120824.122178-1-aleksandr.mikhalitsyn@canonical.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Right now we determine if filesystem support vfs idmappings or not basing on the FS_ALLOW_IDMAP flag presence. This "static" way works perfecly well for local filesystems like ext4, xfs, btrfs, etc. But for network-like filesystems like fuse, cephfs this approach is not ideal, because sometimes proper support of vfs idmaps requires some extensions for the on-wire protocol, which implies that changes have to be made not only in the Linux kernel code but also in the 3rd party components like libfuse, cephfs MDS server and so on. We have seen that issue during our work on cephfs idmapped mounts [1] with Christian, but right now I'm working on the idmapped mounts support for fuse and I think that it is a right time for this extension. [1] 5ccd8530dd7 ("ceph: handle idmapped mounts in create_request_message()") Cc: Christian Brauner Cc: Seth Forshee Cc: Miklos Szeredi Cc: Amir Goldstein Cc: Bernd Schubert Cc: Signed-off-by: Alexander Mikhalitsyn --- fs/namespace.c | 3 ++- include/linux/fs.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/namespace.c b/fs/namespace.c index fbf0e596fcd3..02eb47b3d728 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -4300,7 +4300,8 @@ static int can_idmap_mount(const struct mount_kattr *kattr, struct mount *mnt) return -EPERM; /* The underlying filesystem doesn't support idmapped mounts yet. */ - if (!(m->mnt_sb->s_type->fs_flags & FS_ALLOW_IDMAP)) + if (!(m->mnt_sb->s_type->fs_flags & FS_ALLOW_IDMAP) || + (m->mnt_sb->s_type->allow_idmap && !m->mnt_sb->s_type->allow_idmap(m->mnt_sb))) return -EINVAL; /* We're not controlling the superblock. */ diff --git a/include/linux/fs.h b/include/linux/fs.h index 98b7a7a8c42e..f2e373b5420a 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2377,6 +2377,7 @@ struct file_system_type { #define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */ int (*init_fs_context)(struct fs_context *); const struct fs_parameter_spec *parameters; + bool (*allow_idmap)(struct super_block *); struct dentry *(*mount) (struct file_system_type *, int, const char *, void *); void (*kill_sb) (struct super_block *); From patchwork Mon Jan 8 12:08:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13513351 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) (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 4C798405EB for ; Mon, 8 Jan 2024 12:10:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="HPWJVlBJ" Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id C1CED3F582 for ; Mon, 8 Jan 2024 12:10:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1704715805; bh=mr8sbzdAtqXe7/XkmKXPwVfGObhH4DN7fFUmLFyq+MA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HPWJVlBJuS2/jrNzHxbrlHJeBlg0hB9uxPmoWr1lzlCKwNhiSSUcM6lMs7R6tUzJq r3dQPNXoFixG2MCxScHs/Ooh/omTc8eYp18PD6dUtFh/w3IoQwo9/pkFutETLfcgM5 cUWY0mBK4BZTE21tamOYrxNiW6fZmma/ZsjLUhmVN/Lp41+7Ag88rcuKBd//XA+oL6 aBDnL66zlZf74d5+59eXBf1nlP8aXoLxgafBMfjIgO5fFyy4QVW7ZQEjVLOf9dhwAv 5A/jyX0rI69gJwy2bTDYtBCGY4Ian4DzGLSCjZVDmzg9yugxM+s9NdguDQjJn07p2H eYxZleO7MU/Yw== Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-50e7ae03f5cso1062221e87.2 for ; Mon, 08 Jan 2024 04:10:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704715805; x=1705320605; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mr8sbzdAtqXe7/XkmKXPwVfGObhH4DN7fFUmLFyq+MA=; b=ejkvax3ytV5XFIp2rTql5GrJgwK/cp9TRjyWmECbpHYm9Y9GJBKXyy/jOYwBe6/1Ui V1usTn86MLq3na0EFirzRFa9KVJd06xGwmNIMm2stVauVSlZZ7s+JiJP2y0a5b1NcDZi eEmoOiGhkZoATT9Xa/3Qymll0IaIb/De2pNkXDvUrt+VCq4A5EPPx77J1vndbFoO1pME 8A1N2rgLQpHiWmZFOT0KtXrQixKwk2gBJqERhfVkzE1Blfen5jR+gbk1D+fBSOFULlCA JSujUcquWAxlGBHS/aPg9yML/LUK/XsHVJrEueAOaTGIOaTd+XgozUXz/EM0Ev3DS/0h yaKg== X-Gm-Message-State: AOJu0YwWccP4OhJqnKa69jbADTXpZoqUR5A5FV/jymCyu+3knKUnd5bT yxq3t2zaFjEEy2wowv0CaUDt7/bV66TdMB+806NoELTe6XG/RzlwlcotapzuPMQ/6h6GDHhnRoC u+fwzHpeZY7puAqZYl2lcWBphZvbk3DlMJNYdH/FrZKhBtia9QQ== X-Received: by 2002:ac2:5e33:0:b0:50e:52ea:771e with SMTP id o19-20020ac25e33000000b0050e52ea771emr1121317lfg.138.1704715805167; Mon, 08 Jan 2024 04:10:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IG6BVLmg1QflPR2yuZVRfqVUwsYwwfsK2JxDahvi3YR/nFvwf+wHlCc+2CTfXr7thdLqTc/fg== X-Received: by 2002:ac2:5e33:0:b0:50e:52ea:771e with SMTP id o19-20020ac25e33000000b0050e52ea771emr1121313lfg.138.1704715804894; Mon, 08 Jan 2024 04:10:04 -0800 (PST) Received: from localhost.localdomain ([91.64.72.41]) by smtp.gmail.com with ESMTPSA id fi21-20020a056402551500b005578b816f20sm1767959edb.29.2024.01.08.04.10.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 04:10:04 -0800 (PST) From: Alexander Mikhalitsyn To: mszeredi@redhat.com Cc: brauner@kernel.org, stgraber@stgraber.org, linux-fsdevel@vger.kernel.org, Miklos Szeredi , Seth Forshee , Amir Goldstein , Bernd Schubert , Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v1 2/9] fs/fuse: add FUSE_OWNER_UID_GID_EXT extension Date: Mon, 8 Jan 2024 13:08:17 +0100 Message-Id: <20240108120824.122178-3-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240108120824.122178-1-aleksandr.mikhalitsyn@canonical.com> References: <20240108120824.122178-1-aleksandr.mikhalitsyn@canonical.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To properly support vfs idmappings we need to provide a fuse daemon with the correct owner uid/gid for inode creation requests like mkdir, mknod, atomic_open, symlink. Right now, fuse daemons use req->in.h.uid/req->in.h.gid to set inode owner. These fields contain fsuid/fsgid of the syscall's caller. And that's perfectly fine, because inode owner have to be set to these values. But, for idmapped mounts it's not the case and caller fsuid/fsgid != inode owner, because idmapped mounts do nothing with the caller fsuid/fsgid, but affect inode owner uid/gid. It means that we can't apply vfsid mapping to caller fsuid/fsgid, but instead we have to introduce a new fields to store inode owner uid/gid which will be appropriately transformed. Christian and I have done the same to support idmapped mounts in the cephfs recently [1]. [1] 5ccd8530 ("ceph: handle idmapped mounts in create_request_message()") Cc: Miklos Szeredi Cc: Christian Brauner Cc: Seth Forshee Cc: Amir Goldstein Cc: Bernd Schubert Cc: Signed-off-by: Alexander Mikhalitsyn --- fs/fuse/dir.c | 34 +++++++++++++++++++++++++++++++--- fs/fuse/fuse_i.h | 3 +++ fs/fuse/inode.c | 4 +++- include/uapi/linux/fuse.h | 19 +++++++++++++++++++ 4 files changed, 56 insertions(+), 4 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 6f5f9ff95380..e78ad4742aef 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -568,7 +568,33 @@ static int get_create_supp_group(struct inode *dir, struct fuse_in_arg *ext) return 0; } -static int get_create_ext(struct fuse_args *args, +static int get_owner_uid_gid(struct mnt_idmap *idmap, struct fuse_conn *fc, struct fuse_in_arg *ext) +{ + struct fuse_ext_header *xh; + struct fuse_owner_uid_gid *owner_creds; + u32 owner_creds_len = fuse_ext_size(sizeof(*owner_creds)); + kuid_t owner_fsuid; + kgid_t owner_fsgid; + + xh = extend_arg(ext, owner_creds_len); + if (!xh) + return -ENOMEM; + + xh->size = owner_creds_len; + xh->type = FUSE_EXT_OWNER_UID_GID; + + owner_creds = (struct fuse_owner_uid_gid *) &xh[1]; + + owner_fsuid = mapped_fsuid(idmap, fc->user_ns); + owner_fsgid = mapped_fsgid(idmap, fc->user_ns); + owner_creds->uid = from_kuid(fc->user_ns, owner_fsuid); + owner_creds->gid = from_kgid(fc->user_ns, owner_fsgid); + + return 0; +} + +static int get_create_ext(struct mnt_idmap *idmap, + struct fuse_args *args, struct inode *dir, struct dentry *dentry, umode_t mode) { @@ -580,6 +606,8 @@ static int get_create_ext(struct fuse_args *args, err = get_security_context(dentry, mode, &ext); if (!err && fc->create_supp_group) err = get_create_supp_group(dir, &ext); + if (!err && fc->owner_uid_gid_ext) + err = get_owner_uid_gid(idmap, fc, &ext); if (!err && ext.size) { WARN_ON(args->in_numargs >= ARRAY_SIZE(args->in_args)); @@ -662,7 +690,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, args.out_args[1].size = sizeof(outopen); args.out_args[1].value = &outopen; - err = get_create_ext(&args, dir, entry, mode); + err = get_create_ext(&nop_mnt_idmap, &args, dir, entry, mode); if (err) goto out_put_forget_req; @@ -790,7 +818,7 @@ static int create_new_entry(struct fuse_mount *fm, struct fuse_args *args, args->out_args[0].value = &outarg; if (args->opcode != FUSE_LINK) { - err = get_create_ext(args, dir, entry, mode); + err = get_create_ext(&nop_mnt_idmap, args, dir, entry, mode); if (err) goto out_put_forget_req; } diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 1df83eebda92..15ec95dea276 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -806,6 +806,9 @@ struct fuse_conn { /* Add supplementary group info when creating a new inode */ unsigned int create_supp_group:1; + /* Add owner_{u,g}id info when creating a new inode */ + unsigned int owner_uid_gid_ext:1; + /* Does the filesystem support per inode DAX? */ unsigned int inode_dax:1; diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index ab824a8908b7..08cd3714b32d 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -1284,6 +1284,8 @@ static void process_init_reply(struct fuse_mount *fm, struct fuse_args *args, fc->create_supp_group = 1; if (flags & FUSE_DIRECT_IO_ALLOW_MMAP) fc->direct_io_allow_mmap = 1; + if (flags & FUSE_OWNER_UID_GID_EXT) + fc->owner_uid_gid_ext = 1; } else { ra_pages = fc->max_read / PAGE_SIZE; fc->no_lock = 1; @@ -1330,7 +1332,7 @@ void fuse_send_init(struct fuse_mount *fm) FUSE_NO_OPENDIR_SUPPORT | FUSE_EXPLICIT_INVAL_DATA | FUSE_HANDLE_KILLPRIV_V2 | FUSE_SETXATTR_EXT | FUSE_INIT_EXT | FUSE_SECURITY_CTX | FUSE_CREATE_SUPP_GROUP | - FUSE_HAS_EXPIRE_ONLY | FUSE_DIRECT_IO_ALLOW_MMAP; + FUSE_HAS_EXPIRE_ONLY | FUSE_DIRECT_IO_ALLOW_MMAP | FUSE_OWNER_UID_GID_EXT; #ifdef CONFIG_FUSE_DAX if (fm->fc->dax) flags |= FUSE_MAP_ALIGNMENT; diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index e7418d15fe39..ebe82104b172 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -211,6 +211,10 @@ * 7.39 * - add FUSE_DIRECT_IO_ALLOW_MMAP * - add FUSE_STATX and related structures + * + * 7.40 + * - add FUSE_EXT_OWNER_UID_GID + * - add FUSE_OWNER_UID_GID_EXT */ #ifndef _LINUX_FUSE_H @@ -410,6 +414,8 @@ struct fuse_file_lock { * symlink and mknod (single group that matches parent) * FUSE_HAS_EXPIRE_ONLY: kernel supports expiry-only entry invalidation * FUSE_DIRECT_IO_ALLOW_MMAP: allow shared mmap in FOPEN_DIRECT_IO mode. + * FUSE_OWNER_UID_GID_EXT: add inode owner UID/GID info to create, mkdir, + * symlink and mknod */ #define FUSE_ASYNC_READ (1 << 0) #define FUSE_POSIX_LOCKS (1 << 1) @@ -452,6 +458,7 @@ struct fuse_file_lock { /* Obsolete alias for FUSE_DIRECT_IO_ALLOW_MMAP */ #define FUSE_DIRECT_IO_RELAX FUSE_DIRECT_IO_ALLOW_MMAP +#define FUSE_OWNER_UID_GID_EXT (1ULL << 37) /** * CUSE INIT request/reply flags @@ -561,11 +568,13 @@ struct fuse_file_lock { * extension type * FUSE_MAX_NR_SECCTX: maximum value of &fuse_secctx_header.nr_secctx * FUSE_EXT_GROUPS: &fuse_supp_groups extension + * FUSE_EXT_OWNER_UID_GID: &fuse_owner_uid_gid extension */ enum fuse_ext_type { /* Types 0..31 are reserved for fuse_secctx_header */ FUSE_MAX_NR_SECCTX = 31, FUSE_EXT_GROUPS = 32, + FUSE_EXT_OWNER_UID_GID = 33, }; enum fuse_opcode { @@ -1153,4 +1162,14 @@ struct fuse_supp_groups { uint32_t groups[]; }; +/** + * struct fuse_owner_uid_gid - Inode owner UID/GID extension + * @uid: inode owner UID + * @gid: inode owner GID + */ +struct fuse_owner_uid_gid { + uint32_t uid; + uint32_t gid; +}; + #endif /* _LINUX_FUSE_H */ From patchwork Mon Jan 8 12:08:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13513352 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) (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 9686540BE9 for ; Mon, 8 Jan 2024 12:10:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="Z7OPTZJq" Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id DDC373F5AA for ; Mon, 8 Jan 2024 12:10:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1704715808; bh=Qlcho8chuufL9JmbPqtNzk4zs+rMss6COIQOi9IfnOw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Z7OPTZJqsSTCPqB11nkcuok0NL+getiF4kfHK53/PNFHn4Uv6aemMR2Mi8FRhBfce OLeTmwjJvMdHJhOSD72VFNp7V5nSJGjB55xuSydr/h2o/reKMPLRVhzB4oTh1TbWhX 4xipx579TV4Pz8xvrVbGynKilJd/fqS3Erh+2EoylL417h74enGWvTvgHbxm4l9+tF 25pR/2l3JjaPAsxJ/fQH2W08XaKs7IBQfQ7VJQniQf48hg9hgufNKQbukv23+Um4mL E9DTG1mmSEyejnSCJlgdRJSDVkwLX65eGa4BoydvwG6o4xG5h1v6wfFPfgobN1CoKy kp8IKWpUGrfSg== Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2cce9d6ec6bso14439191fa.2 for ; Mon, 08 Jan 2024 04:10:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704715808; x=1705320608; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Qlcho8chuufL9JmbPqtNzk4zs+rMss6COIQOi9IfnOw=; b=aoCmKQtsvHfNPCYHpI+rAbSkaLhUpPrfBXlG+BY8WqPkzriaypAmS8VrQDo9hYZDW7 YSFbNGLcJJi1yjbcR+fCB8aR66pWQXvnLUAT195jFx3mn3IpzBDWqCiuK6+MfCZ2LFUK QXcnhApH38+lyUFiqPnZptKjx0Tu5NbcKRo/qC6wzvpjSt0EyTscanNYCNDn5qzctOvb J9b4DvfZunvza0uqseDoKB4xzXyCNPCJrDdjufTAU0a+JmuUZjNZIMkPIJc1KPTmmPHu NiBxLZ6lPJTscKtnT2R0dffOiYYAEZ0wKGSj7fnziqGVUn7mIgY8Du94ne8XZfGesuCG bOmw== X-Gm-Message-State: AOJu0YzoEAsx3E/CRww3GY5OGRnlE6jkNsqGjYu1GhRUqZ7UDUYUUsxn OPy0VkPdhdeDSC7msZw3DgHtAL9GFBpEisHcssYUlgb/sjSR8B8wfZ1n3YfRYtqw6wD8wfax9EK VY2/3PPMV2Hd5CC2X6NYsDi/32DJq7yrzjSCORFmYNsSL0NW/2w== X-Received: by 2002:a2e:3005:0:b0:2cc:8545:d6f9 with SMTP id w5-20020a2e3005000000b002cc8545d6f9mr1455627ljw.15.1704715808240; Mon, 08 Jan 2024 04:10:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IE6Cz/42DbzT+orPD/r3QKq1nu0ZTzoybNkUSmzDw8l2XlSCl2Tn0YWn6jBVA8XteZl0oCtPw== X-Received: by 2002:a2e:3005:0:b0:2cc:8545:d6f9 with SMTP id w5-20020a2e3005000000b002cc8545d6f9mr1455623ljw.15.1704715808045; Mon, 08 Jan 2024 04:10:08 -0800 (PST) Received: from localhost.localdomain ([91.64.72.41]) by smtp.gmail.com with ESMTPSA id fi21-20020a056402551500b005578b816f20sm1767959edb.29.2024.01.08.04.10.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 04:10:07 -0800 (PST) From: Alexander Mikhalitsyn To: mszeredi@redhat.com Cc: brauner@kernel.org, stgraber@stgraber.org, linux-fsdevel@vger.kernel.org, Seth Forshee , Miklos Szeredi , Amir Goldstein , Bernd Schubert , Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v1 3/9] fs/fuse: support idmap for mkdir/mknod/symlink/create Date: Mon, 8 Jan 2024 13:08:18 +0100 Message-Id: <20240108120824.122178-4-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240108120824.122178-1-aleksandr.mikhalitsyn@canonical.com> References: <20240108120824.122178-1-aleksandr.mikhalitsyn@canonical.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We have all the infrastructure in place, we just need to pass an idmapping here. Cc: Christian Brauner Cc: Seth Forshee Cc: Miklos Szeredi Cc: Amir Goldstein Cc: Bernd Schubert Cc: Signed-off-by: Alexander Mikhalitsyn --- fs/fuse/dir.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index e78ad4742aef..a0968f086b62 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -633,9 +633,9 @@ static void free_ext_value(struct fuse_args *args) * If the filesystem doesn't support this, then fall back to separate * 'mknod' + 'open' requests. */ -static int fuse_create_open(struct inode *dir, struct dentry *entry, - struct file *file, unsigned int flags, - umode_t mode, u32 opcode) +static int fuse_create_open(struct mnt_idmap *idmap, struct inode *dir, + struct dentry *entry, struct file *file, + unsigned int flags, umode_t mode, u32 opcode) { int err; struct inode *inode; @@ -690,7 +690,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, args.out_args[1].size = sizeof(outopen); args.out_args[1].value = &outopen; - err = get_create_ext(&nop_mnt_idmap, &args, dir, entry, mode); + err = get_create_ext(idmap, &args, dir, entry, mode); if (err) goto out_put_forget_req; @@ -749,6 +749,7 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry, umode_t mode) { int err; + struct mnt_idmap *idmap = file_mnt_idmap(file); struct fuse_conn *fc = get_fuse_conn(dir); struct dentry *res = NULL; @@ -773,7 +774,7 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry, if (fc->no_create) goto mknod; - err = fuse_create_open(dir, entry, file, flags, mode, FUSE_CREATE); + err = fuse_create_open(idmap, dir, entry, file, flags, mode, FUSE_CREATE); if (err == -ENOSYS) { fc->no_create = 1; goto mknod; @@ -784,7 +785,7 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry, return err; mknod: - err = fuse_mknod(&nop_mnt_idmap, dir, entry, mode, 0); + err = fuse_mknod(idmap, dir, entry, mode, 0); if (err) goto out_dput; no_open: @@ -794,9 +795,9 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry, /* * Code shared between mknod, mkdir, symlink and link */ -static int create_new_entry(struct fuse_mount *fm, struct fuse_args *args, - struct inode *dir, struct dentry *entry, - umode_t mode) +static int create_new_entry(struct mnt_idmap *idmap, struct fuse_mount *fm, + struct fuse_args *args, struct inode *dir, + struct dentry *entry, umode_t mode) { struct fuse_entry_out outarg; struct inode *inode; @@ -818,7 +819,7 @@ static int create_new_entry(struct fuse_mount *fm, struct fuse_args *args, args->out_args[0].value = &outarg; if (args->opcode != FUSE_LINK) { - err = get_create_ext(&nop_mnt_idmap, args, dir, entry, mode); + err = get_create_ext(idmap, args, dir, entry, mode); if (err) goto out_put_forget_req; } @@ -884,13 +885,13 @@ static int fuse_mknod(struct mnt_idmap *idmap, struct inode *dir, args.in_args[0].value = &inarg; args.in_args[1].size = entry->d_name.len + 1; args.in_args[1].value = entry->d_name.name; - return create_new_entry(fm, &args, dir, entry, mode); + return create_new_entry(idmap, fm, &args, dir, entry, mode); } static int fuse_create(struct mnt_idmap *idmap, struct inode *dir, struct dentry *entry, umode_t mode, bool excl) { - return fuse_mknod(&nop_mnt_idmap, dir, entry, mode, 0); + return fuse_mknod(idmap, dir, entry, mode, 0); } static int fuse_tmpfile(struct mnt_idmap *idmap, struct inode *dir, @@ -902,7 +903,7 @@ static int fuse_tmpfile(struct mnt_idmap *idmap, struct inode *dir, if (fc->no_tmpfile) return -EOPNOTSUPP; - err = fuse_create_open(dir, file->f_path.dentry, file, file->f_flags, mode, FUSE_TMPFILE); + err = fuse_create_open(idmap, dir, file->f_path.dentry, file, file->f_flags, mode, FUSE_TMPFILE); if (err == -ENOSYS) { fc->no_tmpfile = 1; err = -EOPNOTSUPP; @@ -929,7 +930,7 @@ static int fuse_mkdir(struct mnt_idmap *idmap, struct inode *dir, args.in_args[0].value = &inarg; args.in_args[1].size = entry->d_name.len + 1; args.in_args[1].value = entry->d_name.name; - return create_new_entry(fm, &args, dir, entry, S_IFDIR); + return create_new_entry(idmap, fm, &args, dir, entry, S_IFDIR); } static int fuse_symlink(struct mnt_idmap *idmap, struct inode *dir, @@ -945,7 +946,7 @@ static int fuse_symlink(struct mnt_idmap *idmap, struct inode *dir, args.in_args[0].value = entry->d_name.name; args.in_args[1].size = len; args.in_args[1].value = link; - return create_new_entry(fm, &args, dir, entry, S_IFLNK); + return create_new_entry(idmap, fm, &args, dir, entry, S_IFLNK); } void fuse_flush_time_update(struct inode *inode) @@ -1139,7 +1140,7 @@ static int fuse_link(struct dentry *entry, struct inode *newdir, args.in_args[0].value = &inarg; args.in_args[1].size = newent->d_name.len + 1; args.in_args[1].value = newent->d_name.name; - err = create_new_entry(fm, &args, newdir, newent, inode->i_mode); + err = create_new_entry(&nop_mnt_idmap, fm, &args, newdir, newent, inode->i_mode); if (!err) fuse_update_ctime_in_cache(inode); else if (err == -EINTR) From patchwork Mon Jan 8 12:08:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13513353 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) (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 3D1B540BFE for ; Mon, 8 Jan 2024 12:10:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="JARV6rrm" Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 65CC53F5B0 for ; Mon, 8 Jan 2024 12:10:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1704715811; bh=mADyhqp5Fy5mB38qoO1ZIXMT9rQkzzjtNQqjvzvAMZk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JARV6rrmrwl2dhrMxKwjtxHhcxrvvpFrG9B38kB6ZgU8sFjV0WvPP+N3Z8Qj7x8lP 2RRTd/AJAbC593xYTRenNmvwiXG+KbzjHUyvS9LcMczyqQHKrCLM51zAxWyrYUD50s +irn3t+jwSALdadtoN7qtoJzpfluHp7N2qzVsq23BvqFPYt1aZlGjHAY76cRzeJtsB zI6/pTboBLxHh0dq3ftvLHAuXz4cpxnlOpqPbppDPv+JxaGdME17pOh30y63bGpMT9 O4KGKqp9NNKGeZhqWbHNzbMh5sz+L40kiREgQcGLzuTcsIe3d9Nl6pFZxMxQct/ss9 ENsYu+ndcaTIg== Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2cd1d820fe7so13859761fa.1 for ; Mon, 08 Jan 2024 04:10:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704715811; x=1705320611; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mADyhqp5Fy5mB38qoO1ZIXMT9rQkzzjtNQqjvzvAMZk=; b=Ii8x9tbcXK5J2GIheeB1i8qxdZcEFzd5P/RV/LqdbEkP8f2t0007VT6A5PmLTrpe0t t7DimUoZNd7/NjDfV5KCosVkp8B8V6SOpYQPaCs+SnjMpin/DXZ5sZOVXqgsQHNpJB37 fcKdyWdxFoJbRFBtOC3KAWVk5xuXP2Q1mxl1IgXIlXyyrK88S0icsNj/DFT1QXiQ9cTP b+PMwH+lxDY6mxdh8J91U9z1dpV4nOhbGvdAhVL1ed0UNfD1YhoditTHFMwx9lrm7ubL VyfEQXZmYfw4GNI8PBFtHp76xSeAYKcBa7j5uMG7GKIikUkZa15x6HSNyepGZ0id8jUb qzSQ== X-Gm-Message-State: AOJu0YxAgwSl8lo8teTj1LrkC4w3D1zMD+9wPnh20xncThV1s/rKUedg k9JSUMVPEmO5IMvkw3jrM2RJKKSjDrIlFNeWo0R9nqqz586gjrLtx4z1zk5VFFUkd+u99jhgt2r jGTKJaqCumEVkN3oLgeoM+cBwV4mbqiA70e1Yv7myL8HsfBSCAA== X-Received: by 2002:a2e:b384:0:b0:2cd:57ba:b4f2 with SMTP id f4-20020a2eb384000000b002cd57bab4f2mr489989lje.79.1704715810870; Mon, 08 Jan 2024 04:10:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IGXiihwIK3jmo6piZR/rMi5zufkqOFkZO264KCNFzXCABUwA04B3BKVjQVddj/nKgCIB6bAsg== X-Received: by 2002:a2e:b384:0:b0:2cd:57ba:b4f2 with SMTP id f4-20020a2eb384000000b002cd57bab4f2mr489976lje.79.1704715810668; Mon, 08 Jan 2024 04:10:10 -0800 (PST) Received: from localhost.localdomain ([91.64.72.41]) by smtp.gmail.com with ESMTPSA id fi21-20020a056402551500b005578b816f20sm1767959edb.29.2024.01.08.04.10.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 04:10:09 -0800 (PST) From: Alexander Mikhalitsyn To: mszeredi@redhat.com Cc: brauner@kernel.org, stgraber@stgraber.org, linux-fsdevel@vger.kernel.org, Seth Forshee , Miklos Szeredi , Amir Goldstein , Bernd Schubert , Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v1 4/9] fs/fuse: support idmapped getattr inode op Date: Mon, 8 Jan 2024 13:08:19 +0100 Message-Id: <20240108120824.122178-5-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240108120824.122178-1-aleksandr.mikhalitsyn@canonical.com> References: <20240108120824.122178-1-aleksandr.mikhalitsyn@canonical.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We have to: - pass an idmapping to the generic_fillattr() to properly handle UIG/GID mapping for the userspace. - pass -/- to fuse_fillattr() (analog of generic_fillattr() in fuse). Difference between these two is that generic_fillattr() takes all the stat() data from the inode directly, while fuse_fillattr() codepath takes a fresh data just from the userspace reply on the FUSE_GETATTR request. Cc: Christian Brauner Cc: Seth Forshee Cc: Miklos Szeredi Cc: Amir Goldstein Cc: Bernd Schubert Cc: Signed-off-by: Alexander Mikhalitsyn --- fs/fuse/dir.c | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index a0968f086b62..5efcf06622f0 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -1149,18 +1149,22 @@ static int fuse_link(struct dentry *entry, struct inode *newdir, return err; } -static void fuse_fillattr(struct inode *inode, struct fuse_attr *attr, - struct kstat *stat) +static void fuse_fillattr(struct mnt_idmap *idmap, struct inode *inode, + struct fuse_attr *attr, struct kstat *stat) { unsigned int blkbits; struct fuse_conn *fc = get_fuse_conn(inode); + vfsuid_t vfsuid = make_vfsuid(idmap, fc->user_ns, + make_kuid(fc->user_ns, attr->uid)); + vfsgid_t vfsgid = make_vfsgid(idmap, fc->user_ns, + make_kgid(fc->user_ns, attr->gid)); stat->dev = inode->i_sb->s_dev; stat->ino = attr->ino; stat->mode = (inode->i_mode & S_IFMT) | (attr->mode & 07777); stat->nlink = attr->nlink; - stat->uid = make_kuid(fc->user_ns, attr->uid); - stat->gid = make_kgid(fc->user_ns, attr->gid); + stat->uid = vfsuid_into_kuid(vfsuid); + stat->gid = vfsgid_into_kgid(vfsgid); stat->rdev = inode->i_rdev; stat->atime.tv_sec = attr->atime; stat->atime.tv_nsec = attr->atimensec; @@ -1199,8 +1203,8 @@ static void fuse_statx_to_attr(struct fuse_statx *sx, struct fuse_attr *attr) attr->blksize = sx->blksize; } -static int fuse_do_statx(struct inode *inode, struct file *file, - struct kstat *stat) +static int fuse_do_statx(struct mnt_idmap *idmap, struct inode *inode, + struct file *file, struct kstat *stat) { int err; struct fuse_attr attr; @@ -1253,15 +1257,15 @@ static int fuse_do_statx(struct inode *inode, struct file *file, stat->result_mask = sx->mask & (STATX_BASIC_STATS | STATX_BTIME); stat->btime.tv_sec = sx->btime.tv_sec; stat->btime.tv_nsec = min_t(u32, sx->btime.tv_nsec, NSEC_PER_SEC - 1); - fuse_fillattr(inode, &attr, stat); + fuse_fillattr(idmap, inode, &attr, stat); stat->result_mask |= STATX_TYPE; } return 0; } -static int fuse_do_getattr(struct inode *inode, struct kstat *stat, - struct file *file) +static int fuse_do_getattr(struct mnt_idmap *idmap, struct inode *inode, + struct kstat *stat, struct file *file) { int err; struct fuse_getattr_in inarg; @@ -1300,15 +1304,15 @@ static int fuse_do_getattr(struct inode *inode, struct kstat *stat, ATTR_TIMEOUT(&outarg), attr_version); if (stat) - fuse_fillattr(inode, &outarg.attr, stat); + fuse_fillattr(idmap, inode, &outarg.attr, stat); } } return err; } -static int fuse_update_get_attr(struct inode *inode, struct file *file, - struct kstat *stat, u32 request_mask, - unsigned int flags) +static int fuse_update_get_attr(struct mnt_idmap *idmap, struct inode *inode, + struct file *file, struct kstat *stat, + u32 request_mask, unsigned int flags) { struct fuse_inode *fi = get_fuse_inode(inode); struct fuse_conn *fc = get_fuse_conn(inode); @@ -1339,16 +1343,16 @@ static int fuse_update_get_attr(struct inode *inode, struct file *file, forget_all_cached_acls(inode); /* Try statx if BTIME is requested */ if (!fc->no_statx && (request_mask & ~STATX_BASIC_STATS)) { - err = fuse_do_statx(inode, file, stat); + err = fuse_do_statx(idmap, inode, file, stat); if (err == -ENOSYS) { fc->no_statx = 1; goto retry; } } else { - err = fuse_do_getattr(inode, stat, file); + err = fuse_do_getattr(idmap, inode, stat, file); } } else if (stat) { - generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat); + generic_fillattr(idmap, request_mask, inode, stat); stat->mode = fi->orig_i_mode; stat->ino = fi->orig_ino; if (test_bit(FUSE_I_BTIME, &fi->state)) { @@ -1362,7 +1366,7 @@ static int fuse_update_get_attr(struct inode *inode, struct file *file, int fuse_update_attributes(struct inode *inode, struct file *file, u32 mask) { - return fuse_update_get_attr(inode, file, NULL, mask, 0); + return fuse_update_get_attr(&nop_mnt_idmap, inode, file, NULL, mask, 0); } int fuse_reverse_inval_entry(struct fuse_conn *fc, u64 parent_nodeid, @@ -1506,7 +1510,7 @@ static int fuse_perm_getattr(struct inode *inode, int mask) return -ECHILD; forget_all_cached_acls(inode); - return fuse_do_getattr(inode, NULL, NULL); + return fuse_do_getattr(&nop_mnt_idmap, inode, NULL, NULL); } /* @@ -2062,7 +2066,7 @@ static int fuse_setattr(struct mnt_idmap *idmap, struct dentry *entry, * ia_mode calculation may have used stale i_mode. * Refresh and recalculate. */ - ret = fuse_do_getattr(inode, NULL, file); + ret = fuse_do_getattr(&nop_mnt_idmap, inode, NULL, file); if (ret) return ret; @@ -2119,7 +2123,7 @@ static int fuse_getattr(struct mnt_idmap *idmap, return -EACCES; } - return fuse_update_get_attr(inode, NULL, stat, request_mask, flags); + return fuse_update_get_attr(idmap, inode, NULL, stat, request_mask, flags); } static const struct inode_operations fuse_dir_inode_operations = { From patchwork Mon Jan 8 12:08:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13513354 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) (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 176794122A for ; Mon, 8 Jan 2024 12:10:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="JtN9iQVC" Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 30CA03F5A7 for ; Mon, 8 Jan 2024 12:10:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1704715814; bh=aN55u2dkdKkT9zGjEjP2EnVAXA2m3PLWvFfoTZsXkV4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JtN9iQVC11J1SchqzCJSRAg67r4S5UDZyehwGkKERF25+8lAosFuE4pCdCR68SB8g MphGgwr75jSZnX/s1MOP7bth5iHDAe4utxzy6DV+IRP0sG+Jz/3KkyTRDTpND605Lo 4267d/R91yMcgAy8x2myT4H+wGqVTJQUjrCLMep+yhAtJTuTHCgF7BG4aC3aKyP4TE WL1V3HacZaHShDyeE8V3kmpas1YukBQxfNwjoNpQDQ/FMAv1FHGEZ5MAa0Mk+5SATp 2DKmUXnVcVzUmZf3sPGuyWCjlBE1HoSlXHQFPV4IaSUfiQkSdBMfVj2R2yF/9XSQNr ANkiBvT+2Wrxg== Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-556c60c7eb8so779385a12.0 for ; Mon, 08 Jan 2024 04:10:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704715814; x=1705320614; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aN55u2dkdKkT9zGjEjP2EnVAXA2m3PLWvFfoTZsXkV4=; b=CHZimnpJPZ9dIH9SQ9sKIA83EoOFChqa/G4f+TZEvxZq5Lp8RviaQaYwIlLndU/cht VrkZW6isf0fvRxuY9ZRTROBPuc62ZJBIaAJ8ajERVkWt2tMnjl9ZL2hn2rz62Zez2Cz8 +JCmahteBIN927SSFjrT21w+n5nF83czAQNiKK0U82IZZZjNKte07vnDcxkJKVKKKW/l H6QK0W9rnvkPI992KDKlvUiESWT6s+wY2WzMYptpOy1H+bkKcb1U7jJNZQ5Q5ITZHp7U wWWVTCobMcMF+O9gsGQfxJY7An71aZjrNB4Wz9ZCwY1Gfi8d+JZbAwqLNNK7R98aHyiy JAEw== X-Gm-Message-State: AOJu0YzreVr1kgtj22JXQaXlkc8MEBnekpqgnaxJ1OR6WmzAxryIWNRZ rg2DL1f+kdZNzqBeg/qs9lGv4TTcs6Ft0FNGl1kl+nY1XMdMcDI+iI/2MPE6EFwvH9S+efLdG5R PozuwzYUfT/8ckGxZiLxK9hLLBtvmf7fDq9RWlMgqyYeLw00CVQ== X-Received: by 2002:a50:8ac4:0:b0:553:a041:3560 with SMTP id k4-20020a508ac4000000b00553a0413560mr2378966edk.58.1704715813685; Mon, 08 Jan 2024 04:10:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IGJP5eOOFi4zff3/kz6KkKpi/0hmrVe9vDrjDdCDnW47eqq7qvcAY6eriI0cBf+y7RTehsDkQ== X-Received: by 2002:a50:8ac4:0:b0:553:a041:3560 with SMTP id k4-20020a508ac4000000b00553a0413560mr2378953edk.58.1704715813387; Mon, 08 Jan 2024 04:10:13 -0800 (PST) Received: from localhost.localdomain ([91.64.72.41]) by smtp.gmail.com with ESMTPSA id fi21-20020a056402551500b005578b816f20sm1767959edb.29.2024.01.08.04.10.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 04:10:12 -0800 (PST) From: Alexander Mikhalitsyn To: mszeredi@redhat.com Cc: brauner@kernel.org, stgraber@stgraber.org, linux-fsdevel@vger.kernel.org, Seth Forshee , Miklos Szeredi , Amir Goldstein , Bernd Schubert , Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v1 5/9] fs/fuse: support idmapped ->permission inode op Date: Mon, 8 Jan 2024 13:08:20 +0100 Message-Id: <20240108120824.122178-6-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240108120824.122178-1-aleksandr.mikhalitsyn@canonical.com> References: <20240108120824.122178-1-aleksandr.mikhalitsyn@canonical.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We only cover the case when "default_permissions" flag is used. A reason for that is that otherwise all the permission checks are done in the userspace and we have to deal with VFS idmapping in the userspace (which is bad), alternatively we have to provide the userspace with idmapped req->in.h.uid/req->in.h.gid which is also not align with VFS idmaps philosophy. Cc: Christian Brauner Cc: Seth Forshee Cc: Miklos Szeredi Cc: Amir Goldstein Cc: Bernd Schubert Cc: Signed-off-by: Alexander Mikhalitsyn --- fs/fuse/dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 5efcf06622f0..f7c2c54f7122 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -1558,7 +1558,7 @@ static int fuse_permission(struct mnt_idmap *idmap, } if (fc->default_permissions) { - err = generic_permission(&nop_mnt_idmap, inode, mask); + err = generic_permission(idmap, inode, mask); /* If permission is denied, try to refresh file attributes. This is also needed, because the root @@ -1566,7 +1566,7 @@ static int fuse_permission(struct mnt_idmap *idmap, if (err == -EACCES && !refreshed) { err = fuse_perm_getattr(inode, mask); if (!err) - err = generic_permission(&nop_mnt_idmap, + err = generic_permission(idmap, inode, mask); } From patchwork Mon Jan 8 12:08:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13513355 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) (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 E57824123B for ; Mon, 8 Jan 2024 12:10:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="O3ONM7m+" Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id C64843F45F for ; Mon, 8 Jan 2024 12:10:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1704715816; bh=9JOCkZnahtYcjH5f/6OzDGT6n3cRWHJ6WXIUPPzUvyw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=O3ONM7m+eFjSrc/qCOGyOSDoP9mzxvpW4mg13LZQzt8raSR+yZG6qNs2lC2pPNcMk dadoWRzbK4UGfN4gTf9E/0DaukJwudqo02FI8BWvdETQ7OGtHkavTqX4rxGD6rLRwL vPRhArHbHXFnX0RwZwebAV0XbY+T2Pg8efOatTJOygVazKdVjOQjSjI4irgxSb1IAW bROfPJFdaQp6nYlT7AMvpxq7eHAhyXgM7XR1xaoCW7aL0qlkAiaE/6NMCKkbRwRigj E9HA/A/dwFNroT5HcsaAYlRfbUQDJIBDKFceJ92Yc0DCCaxvRywXEPX0ijlebi3pio Ad1Mp63ezzmcg== Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-55369c474e1so939784a12.0 for ; Mon, 08 Jan 2024 04:10:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704715816; x=1705320616; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9JOCkZnahtYcjH5f/6OzDGT6n3cRWHJ6WXIUPPzUvyw=; b=svgGGhIQYNuX6qygsm9mq0IojcWdnmMeEnkv8TaaW+/RptHAvFn2LJxAmPQCOQM6UD ZzN0+qBbJVUC1GUUFuEP0qv4u93Xxxc3V38pDIeWPVFW8k2GBehj36WmVZLd+F5TPSLe 6pOu2BazueViMSkfrgDbS+CNRBQo0uWV1Uyi7GBBDR3QHThgaPpG7u8Vd9KHKTx3+rul HlDG3XF2lbpWgGVKEucu5YEFerianuY9k3y6iE54D6KPbu/uOLTWZ/Tk/G107XOPXl8e QQ07KV0GtwKDMGC2XCAkb3lr8KLk6zKyN5+Q1X9ZHRuiMIXl0tXfwbnvYNT04xjNqAuo BG8Q== X-Gm-Message-State: AOJu0YzhDt3OFC7OnlWJFfp3NiMer+M0xFid638G6mUThzY/2rv9dbGa +HV5s4f5t0W0nzrsEliAqNocmwMckaNNOpzp7rRf1MJ7HUGJTGlfji06lY/6V2rwKkaAJGb+e8i 9z0u9VNRg6j2CPWcUYVnaFgND4eVY9uPMA/rEUtB9J/219tXvhw== X-Received: by 2002:a50:9e24:0:b0:557:2213:bc4e with SMTP id z33-20020a509e24000000b005572213bc4emr1414495ede.57.1704715816370; Mon, 08 Jan 2024 04:10:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IHw8peZwjRNS6HnIeq6gf9kiSM/PadeOHzJBqN/8B3lBmvGk2+H+2sR5ks64RD0Cx44QtvI+w== X-Received: by 2002:a50:9e24:0:b0:557:2213:bc4e with SMTP id z33-20020a509e24000000b005572213bc4emr1414490ede.57.1704715816191; Mon, 08 Jan 2024 04:10:16 -0800 (PST) Received: from localhost.localdomain ([91.64.72.41]) by smtp.gmail.com with ESMTPSA id fi21-20020a056402551500b005578b816f20sm1767959edb.29.2024.01.08.04.10.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 04:10:14 -0800 (PST) From: Alexander Mikhalitsyn To: mszeredi@redhat.com Cc: brauner@kernel.org, stgraber@stgraber.org, linux-fsdevel@vger.kernel.org, Seth Forshee , Miklos Szeredi , Amir Goldstein , Bernd Schubert , Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v1 6/9] fs/fuse: support idmapped ->setattr op Date: Mon, 8 Jan 2024 13:08:21 +0100 Message-Id: <20240108120824.122178-7-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240108120824.122178-1-aleksandr.mikhalitsyn@canonical.com> References: <20240108120824.122178-1-aleksandr.mikhalitsyn@canonical.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Cc: Christian Brauner Cc: Seth Forshee Cc: Miklos Szeredi Cc: Amir Goldstein Cc: Bernd Schubert Cc: Signed-off-by: Alexander Mikhalitsyn --- 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); } static inline loff_t fuse_round_up(struct fuse_conn *fc, loff_t off) diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 15ec95dea276..94b25ea5344a 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1288,8 +1288,8 @@ bool fuse_write_update_attr(struct inode *inode, loff_t pos, ssize_t written); int fuse_flush_times(struct inode *inode, struct fuse_file *ff); int fuse_write_inode(struct inode *inode, struct writeback_control *wbc); -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); void fuse_set_initialized(struct fuse_conn *fc); From patchwork Mon Jan 8 12:08:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13513356 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) (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 193AE41774 for ; Mon, 8 Jan 2024 12:10:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="oZgET+09" Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 9F1083F737 for ; Mon, 8 Jan 2024 12:10:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1704715819; bh=AZ1e4DQplobEkYb2oelZJP/g6uMuj6ixR2NKn4USgqo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oZgET+09Ka8MNP9uDRDSiEXoBiVx6GYwnMHXNDL4GQCvAdtU6ymuhi9QMZobpNiLI y1ek8B3KBeTZsMv6+8Ks72uRfZCg4wtlJezxSwDVrM35BRcg/jtf+xCloGAJzR6X6z +6xcfcmko6NoOhs4lLGqR7TiSKPxzySaPUpzAERXy+22ef1l8OFK0/3UEYGggcRehO E0GDqXmEwpqBocf/8ihFCUoiA62p2Tp90+5IJhkIe4hBNWne+pXHJ0izdMAIIb8i0z OLoVaSAU5ObfDlMaLWu+Zg/BwHqwa9SXQVv2JJTIARsfe5hKzFDxWRceft2BaXmE0K kuDSLTFwAhlig== Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-50eaa746598so1188809e87.1 for ; Mon, 08 Jan 2024 04:10:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704715819; x=1705320619; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AZ1e4DQplobEkYb2oelZJP/g6uMuj6ixR2NKn4USgqo=; b=LIITaWso6AxY4rlRlpCzNdi+IQxFbFewqtgUeCIVTxVX5+YbzM4RqV65FLvunaAUOz tJvg1tD3H64O+jQOv8xvLUh0lcrGU/zjg7WDmoazExg9raOMGGA8kf/VHjQVKOHuWyH0 /0opqXKwD6n8Vg1gXD6RRqHtgXge6PjZ/YWNqxpQ8x2Hhn2MLWQekCbdBoz0SAsxsluv 1enpZCC+0dB+NYynb7Phh9ds7WqrUUxnZbhRayQ5e5aHQkduFh1BK7bFQ7kw7QF940Dj I5wYoFCQIGpp7vLmI1bVqJZNYCmIJwSZ9F1Beo/rQrI7sFJS90/ii5rzGHq91Lfsudj3 1uYg== X-Gm-Message-State: AOJu0Yzez3KkKir416wkbVLgJsfqQxFEAcg8ZRmpVcQv0F+O9hfarzxF h6/ERZJqu5/lKbIJRhHR7nsk6h7EKMGhAY8kixQC23QpZL8EWWA3pavDTKdyqM84RzdiUZ1bn2Z /dUkhZSLLTtlXxAqqAoKwtX7Qjpp4SH42bvmVhobn9N+P3iKjjw== X-Received: by 2002:ac2:44a8:0:b0:50e:7c6e:b411 with SMTP id c8-20020ac244a8000000b0050e7c6eb411mr1194728lfm.103.1704715819056; Mon, 08 Jan 2024 04:10:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IG7Nzn++Vuip8dKLKr2jYqNsa9FafczX9ul7wwW/1w2B0tbqsqXsHCty5yPcFNCQXD2vOYw2Q== X-Received: by 2002:ac2:44a8:0:b0:50e:7c6e:b411 with SMTP id c8-20020ac244a8000000b0050e7c6eb411mr1194719lfm.103.1704715818859; Mon, 08 Jan 2024 04:10:18 -0800 (PST) Received: from localhost.localdomain ([91.64.72.41]) by smtp.gmail.com with ESMTPSA id fi21-20020a056402551500b005578b816f20sm1767959edb.29.2024.01.08.04.10.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 04:10:17 -0800 (PST) From: Alexander Mikhalitsyn To: mszeredi@redhat.com Cc: brauner@kernel.org, stgraber@stgraber.org, linux-fsdevel@vger.kernel.org, Seth Forshee , Miklos Szeredi , Amir Goldstein , Bernd Schubert , Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v1 7/9] fs/fuse: drop idmap argument from __fuse_get_acl Date: Mon, 8 Jan 2024 13:08:22 +0100 Message-Id: <20240108120824.122178-8-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240108120824.122178-1-aleksandr.mikhalitsyn@canonical.com> References: <20240108120824.122178-1-aleksandr.mikhalitsyn@canonical.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We don't need to have idmap in the __fuse_get_acl as we don't have any use for it. In the current POSIX ACL implementation, idmapped mounts are taken into account on the userspace/kernel border (see vfs_set_acl_idmapped_mnt() and vfs_posix_acl_to_xattr()). Cc: Christian Brauner Cc: Seth Forshee Cc: Miklos Szeredi Cc: Amir Goldstein Cc: Bernd Schubert Cc: Signed-off-by: Alexander Mikhalitsyn Reviewed-by: Christian Brauner --- fs/fuse/acl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/fuse/acl.c b/fs/fuse/acl.c index 3d192b80a561..3a3cd88bd3d7 100644 --- a/fs/fuse/acl.c +++ b/fs/fuse/acl.c @@ -12,7 +12,6 @@ #include static struct posix_acl *__fuse_get_acl(struct fuse_conn *fc, - struct mnt_idmap *idmap, struct inode *inode, int type, bool rcu) { int size; @@ -74,7 +73,7 @@ struct posix_acl *fuse_get_acl(struct mnt_idmap *idmap, if (fuse_no_acl(fc, inode)) return ERR_PTR(-EOPNOTSUPP); - return __fuse_get_acl(fc, idmap, inode, type, false); + return __fuse_get_acl(fc, inode, type, false); } struct posix_acl *fuse_get_inode_acl(struct inode *inode, int type, bool rcu) @@ -90,8 +89,7 @@ struct posix_acl *fuse_get_inode_acl(struct inode *inode, int type, bool rcu) */ if (!fc->posix_acl) return NULL; - - return __fuse_get_acl(fc, &nop_mnt_idmap, inode, type, rcu); + return __fuse_get_acl(fc, inode, type, rcu); } int fuse_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, From patchwork Mon Jan 8 12:08:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13513357 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) (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 05E5B42059 for ; Mon, 8 Jan 2024 12:10:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="ew0XhTsk" Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 964A83F744 for ; Mon, 8 Jan 2024 12:10:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1704715821; bh=9iWRZnNscxr8QayhU5Rg4d2f++I0rJo2nyXgNTtGjkw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ew0XhTskysynAuIDEjjZcAgeykIuYk5jbgpsfXs4zYxexdPva80npFNM9S8ENrrJI gA5lbbz/JQHvxDppemMhkYLic7sT9S1Mv6ZaDvsP2u3r+rP/DT1vnasr8WoACHvNR9 rlHekq8r1RwPWBiVrZ+vhZNTuHQG54P5zrJWTR+LKC8DwmbzHhu9d7ujG/nvWnL7cL 6diUp/SBEbF4heJnC7jCGqxo+hjvRBhH37I2mk6J3hjXKCalF7M1VrdEaYG8JcID6u hUz04nuug5NF/fDzWd0dnHWh2Tl0zkHM3hG9eqVLzyk+au9zjTh+E9TCabYqgLsXZV vbsZAJ8u/TbLw== Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5551f8ec1c8so1104869a12.1 for ; Mon, 08 Jan 2024 04:10:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704715821; x=1705320621; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9iWRZnNscxr8QayhU5Rg4d2f++I0rJo2nyXgNTtGjkw=; b=efXF19wFXGxMfqIeo8C01IjsKcD8T30Ug4gGK/dnEww52DayQaqY8HQzKuRLwOD8oX XwTV05mhACskaqGdmxKDFyakJWFZp36PHsfTYImlmi+W8pv0NVFrjcrjmQhg1rUtUGJ/ dIjuZMvXeRLOmuM6A0QA1RyCpaAcPmpMqNdPHVWYc7C42rqGUrXOmu8LMpyqrmiYbONZ HFUr3EhEJWag/aNNGmN+X6/IbfR+ljaePqh59ySeC48AeCYe9I0b9VMHvrhcObSW/411 tRscxiQveWcg/pKcQgOzWXyrWRJLosVWb1EBKIGHKlEPgF5Es2ShB+FwVyEj9GWJKp23 Xcdw== X-Gm-Message-State: AOJu0Yxydw7PZjJA2M/GPpFuu0xYmbVKt0HjpkHjMEf4/Nt2rdNewM9q CYU156ps+bKfiWpxHzvzEnuySLdtQ7dfPaabFoLEYGNhzyuD4Nc2ZqiLnFCbznpym2wE10LXLkP DQRbWRp1R2FcJDGXLGSaEWCGzPhV0DRWWDNbdbEbo2x8GP0o+uQ== X-Received: by 2002:a50:f688:0:b0:557:8d37:2e8d with SMTP id d8-20020a50f688000000b005578d372e8dmr1279931edn.15.1704715821271; Mon, 08 Jan 2024 04:10:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IEkOLg4PdqdFQ702pfHBj3dKeidAQf6BOtGBbpwTprd9QoY0lj1ZgOD0aGwJAUpLDd3U2Afjw== X-Received: by 2002:a50:f688:0:b0:557:8d37:2e8d with SMTP id d8-20020a50f688000000b005578d372e8dmr1279918edn.15.1704715821105; Mon, 08 Jan 2024 04:10:21 -0800 (PST) Received: from localhost.localdomain ([91.64.72.41]) by smtp.gmail.com with ESMTPSA id fi21-20020a056402551500b005578b816f20sm1767959edb.29.2024.01.08.04.10.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 04:10:20 -0800 (PST) From: Alexander Mikhalitsyn To: mszeredi@redhat.com Cc: brauner@kernel.org, stgraber@stgraber.org, linux-fsdevel@vger.kernel.org, Seth Forshee , Miklos Szeredi , Amir Goldstein , Bernd Schubert , Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v1 8/9] fs/fuse: support idmapped ->set_acl Date: Mon, 8 Jan 2024 13:08:23 +0100 Message-Id: <20240108120824.122178-9-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240108120824.122178-1-aleksandr.mikhalitsyn@canonical.com> References: <20240108120824.122178-1-aleksandr.mikhalitsyn@canonical.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 It's just a matter of adjusting a permission check condition for S_ISGID flag. All the rest is already handled in the generic VFS code. Notice that this permission check is the analog of what we have in posix_acl_update_mode() generic helper, but fuse doesn't use this helper as on the kernel side we don't care about ensuring that POSIX ACL and CHMOD permissions are in sync as it is a responsibility of a userspace daemon to handle that. For the same reason we don't have a calls to posix_acl_chmod(), while most of other filesystem do. Cc: Christian Brauner Cc: Seth Forshee Cc: Miklos Szeredi Cc: Amir Goldstein Cc: Bernd Schubert Cc: Signed-off-by: Alexander Mikhalitsyn --- fs/fuse/acl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/fuse/acl.c b/fs/fuse/acl.c index 3a3cd88bd3d7..727fe50e255e 100644 --- a/fs/fuse/acl.c +++ b/fs/fuse/acl.c @@ -144,8 +144,8 @@ int fuse_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, * be stripped. */ if (fc->posix_acl && - !vfsgid_in_group_p(i_gid_into_vfsgid(&nop_mnt_idmap, inode)) && - !capable_wrt_inode_uidgid(&nop_mnt_idmap, inode, CAP_FSETID)) + !vfsgid_in_group_p(i_gid_into_vfsgid(idmap, inode)) && + !capable_wrt_inode_uidgid(idmap, inode, CAP_FSETID)) extra_flags |= FUSE_SETXATTR_ACL_KILL_SGID; ret = fuse_setxattr(inode, name, value, size, 0, extra_flags); From patchwork Mon Jan 8 12:08:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13513358 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) (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 702FA44373 for ; Mon, 8 Jan 2024 12:10:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="ME1wlTxe" Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id BFE6B3F373 for ; Mon, 8 Jan 2024 12:10:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1704715824; bh=5YU1NX55EkC+kEj5EffEs5H2AwvURtGdQ/HYjkwRM8I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ME1wlTxeCrq7VypFX8QeCIX9CrWDmtHj3rCV7u52LprNG24j5mRPU1v0quLW8Yp6X GIa1SUT3GdEZLo47aA2gHLg/zC/3vUqjWtZQyi5V45qQ7AOayOlIRSbKZ/OytvW34h GK+ScFaONHEUNA5TgQZBZaB/zexMemv8THw/icOkRqS4rJvrZmKPV/fs2+LvFHSw6Y Z3CK69KZQtloqdiNrmipkdd4j03+B9GBFNPeLqTcr5Bdk5CN/HUT0JGJfjwebT1alb ZcLDCuaEvnUCzM/FyLVl9R6IQTtjmGtlpI7GOnVcugOkvVvRP981hYQWMR/DjqPhtt 6mZadzbd03egw== Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-557d1641101so248857a12.2 for ; Mon, 08 Jan 2024 04:10:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704715824; x=1705320624; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5YU1NX55EkC+kEj5EffEs5H2AwvURtGdQ/HYjkwRM8I=; b=dJbWJzJAYBNaRdx5SIIK7qu+6Bp7WmAom47lU/PJQjlgJxwTVgdXaaw415wuoW8/Eh zHdcl14R/T9xULDQamZWfG1pO8zvF8Anj3Sjut+A8FE1pkIURrZMyrWPdHZVBPU0hOMH 66jQu0rsJTIk+nkeM3T+LMn+EZx5fYryQhddli3mKqj8+68bj5I8xB0J1nc6pzB68zS2 WBEgZgXHoTxotcDxuDCykBRC7YLJsAQb1aEGJKWfxtbX09EtHpZtKDeIj9lv8z67yk0W rne55iHAJKZ7EUgo6Mey6SgkoN/0d46B385dEMwwjsj7XcuwM5cj3Fyb0DBfzHUyIvMQ F4jA== X-Gm-Message-State: AOJu0Yyj8Gxwm6qvFZ1lzFtLQ//xBlp0/Caf65LRI6fVxgu5yfyow8eq M0X/WLN5jFemMXDqLJcDImz0BwyZ+ylH866z+CuuB1u8SaC8nCG3JPsqkxU9nEPfEt6DivB7A5Q kNDy8aL1aK/IfoIau1mo6byRxysRLP8+5uUOkc2Pm9rW7SqUUng== X-Received: by 2002:a50:951e:0:b0:552:fcca:ee11 with SMTP id u30-20020a50951e000000b00552fccaee11mr1322933eda.74.1704715824430; Mon, 08 Jan 2024 04:10:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IGbkDQ81TrJrfcIXQl9SZ1Mnhsn8K0v5xkp/foSnlY+Kqttn18YIQ5m+/IG2qQHswCxHJux4g== X-Received: by 2002:a50:951e:0:b0:552:fcca:ee11 with SMTP id u30-20020a50951e000000b00552fccaee11mr1322918eda.74.1704715823978; Mon, 08 Jan 2024 04:10:23 -0800 (PST) Received: from localhost.localdomain ([91.64.72.41]) by smtp.gmail.com with ESMTPSA id fi21-20020a056402551500b005578b816f20sm1767959edb.29.2024.01.08.04.10.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 04:10:22 -0800 (PST) From: Alexander Mikhalitsyn To: mszeredi@redhat.com Cc: brauner@kernel.org, stgraber@stgraber.org, linux-fsdevel@vger.kernel.org, Seth Forshee , Miklos Szeredi , Amir Goldstein , Bernd Schubert , Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v1 9/9] fs/fuse: allow idmapped mounts Date: Mon, 8 Jan 2024 13:08:24 +0100 Message-Id: <20240108120824.122178-10-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240108120824.122178-1-aleksandr.mikhalitsyn@canonical.com> References: <20240108120824.122178-1-aleksandr.mikhalitsyn@canonical.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now we have everything in place and we can allow idmapped mounts by setting the FS_ALLOW_IDMAP flag. Notice that real availability of idmapped mounts will depend on the fuse daemon. Fuse daemon have to set FUSE_ALLOW_IDMAP flag in the FUSE_INIT reply. To discuss: - we enable idmapped mounts support only if "default_permissions" mode is enabled, because otherwise we would need to deal with UID/GID mappings in the userspace side OR provide the userspace with idmapped req->in.h.uid/req->in.h.gid values which is not something that we probably want to. Idmapped mounts phylosophy is not about faking caller uid/gid. - We have a small offlist discussion with Christian around adding fs_type->allow_idmap hook. Christian pointed that it would be nice to have a superblock flag instead like SB_I_NOIDMAP and we can set this flag during mount time if we see that filesystem does not support idmappings. But, unfortunately I didn't succeed here because the kernel will know if the filesystem supports idmapping or not after FUSE_INIT request, but FUSE_INIT request is being sent at the end of mounting process, so mount and superblock will exist and visible by the userspace in that time. It seems like setting SB_I_NOIDMAP flag in this case is too late as user may do the trick with creating a idmapped mount while it wasn't restricted by SB_I_NOIDMAP. Alternatively, we can introduce a "positive" version SB_I_ALLOWIDMAP and "weak" version of FS_ALLOW_IDMAP like FS_MAY_ALLOW_IDMAP. So if FS_MAY_ALLOW_IDMAP is set, then SB_I_ALLOWIDMAP has to be set on the superblock to allow creation of an idmapped mount. But that's a matter of our discussion. Some extra links and examples: - libfuse support https://github.com/mihalicyn/libfuse/commits/idmap_support - fuse-overlayfs support: https://github.com/mihalicyn/fuse-overlayfs/commits/idmap_support - cephfs-fuse conversion example https://github.com/mihalicyn/ceph/commits/fuse_idmap - glusterfs conversion example https://github.com/mihalicyn/glusterfs/commits/fuse_idmap Cc: Christian Brauner Cc: Seth Forshee Cc: Miklos Szeredi Cc: Amir Goldstein Cc: Bernd Schubert Cc: Signed-off-by: Alexander Mikhalitsyn --- fs/fuse/fuse_i.h | 3 +++ fs/fuse/inode.c | 22 +++++++++++++++++++--- include/uapi/linux/fuse.h | 5 ++++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 94b25ea5344a..9317b8c35191 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -809,6 +809,9 @@ struct fuse_conn { /* Add owner_{u,g}id info when creating a new inode */ unsigned int owner_uid_gid_ext:1; + /* Allow creation of idmapped mounts */ + unsigned int allow_idmap:1; + /* Does the filesystem support per inode DAX? */ unsigned int inode_dax:1; diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 08cd3714b32d..47e32a8baed3 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -1286,6 +1286,12 @@ static void process_init_reply(struct fuse_mount *fm, struct fuse_args *args, fc->direct_io_allow_mmap = 1; if (flags & FUSE_OWNER_UID_GID_EXT) fc->owner_uid_gid_ext = 1; + if (flags & FUSE_ALLOW_IDMAP) { + if (fc->owner_uid_gid_ext && fc->default_permissions) + fc->allow_idmap = 1; + else + ok = false; + } } else { ra_pages = fc->max_read / PAGE_SIZE; fc->no_lock = 1; @@ -1332,7 +1338,8 @@ void fuse_send_init(struct fuse_mount *fm) FUSE_NO_OPENDIR_SUPPORT | FUSE_EXPLICIT_INVAL_DATA | FUSE_HANDLE_KILLPRIV_V2 | FUSE_SETXATTR_EXT | FUSE_INIT_EXT | FUSE_SECURITY_CTX | FUSE_CREATE_SUPP_GROUP | - FUSE_HAS_EXPIRE_ONLY | FUSE_DIRECT_IO_ALLOW_MMAP | FUSE_OWNER_UID_GID_EXT; + FUSE_HAS_EXPIRE_ONLY | FUSE_DIRECT_IO_ALLOW_MMAP | + FUSE_OWNER_UID_GID_EXT | FUSE_ALLOW_IDMAP; #ifdef CONFIG_FUSE_DAX if (fm->fc->dax) flags |= FUSE_MAP_ALIGNMENT; @@ -1915,12 +1922,20 @@ static void fuse_kill_sb_anon(struct super_block *sb) fuse_mount_destroy(get_fuse_mount_super(sb)); } +static bool fuse_allow_idmap(struct super_block *sb) +{ + struct fuse_conn *fc = get_fuse_conn_super(sb); + + return fc->allow_idmap; +} + static struct file_system_type fuse_fs_type = { .owner = THIS_MODULE, .name = "fuse", - .fs_flags = FS_HAS_SUBTYPE | FS_USERNS_MOUNT, + .fs_flags = FS_HAS_SUBTYPE | FS_USERNS_MOUNT | FS_ALLOW_IDMAP, .init_fs_context = fuse_init_fs_context, .parameters = fuse_fs_parameters, + .allow_idmap = fuse_allow_idmap, .kill_sb = fuse_kill_sb_anon, }; MODULE_ALIAS_FS("fuse"); @@ -1938,8 +1953,9 @@ static struct file_system_type fuseblk_fs_type = { .name = "fuseblk", .init_fs_context = fuse_init_fs_context, .parameters = fuse_fs_parameters, + .allow_idmap = fuse_allow_idmap, .kill_sb = fuse_kill_sb_blk, - .fs_flags = FS_REQUIRES_DEV | FS_HAS_SUBTYPE, + .fs_flags = FS_REQUIRES_DEV | FS_HAS_SUBTYPE | FS_ALLOW_IDMAP, }; MODULE_ALIAS_FS("fuseblk"); diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index ebe82104b172..d8e1235d9796 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -215,6 +215,7 @@ * 7.40 * - add FUSE_EXT_OWNER_UID_GID * - add FUSE_OWNER_UID_GID_EXT + * - add FUSE_ALLOW_IDMAP */ #ifndef _LINUX_FUSE_H @@ -250,7 +251,7 @@ #define FUSE_KERNEL_VERSION 7 /** Minor version number of this interface */ -#define FUSE_KERNEL_MINOR_VERSION 39 +#define FUSE_KERNEL_MINOR_VERSION 40 /** The node ID of the root inode */ #define FUSE_ROOT_ID 1 @@ -416,6 +417,7 @@ struct fuse_file_lock { * FUSE_DIRECT_IO_ALLOW_MMAP: allow shared mmap in FOPEN_DIRECT_IO mode. * FUSE_OWNER_UID_GID_EXT: add inode owner UID/GID info to create, mkdir, * symlink and mknod + * FUSE_ALLOW_IDMAP: allow creation of idmapped mounts */ #define FUSE_ASYNC_READ (1 << 0) #define FUSE_POSIX_LOCKS (1 << 1) @@ -459,6 +461,7 @@ struct fuse_file_lock { /* Obsolete alias for FUSE_DIRECT_IO_ALLOW_MMAP */ #define FUSE_DIRECT_IO_RELAX FUSE_DIRECT_IO_ALLOW_MMAP #define FUSE_OWNER_UID_GID_EXT (1ULL << 37) +#define FUSE_ALLOW_IDMAP (1ULL << 38) /** * CUSE INIT request/reply flags