From patchwork Tue Sep 3 15:16:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13788881 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 1BBAD188A3B for ; Tue, 3 Sep 2024 15:16:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376616; cv=none; b=Y587Q/DUB0tvaNKpd4X/TOxyYcASB2dxuJkxXL2E/KIyx/JCVZLgfUYESIjq5PLta3Scr7TXgAhlGZMWkOGNFKd3qrFmsmD8wTuATTg0GVZkkxqZEy5Yxc5h2s4SrS/3iJfObOOZ4ZnhthKxtEOZ+bfn2dUStqfkoII7Nq3J6yo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376616; c=relaxed/simple; bh=+65lnekXMhI1t21zuHkzMVhnAJ/aGY9ksednbDEEX24=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Szhfepfbs33ahKHgi7uTfhUmdoBZbO9gtIL+HgcePIwSddvqVEmgtweTzCbeieI0Bo5z6wM+/srnINhmQrhWyTpVgYxnqq9xJ2ypc7Bm/fesMUGnmBVaZhn0UHpXQRMbRdvH4nJib4n9oUP2mIzrIJyLTmZDzHEyPhmZ8046dIA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=FC+OgzKo; arc=none smtp.client-ip=185.125.188.123 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="FC+OgzKo" Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.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 B90BF3FE1C for ; Tue, 3 Sep 2024 15:16:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1725376607; bh=j3VPDcvR6dDhs8ZQ9mZ4n82aTjnb//+beKKdu3S1mOA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FC+OgzKoplrRZ3LZvzUa47yyNi4xzPI33BUErX699JruaOKmXF5QsuVZzA+6an2zT +a8H2yxwSA3k7+cbkqjx7xJ7JQJUGjvLojwUm/J/DEeWdPhUQ1IDO5762hLwpEfmRe 3usFe+hYf2NoIe0QOACAIQBj5CjaBM9uc53mPL9o07SQrEfwbqDa/IglYTdQRFW3qO dVjC0PFcVToaJb+mZPBkHJ5H8chMY/39ZeomXnKqc1k97d+y8PnglierdKUE32C/Mf kEmmeXi7566nbWsXTMTeSYeGItVsPu2Zt6y5/k+DJ7Eu4ok0bNVraBz9TwhVOFMMEs dQYEwieDLomhQ== Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a8696019319so395843766b.1 for ; Tue, 03 Sep 2024 08:16:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725376607; x=1725981407; 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=j3VPDcvR6dDhs8ZQ9mZ4n82aTjnb//+beKKdu3S1mOA=; b=YIDiDpFHxhn4hV/ppwenVXMEmir41XAPX3/HdgU8qv4gVpAsnGkWUS+3SyDUX+Lkvb tvBWDH+PIE1A4fyilwEJkNaMjdRmShicTFeHbjaeBK2mPqV/dRf+PBCr5SLACa7g7mNt oQtYaxlI8X1hYpCZcX7j8EmlH3JyuSDNxE6WweFPaCc6c/3fmXgG/xbhmycN+TuYhwsO TudTJB9ytowvib1zQ8GRK/Q0J9WbEgSLzf8U/wsQTWGVtoXTt4HM8VR+0NdgcupAw//0 uQavBniNJb570+dG1p+GBJCjDwA2G6Jx4OklNVpdmg8qCeAepzm3TxpmqV1D8HcRth/v xJLA== X-Forwarded-Encrypted: i=1; AJvYcCXIZEMeEbAidSwtNVv/sAtG5e1bQCMjzjQKkDX2+w8Y7wfcQ95tvqejuwfQDgJOeQnYlI+nOUNpf/EItzjd@vger.kernel.org X-Gm-Message-State: AOJu0YyWK7dol+CN91MOSiVnLSaoa7GfZaUD3HYJ+TMyvXacb3VBMyPn /T1TVgkSPl2czD09HLgmlzWLI+3OeeRwMs7vlsMxwAJEAPSLU/aSX1E5pky0Ctbr5RrC0arwpZZ wOM2V/8qsxzCwwdGsCTRMlIT2d22vwzcnbJW6mqP4ZV3stkJlvszUO3g7sjIcWIZrhajHUDt5LG sXaGI= X-Received: by 2002:a17:907:7f29:b0:a7a:b4bd:d0eb with SMTP id a640c23a62f3a-a89b94cef55mr877281766b.24.1725376606805; Tue, 03 Sep 2024 08:16:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGeYN6hRfAhuD0+4Q5mLVtZ2Al7kWcPr9w+dVvPFIc/c9/ume9/DhCoB3QIXHG+d0EhOrXsgQ== X-Received: by 2002:a17:907:7f29:b0:a7a:b4bd:d0eb with SMTP id a640c23a62f3a-a89b94cef55mr877278866b.24.1725376606295; Tue, 03 Sep 2024 08:16:46 -0700 (PDT) Received: from amikhalitsyn.. ([188.192.113.77]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a19afb108sm156377166b.223.2024.09.03.08.16.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 08:16:45 -0700 (PDT) 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 , Jan Kara , linux-kernel@vger.kernel.org Subject: [PATCH v4 01/15] fs/namespace: introduce SB_I_NOIDMAP flag Date: Tue, 3 Sep 2024 17:16:12 +0200 Message-Id: <20240903151626.264609-2-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240903151626.264609-1-aleksandr.mikhalitsyn@canonical.com> References: <20240903151626.264609-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/virtiofs 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: Suggested-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn Reviewed-by: Christian Brauner --- v3: - this commit added --- fs/namespace.c | 4 ++++ include/linux/fs.h | 1 + 2 files changed, 5 insertions(+) diff --git a/fs/namespace.c b/fs/namespace.c index 328087a4df8a..d1702285c915 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -4436,6 +4436,10 @@ static int can_idmap_mount(const struct mount_kattr *kattr, struct mount *mnt) if (!(m->mnt_sb->s_type->fs_flags & FS_ALLOW_IDMAP)) return -EINVAL; + /* The filesystem has turned off idmapped mounts. */ + if (m->mnt_sb->s_iflags & SB_I_NOIDMAP) + return -EINVAL; + /* We're not controlling the superblock. */ if (!ns_capable(fs_userns, CAP_SYS_ADMIN)) return -EPERM; diff --git a/include/linux/fs.h b/include/linux/fs.h index 6ca11e241a24..8756f84d627c 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1190,6 +1190,7 @@ extern int send_sigurg(struct fown_struct *fown); #define SB_I_TS_EXPIRY_WARNED 0x00000400 /* warned about timestamp range expiry */ #define SB_I_RETIRED 0x00000800 /* superblock shouldn't be reused */ #define SB_I_NOUMASK 0x00001000 /* VFS does not apply umask */ +#define SB_I_NOIDMAP 0x00002000 /* No idmapped mounts on this superblock */ /* Possible states of 'frozen' field */ enum { From patchwork Tue Sep 3 15:16:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13788880 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 030EC18859F for ; Tue, 3 Sep 2024 15:16:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376616; cv=none; b=tO71JC5SllTwXyc/iAJjp9CmHEmkaAsKicjCtiIA23IcasaUnfm6ox1IKcYl35t9rB1l96avaT+1/f5b2CNarU0Ua8eBbk0vjd3TK4I9z2LI9LcnbLyP1m12rFQmfiT9y1beMDoHfNcDbT5RF3gFd/40jE9hQLjBUsadNW0KdzU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376616; c=relaxed/simple; bh=zbfFmYg52x4bNkZY0iHbZPvACTmlOnxysSOisb9uilw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YNi4dqJGEH6+NZSQqPXjPh9K3xXrjJ3AWvMUuxPUCVApjtWUlBYCVURtDa5srUGkvC4lyk57UJs9u++Y5U51sTzkzuGy5Bp5cLk4v2HMJ8aO3dgX63B8HnrA5xZCwVjAO7tsmyu39Hymdesv2hCUig5heM75zyzrD5QMLyFvlMU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=RZqzDMl3; arc=none smtp.client-ip=185.125.188.123 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="RZqzDMl3" Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.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 59BFD400E1 for ; Tue, 3 Sep 2024 15:16:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1725376610; bh=x8jszuSuXnXNJxcLdhQ06xMDLcRlHy+xx7dW4v2SH2g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RZqzDMl3/InQyDIqo1HyLcZ3Uu7HdFMNtvGFIdzn50g4rKw3D2ENO4mKGniH03Cm4 tIg49bJIe/l6l7KpNuCdKdCfrX+s6q6YE78zo3YXfmIyIh/Q3Ej2s8um1hx603u4VJ LQkLfxsJYj/E2ZGpLoBFRZUJ3eIouGUC1hDkBRniBjefEooqVPBEQZA7KNw6OSxSWL R/72Qg18Wto78Ud50V63ytPbXOhe3ciVa5Omi/QbyjYzczjPhT4Stj77nAbu8l5TV2 zzFtN/1wxKOeJ2Q8AUMp9r5unpspJ2W5pgATKDX3YuYOK/Ofop4Bb4UI92YdLLlOQa yx3DOqX0jlXbg== Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a7d2d414949so456737466b.0 for ; Tue, 03 Sep 2024 08:16:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725376610; x=1725981410; 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=x8jszuSuXnXNJxcLdhQ06xMDLcRlHy+xx7dW4v2SH2g=; b=p5Tnb1Ai/KYwT9pM9QI6fNK2q73RujHSyRHLZ+2bjXoOel/+qOkVgbKDfHm0uFxW3e zFqRLtiL71cBzyrfpQq6FoWS15QmygiftlizC4TObNL/m2/jUzZS0d95FxBWlromUpqO 5Hs7WSjOliv1HcFXY77hEILgr4982zinIPiWm6vv5MDH1ktjKErSjsXgW7RSvH/ZVXRs Lj7Fp9TW3I1OyHMz3cz6B5MuryR8bXuxH026ywYX3+t3TI2Eev772hUuP1hYifXNjiZ6 3+iQLUynFd4LQb/s6fcJgHL5XtQGGxhr0AgBG4WDMV44aqP4QIjd5XtLQ1PC24oP2jMl 0o1w== X-Forwarded-Encrypted: i=1; AJvYcCUZVpVZPmM47PdpvYJPky02+NMzExJnz5KYUFdUquIERuIzDMB1RlOnmwmdDqW2X1uqCscZCi/gcKx58mj1@vger.kernel.org X-Gm-Message-State: AOJu0Yyb50o86cC9Ttjnt8vvIvxoWNiWXioQruBy08adU6uN8BTC/Pz3 TxtV2KmTGKkcltYJ1dC0Jl5R/lqBGowCgiRU7KImkYAOtZBYEFZNbl1A/m61MZqDEEKZifkyD7C VzpGRHPWKse+SxDsXns/X0O4YDWCragFJ0cQEGBkBMR3x1MwJHYqasUArNyUlqM7ap0GlcAd6+L CNGW8= X-Received: by 2002:a17:907:968d:b0:a86:b6ee:8747 with SMTP id a640c23a62f3a-a8a32f9f1f8mr90220866b.43.1725376609539; Tue, 03 Sep 2024 08:16:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGs9nFNqPMbcV/jWpg4+uWW1GqZ9gh0BQOAKr9B+8QKp53t56++gbos2lE0uI6EBfpBGrbq0Q== X-Received: by 2002:a17:907:968d:b0:a86:b6ee:8747 with SMTP id a640c23a62f3a-a8a32f9f1f8mr90218266b.43.1725376609062; Tue, 03 Sep 2024 08:16:49 -0700 (PDT) Received: from amikhalitsyn.. ([188.192.113.77]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a19afb108sm156377166b.223.2024.09.03.08.16.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 08:16:48 -0700 (PDT) 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 v4 02/15] fs/fuse: add basic infrastructure to support idmappings Date: Tue, 3 Sep 2024 17:16:13 +0200 Message-Id: <20240903151626.264609-3-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240903151626.264609-1-aleksandr.mikhalitsyn@canonical.com> References: <20240903151626.264609-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 Add some preparational changes in fuse_get_req/fuse_force_creds to handle idmappings. Miklos suggested [1], [2] to change the meaning of in.h.uid/in.h.gid fields when daemon declares support for idmapped mounts. In a new semantic, we fill uid/gid values in fuse header with a id-mapped caller uid/gid (for requests which create new inodes), for all the rest cases we just send -1 to userspace. No functional changes intended. Link: https://lore.kernel.org/all/CAJfpegsVY97_5mHSc06mSw79FehFWtoXT=hhTUK_E-Yhr7OAuQ@mail.gmail.com/ [1] Link: https://lore.kernel.org/all/CAJfpegtHQsEUuFq1k4ZbTD3E1h-GsrN3PWyv7X8cg6sfU_W2Yw@mail.gmail.com/ [2] Cc: Christian Brauner Cc: Seth Forshee Cc: Miklos Szeredi Cc: Amir Goldstein Cc: Bernd Schubert Cc: Signed-off-by: Alexander Mikhalitsyn --- v4: - this commit added --- fs/fuse/dev.c | 50 +++++++++++++++++++++++++++++---------- fs/fuse/inode.c | 1 + include/uapi/linux/fuse.h | 2 ++ 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 7146038b2fe7..d3f3c3557c04 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -103,7 +103,9 @@ static void fuse_drop_waiting(struct fuse_conn *fc) static void fuse_put_request(struct fuse_req *req); -static struct fuse_req *fuse_get_req(struct fuse_mount *fm, bool for_background) +static struct fuse_req *fuse_get_req(struct mnt_idmap *idmap, + struct fuse_mount *fm, + bool for_background) { struct fuse_conn *fc = fm->fc; struct fuse_req *req; @@ -135,19 +137,37 @@ static struct fuse_req *fuse_get_req(struct fuse_mount *fm, bool for_background) goto out; } - req->in.h.uid = from_kuid(fc->user_ns, current_fsuid()); - req->in.h.gid = from_kgid(fc->user_ns, current_fsgid()); req->in.h.pid = pid_nr_ns(task_pid(current), fc->pid_ns); __set_bit(FR_WAITING, &req->flags); if (for_background) __set_bit(FR_BACKGROUND, &req->flags); - if (unlikely(req->in.h.uid == ((uid_t)-1) || - req->in.h.gid == ((gid_t)-1))) { - fuse_put_request(req); - return ERR_PTR(-EOVERFLOW); + if ((fm->sb->s_iflags & SB_I_NOIDMAP) || idmap) { + kuid_t idmapped_fsuid; + kgid_t idmapped_fsgid; + + /* + * Note, that when + * (fm->sb->s_iflags & SB_I_NOIDMAP) is true, then + * (idmap == &nop_mnt_idmap) is always true and therefore, + * mapped_fsuid(idmap, fc->user_ns) == current_fsuid(). + */ + idmapped_fsuid = idmap ? mapped_fsuid(idmap, fc->user_ns) : current_fsuid(); + idmapped_fsgid = idmap ? mapped_fsgid(idmap, fc->user_ns) : current_fsgid(); + req->in.h.uid = from_kuid(fc->user_ns, idmapped_fsuid); + req->in.h.gid = from_kgid(fc->user_ns, idmapped_fsgid); + + if (unlikely(req->in.h.uid == ((uid_t)-1) || + req->in.h.gid == ((gid_t)-1))) { + fuse_put_request(req); + return ERR_PTR(-EOVERFLOW); + } + } else { + req->in.h.uid = FUSE_INVALID_UIDGID; + req->in.h.gid = FUSE_INVALID_UIDGID; } + return req; out: @@ -466,8 +486,14 @@ static void fuse_force_creds(struct fuse_req *req) { struct fuse_conn *fc = req->fm->fc; - req->in.h.uid = from_kuid_munged(fc->user_ns, current_fsuid()); - req->in.h.gid = from_kgid_munged(fc->user_ns, current_fsgid()); + if (req->fm->sb->s_iflags & SB_I_NOIDMAP) { + req->in.h.uid = from_kuid_munged(fc->user_ns, current_fsuid()); + req->in.h.gid = from_kgid_munged(fc->user_ns, current_fsgid()); + } else { + req->in.h.uid = FUSE_INVALID_UIDGID; + req->in.h.gid = FUSE_INVALID_UIDGID; + } + req->in.h.pid = pid_nr_ns(task_pid(current), fc->pid_ns); } @@ -499,7 +525,7 @@ ssize_t fuse_simple_request(struct fuse_mount *fm, struct fuse_args *args) __set_bit(FR_FORCE, &req->flags); } else { WARN_ON(args->nocreds); - req = fuse_get_req(fm, false); + req = fuse_get_req(NULL, fm, false); if (IS_ERR(req)) return PTR_ERR(req); } @@ -560,7 +586,7 @@ int fuse_simple_background(struct fuse_mount *fm, struct fuse_args *args, __set_bit(FR_BACKGROUND, &req->flags); } else { WARN_ON(args->nocreds); - req = fuse_get_req(fm, true); + req = fuse_get_req(NULL, fm, true); if (IS_ERR(req)) return PTR_ERR(req); } @@ -583,7 +609,7 @@ static int fuse_simple_notify_reply(struct fuse_mount *fm, struct fuse_iqueue *fiq = &fm->fc->iq; int err = 0; - req = fuse_get_req(fm, false); + req = fuse_get_req(NULL, fm, false); if (IS_ERR(req)) return PTR_ERR(req); diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index d8ab4e93916f..115538f6f283 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -1567,6 +1567,7 @@ static void fuse_sb_defaults(struct super_block *sb) sb->s_time_gran = 1; sb->s_export_op = &fuse_export_operations; sb->s_iflags |= SB_I_IMA_UNVERIFIABLE_SIGNATURE; + sb->s_iflags |= SB_I_NOIDMAP; if (sb->s_user_ns != &init_user_ns) sb->s_iflags |= SB_I_UNTRUSTED_MOUNTER; sb->s_flags &= ~(SB_NOSEC | SB_I_VERSION); diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index d08b99d60f6f..2ccf38181df2 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -984,6 +984,8 @@ struct fuse_fallocate_in { */ #define FUSE_UNIQUE_RESEND (1ULL << 63) +#define FUSE_INVALID_UIDGID ((uint32_t)(-1)) + struct fuse_in_header { uint32_t len; uint32_t opcode; From patchwork Tue Sep 3 15:16:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13788882 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 E345E1885B6 for ; Tue, 3 Sep 2024 15:16:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.122 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376618; cv=none; b=sfzTy85Hv1840f3bbgJqTIzKEqLceSRqA5rXSLsM5ZHtVnpl7v2rnSY+F/44kr0SaIXCcW5eymavhxXmr8mtEWeSPQEKz3/zlijEg/IKH2HPuaDzfzFFGfGVKiGYHdo4Vee0JbeRa34XS8OzWeuKNjYhnqEqD/B5iNX2sUbgUMI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376618; c=relaxed/simple; bh=f/gJKyVl4ADm/yoP4N8bpvEgSEtHH1kP5oeqKqZ4Tds=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Dh0HSlQ/78gJ9qSAVt2YJlc13jmUw2TkCkYwsnXD7MjaOSDAr9BQ7hYJT63K9Jnv5ffMCD+PY0yzHhWYIc9jsToHHenVFWWNlBOwrArfagqIvVtHpDCd93ObGkTU5uSyY4wpRxylMBwpUMqwIDLfohC5Jfx3Kw5elGkBPllTXAw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=e4Gt2ohf; arc=none smtp.client-ip=185.125.188.122 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="e4Gt2ohf" 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 11B953FE1B for ; Tue, 3 Sep 2024 15:16:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1725376614; bh=UdafeJegpZAV0BY3M2qbl16uDJIFaN2Zpg+hXMszRa4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=e4Gt2ohfyKEL+chtBg45zJgoMfyP5AwCGwHYWnI1HBoXQHKj7tupOvOwZVSutttek xxKxPkpRfT0kXhlNe1G2Gxw87JDC5wuObx7H2igP3IKNqckhV8xqgD1N21cuTLm34L Pqkj7m57oWwHCmoJot5nKzppM+GH4BW4jCevaYbnVpj0ARllBkyAYyNKpyYGcPeVS8 X+A52dGZfPiZROqFyDlMn7p9KJ4LlJyuuklCc2zUpG9FPp7cF1Lyr9Fj+6Cs+tDkhS pnlbmKSAor8PZxI6FDGk29CaWh3VpCx0ciBw2P8PyTu5WA8/s8ZpgEztVomlSywT7u 8932cxFCs7uYQ== Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2f401c76ce1so60989891fa.0 for ; Tue, 03 Sep 2024 08:16:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725376613; x=1725981413; 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=UdafeJegpZAV0BY3M2qbl16uDJIFaN2Zpg+hXMszRa4=; b=pUugYjGfaAuHlrhTmclPW3y/NSD9NgpET54qoq4MiIA6ygQgA4M0zMJ89FknQq4ei5 CmhB++ut+xQUpLnYPEhBRq+evsgzP2WYKB/VX41OzSVDFYgp61T/21atc5UFTghnkqqh e61aykHQ/Skr8g2CoFKjMgejfNkUBWnVpPqHQO56zKFu3bzwZJtxWsRS7AR1iBvoePWI mvpOeDx8b9LZ6RkQ2dgjW4sVCWdEWtrL0eWguZE5EnPyRzp4rxRS+LVjg1Lqsj/lsowU yrXQWd0DL3sW8/EfllYk/f17+bmlaKRJ8tfRTAIzWzTaAJcA5LaMBp4okdsGRUeFTmVE PBMw== X-Forwarded-Encrypted: i=1; AJvYcCXkqox2H5D4pp2uRrnp075nxqDo3/FFt54Py0IjRr2RZt26QIrhkZ0jFgLFhqCB5RvTLW/tLGCjM1JcKjUA@vger.kernel.org X-Gm-Message-State: AOJu0Yx9T8wSu+uEIbasUgXWFkLd8LKMoDv5F5Y+hJ6CW26dDn+r1TT9 2cRiZZi67QqDIqjTeLTHubn/VJ00skOKnPl78m60aVP02Y8kyIFHXp3yWRzebBIafYBVkeq9OYi 2lcf2T+SYSIeoRrDicktmWCsEbsPyCxwuHBXHqjPq+6TacyMGua3/DY3GMLRwP24ooPB6Er5FQ9 KlmMs= X-Received: by 2002:a2e:612:0:b0:2ef:2677:7b74 with SMTP id 38308e7fff4ca-2f6108ae26dmr113933431fa.41.1725376613109; Tue, 03 Sep 2024 08:16:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHhC2jwLdKr/I93Lw0mhZQlHq3y/Gq9QIm9cGGG1aK6M+8ZSCFhfX7x8b8W1hP24WyaaimLhA== X-Received: by 2002:a2e:612:0:b0:2ef:2677:7b74 with SMTP id 38308e7fff4ca-2f6108ae26dmr113933141fa.41.1725376612477; Tue, 03 Sep 2024 08:16:52 -0700 (PDT) Received: from amikhalitsyn.. ([188.192.113.77]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a19afb108sm156377166b.223.2024.09.03.08.16.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 08:16:51 -0700 (PDT) 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 v4 03/15] fs/fuse: add an idmap argument to fuse_simple_request Date: Tue, 3 Sep 2024 17:16:14 +0200 Message-Id: <20240903151626.264609-4-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240903151626.264609-1-aleksandr.mikhalitsyn@canonical.com> References: <20240903151626.264609-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 If idmap == NULL *and* filesystem daemon declared idmapped mounts support, then uid/gid values in a fuse header will be -1. No functional changes intended. Cc: Christian Brauner Cc: Seth Forshee Cc: Miklos Szeredi Cc: Amir Goldstein Cc: Bernd Schubert Cc: Signed-off-by: Alexander Mikhalitsyn --- v4: - this commit added --- fs/fuse/dax.c | 4 ++-- fs/fuse/dev.c | 6 ++++-- fs/fuse/dir.c | 26 +++++++++++++------------- fs/fuse/file.c | 32 ++++++++++++++++---------------- fs/fuse/fuse_i.h | 3 ++- fs/fuse/inode.c | 6 +++--- fs/fuse/ioctl.c | 2 +- fs/fuse/readdir.c | 4 ++-- fs/fuse/xattr.c | 8 ++++---- 9 files changed, 47 insertions(+), 44 deletions(-) diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c index 12ef91d170bb..6d8368d66dd4 100644 --- a/fs/fuse/dax.c +++ b/fs/fuse/dax.c @@ -207,7 +207,7 @@ static int fuse_setup_one_mapping(struct inode *inode, unsigned long start_idx, args.in_numargs = 1; args.in_args[0].size = sizeof(inarg); args.in_args[0].value = &inarg; - err = fuse_simple_request(fm, &args); + err = fuse_simple_request(NULL, fm, &args); if (err < 0) return err; dmap->writable = writable; @@ -245,7 +245,7 @@ static int fuse_send_removemapping(struct inode *inode, args.in_args[0].value = inargp; args.in_args[1].size = inargp->count * sizeof(*remove_one); args.in_args[1].value = remove_one; - return fuse_simple_request(fm, &args); + return fuse_simple_request(NULL, fm, &args); } static int dmap_removemapping_list(struct inode *inode, unsigned int num, diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index d3f3c3557c04..349fc84897a5 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -508,7 +508,9 @@ static void fuse_args_to_req(struct fuse_req *req, struct fuse_args *args) __set_bit(FR_ASYNC, &req->flags); } -ssize_t fuse_simple_request(struct fuse_mount *fm, struct fuse_args *args) +ssize_t fuse_simple_request(struct mnt_idmap *idmap, + struct fuse_mount *fm, + struct fuse_args *args) { struct fuse_conn *fc = fm->fc; struct fuse_req *req; @@ -525,7 +527,7 @@ ssize_t fuse_simple_request(struct fuse_mount *fm, struct fuse_args *args) __set_bit(FR_FORCE, &req->flags); } else { WARN_ON(args->nocreds); - req = fuse_get_req(NULL, fm, false); + req = fuse_get_req(idmap, fm, false); if (IS_ERR(req)) return PTR_ERR(req); } diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 2b0d4781f394..2a8344776350 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -230,7 +230,7 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) parent = dget_parent(entry); fuse_lookup_init(fm->fc, &args, get_node_id(d_inode(parent)), &entry->d_name, &outarg); - ret = fuse_simple_request(fm, &args); + ret = fuse_simple_request(NULL, fm, &args); dput(parent); /* Zero nodeid is same as -ENOENT */ if (!ret && !outarg.nodeid) @@ -383,7 +383,7 @@ int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name attr_version = fuse_get_attr_version(fm->fc); fuse_lookup_init(fm->fc, &args, nodeid, name, outarg); - err = fuse_simple_request(fm, &args); + err = fuse_simple_request(NULL, fm, &args); /* Zero nodeid is same as -ENOENT, but with valid timeout */ if (err || !outarg->nodeid) goto out_put_forget; @@ -672,7 +672,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, if (err) goto out_put_forget_req; - err = fuse_simple_request(fm, &args); + err = fuse_simple_request(NULL, fm, &args); free_ext_value(&args); if (err) goto out_free_ff; @@ -803,7 +803,7 @@ static int create_new_entry(struct fuse_mount *fm, struct fuse_args *args, goto out_put_forget_req; } - err = fuse_simple_request(fm, args); + err = fuse_simple_request(NULL, fm, args); free_ext_value(args); if (err) goto out_put_forget_req; @@ -987,7 +987,7 @@ static int fuse_unlink(struct inode *dir, struct dentry *entry) args.in_numargs = 1; args.in_args[0].size = entry->d_name.len + 1; args.in_args[0].value = entry->d_name.name; - err = fuse_simple_request(fm, &args); + err = fuse_simple_request(NULL, fm, &args); if (!err) { fuse_dir_changed(dir); fuse_entry_unlinked(entry); @@ -1010,7 +1010,7 @@ static int fuse_rmdir(struct inode *dir, struct dentry *entry) args.in_numargs = 1; args.in_args[0].size = entry->d_name.len + 1; args.in_args[0].value = entry->d_name.name; - err = fuse_simple_request(fm, &args); + err = fuse_simple_request(NULL, fm, &args); if (!err) { fuse_dir_changed(dir); fuse_entry_unlinked(entry); @@ -1040,7 +1040,7 @@ static int fuse_rename_common(struct inode *olddir, struct dentry *oldent, args.in_args[1].value = oldent->d_name.name; args.in_args[2].size = newent->d_name.len + 1; args.in_args[2].value = newent->d_name.name; - err = fuse_simple_request(fm, &args); + err = fuse_simple_request(NULL, fm, &args); if (!err) { /* ctime changes */ fuse_update_ctime(d_inode(oldent)); @@ -1210,7 +1210,7 @@ static int fuse_do_statx(struct inode *inode, struct file *file, args.out_numargs = 1; args.out_args[0].size = sizeof(outarg); args.out_args[0].value = &outarg; - err = fuse_simple_request(fm, &args); + err = fuse_simple_request(NULL, fm, &args); if (err) return err; @@ -1268,7 +1268,7 @@ static int fuse_do_getattr(struct inode *inode, struct kstat *stat, args.out_numargs = 1; args.out_args[0].size = sizeof(outarg); args.out_args[0].value = &outarg; - err = fuse_simple_request(fm, &args); + err = fuse_simple_request(NULL, fm, &args); if (!err) { if (fuse_invalid_attr(&outarg.attr) || inode_wrong_type(inode, outarg.attr.mode)) { @@ -1472,7 +1472,7 @@ static int fuse_access(struct inode *inode, int mask) args.in_numargs = 1; args.in_args[0].size = sizeof(inarg); args.in_args[0].value = &inarg; - err = fuse_simple_request(fm, &args); + err = fuse_simple_request(NULL, fm, &args); if (err == -ENOSYS) { fm->fc->no_access = 1; err = 0; @@ -1584,7 +1584,7 @@ static int fuse_readlink_page(struct inode *inode, struct page *page) ap.args.page_zeroing = true; ap.args.out_numargs = 1; ap.args.out_args[0].size = desc.length; - res = fuse_simple_request(fm, &ap.args); + res = fuse_simple_request(NULL, fm, &ap.args); fuse_invalidate_atime(inode); @@ -1857,7 +1857,7 @@ int fuse_flush_times(struct inode *inode, struct fuse_file *ff) } fuse_setattr_fill(fm->fc, &args, inode, &inarg, &outarg); - return fuse_simple_request(fm, &args); + return fuse_simple_request(NULL, fm, &args); } /* @@ -1970,7 +1970,7 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr, inarg.valid |= FATTR_KILL_SUIDGID; } fuse_setattr_fill(fc, &args, inode, &inarg, &outarg); - err = fuse_simple_request(fm, &args); + err = fuse_simple_request(NULL, fm, &args); if (err) { if (err == -EINTR) fuse_invalidate_attr(inode); diff --git a/fs/fuse/file.c b/fs/fuse/file.c index f39456c65ed7..7d14d533dad1 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -48,7 +48,7 @@ static int fuse_send_open(struct fuse_mount *fm, u64 nodeid, args.out_args[0].size = sizeof(*outargp); args.out_args[0].value = outargp; - return fuse_simple_request(fm, &args); + return fuse_simple_request(NULL, fm, &args); } struct fuse_file *fuse_file_alloc(struct fuse_mount *fm, bool release) @@ -111,7 +111,7 @@ static void fuse_file_put(struct fuse_file *ff, bool sync) if (!args) { /* Do nothing when server does not implement 'open' */ } else if (sync) { - fuse_simple_request(ff->fm, args); + fuse_simple_request(NULL, ff->fm, args); fuse_release_end(ff->fm, args, 0); } else { args->end = fuse_release_end; @@ -539,7 +539,7 @@ static int fuse_flush(struct file *file, fl_owner_t id) args.in_args[0].value = &inarg; args.force = true; - err = fuse_simple_request(fm, &args); + err = fuse_simple_request(NULL, fm, &args); if (err == -ENOSYS) { fm->fc->no_flush = 1; err = 0; @@ -572,7 +572,7 @@ int fuse_fsync_common(struct file *file, loff_t start, loff_t end, args.in_numargs = 1; args.in_args[0].size = sizeof(inarg); args.in_args[0].value = &inarg; - return fuse_simple_request(fm, &args); + return fuse_simple_request(NULL, fm, &args); } static int fuse_fsync(struct file *file, loff_t start, loff_t end, @@ -814,7 +814,7 @@ static ssize_t fuse_send_read(struct fuse_io_args *ia, loff_t pos, size_t count, if (ia->io->async) return fuse_async_req_send(fm, ia, count); - return fuse_simple_request(fm, &ia->ap.args); + return fuse_simple_request(NULL, fm, &ia->ap.args); } static void fuse_read_update_size(struct inode *inode, loff_t size, @@ -878,7 +878,7 @@ static int fuse_do_readpage(struct file *file, struct page *page) desc.length--; fuse_read_args_fill(&ia, file, pos, desc.length, FUSE_READ); - res = fuse_simple_request(fm, &ia.ap.args); + res = fuse_simple_request(NULL, fm, &ia.ap.args); if (res < 0) return res; /* @@ -976,7 +976,7 @@ static void fuse_send_readpages(struct fuse_io_args *ia, struct file *file) if (!err) return; } else { - res = fuse_simple_request(fm, &ap->args); + res = fuse_simple_request(NULL, fm, &ap->args); err = res < 0 ? res : 0; } fuse_readpages_end(fm, &ap->args, err); @@ -1101,7 +1101,7 @@ static ssize_t fuse_send_write(struct fuse_io_args *ia, loff_t pos, if (ia->io->async) return fuse_async_req_send(fm, ia, count); - err = fuse_simple_request(fm, &ia->ap.args); + err = fuse_simple_request(NULL, fm, &ia->ap.args); if (!err && ia->write.out.size > count) err = -EIO; @@ -1147,7 +1147,7 @@ static ssize_t fuse_send_write_pages(struct fuse_io_args *ia, if (fm->fc->handle_killpriv_v2 && !capable(CAP_FSETID)) ia->write.in.write_flags |= FUSE_WRITE_KILL_SUIDGID; - err = fuse_simple_request(fm, &ap->args); + err = fuse_simple_request(NULL, fm, &ap->args); if (!err && ia->write.out.size > count) err = -EIO; @@ -2656,7 +2656,7 @@ static int fuse_getlk(struct file *file, struct file_lock *fl) args.out_numargs = 1; args.out_args[0].size = sizeof(outarg); args.out_args[0].value = &outarg; - err = fuse_simple_request(fm, &args); + err = fuse_simple_request(NULL, fm, &args); if (!err) err = convert_fuse_file_lock(fm->fc, &outarg.lk, fl); @@ -2680,7 +2680,7 @@ static int fuse_setlk(struct file *file, struct file_lock *fl, int flock) } fuse_lk_fill(&args, file, fl, opcode, pid_nr, flock, &inarg); - err = fuse_simple_request(fm, &args); + err = fuse_simple_request(NULL, fm, &args); /* locking is restartable */ if (err == -EINTR) @@ -2754,7 +2754,7 @@ static sector_t fuse_bmap(struct address_space *mapping, sector_t block) args.out_numargs = 1; args.out_args[0].size = sizeof(outarg); args.out_args[0].value = &outarg; - err = fuse_simple_request(fm, &args); + err = fuse_simple_request(NULL, fm, &args); if (err == -ENOSYS) fm->fc->no_bmap = 1; @@ -2786,7 +2786,7 @@ static loff_t fuse_lseek(struct file *file, loff_t offset, int whence) args.out_numargs = 1; args.out_args[0].size = sizeof(outarg); args.out_args[0].value = &outarg; - err = fuse_simple_request(fm, &args); + err = fuse_simple_request(NULL, fm, &args); if (err) { if (err == -ENOSYS) { fm->fc->no_lseek = 1; @@ -2919,7 +2919,7 @@ __poll_t fuse_file_poll(struct file *file, poll_table *wait) args.out_numargs = 1; args.out_args[0].size = sizeof(outarg); args.out_args[0].value = &outarg; - err = fuse_simple_request(fm, &args); + err = fuse_simple_request(NULL, fm, &args); if (!err) return demangle_poll(outarg.revents); @@ -3141,7 +3141,7 @@ static long fuse_file_fallocate(struct file *file, int mode, loff_t offset, args.in_numargs = 1; args.in_args[0].size = sizeof(inarg); args.in_args[0].value = &inarg; - err = fuse_simple_request(fm, &args); + err = fuse_simple_request(NULL, fm, &args); if (err == -ENOSYS) { fm->fc->no_fallocate = 1; err = -EOPNOTSUPP; @@ -3253,7 +3253,7 @@ static ssize_t __fuse_copy_file_range(struct file *file_in, loff_t pos_in, args.out_numargs = 1; args.out_args[0].size = sizeof(outarg); args.out_args[0].value = &outarg; - err = fuse_simple_request(fm, &args); + err = fuse_simple_request(NULL, fm, &args); if (err == -ENOSYS) { fc->no_copy_file_range = 1; err = -EOPNOTSUPP; diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index f23919610313..656575e3e4cf 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1154,7 +1154,8 @@ void __exit fuse_ctl_cleanup(void); /** * Simple request sending that does request allocation and freeing */ -ssize_t fuse_simple_request(struct fuse_mount *fm, struct fuse_args *args); +ssize_t fuse_simple_request(struct mnt_idmap *idmap, struct fuse_mount *fm, + struct fuse_args *args); int fuse_simple_background(struct fuse_mount *fm, struct fuse_args *args, gfp_t gfp_flags); diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 115538f6f283..2e26810066e8 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -586,7 +586,7 @@ static void fuse_send_destroy(struct fuse_mount *fm) args.opcode = FUSE_DESTROY; args.force = true; args.nocreds = true; - fuse_simple_request(fm, &args); + fuse_simple_request(NULL, fm, &args); } } @@ -624,7 +624,7 @@ static int fuse_statfs(struct dentry *dentry, struct kstatfs *buf) args.out_numargs = 1; args.out_args[0].size = sizeof(outarg); args.out_args[0].value = &outarg; - err = fuse_simple_request(fm, &args); + err = fuse_simple_request(NULL, fm, &args); if (!err) convert_fuse_statfs(buf, &outarg.st); return err; @@ -713,7 +713,7 @@ static int fuse_sync_fs(struct super_block *sb, int wait) args.nodeid = get_node_id(sb->s_root->d_inode); args.out_numargs = 0; - err = fuse_simple_request(fm, &args); + err = fuse_simple_request(NULL, fm, &args); if (err == -ENOSYS) { fc->sync_fs = 0; err = 0; diff --git a/fs/fuse/ioctl.c b/fs/fuse/ioctl.c index 572ce8a82ceb..b40dd931167d 100644 --- a/fs/fuse/ioctl.c +++ b/fs/fuse/ioctl.c @@ -18,7 +18,7 @@ static ssize_t fuse_send_ioctl(struct fuse_mount *fm, struct fuse_args *args, args->out_args[0].size = sizeof(*outarg); args->out_args[0].value = outarg; - ret = fuse_simple_request(fm, args); + ret = fuse_simple_request(NULL, fm, args); /* Translate ENOSYS, which shouldn't be returned from fs */ if (ret == -ENOSYS) diff --git a/fs/fuse/readdir.c b/fs/fuse/readdir.c index 0377b6dc24c8..e8a093289421 100644 --- a/fs/fuse/readdir.c +++ b/fs/fuse/readdir.c @@ -279,7 +279,7 @@ static void fuse_force_forget(struct file *file, u64 nodeid) args.force = true; args.noreply = true; - fuse_simple_request(fm, &args); + fuse_simple_request(NULL, fm, &args); /* ignore errors */ } @@ -358,7 +358,7 @@ static int fuse_readdir_uncached(struct file *file, struct dir_context *ctx) FUSE_READDIR); } locked = fuse_lock_inode(inode); - res = fuse_simple_request(fm, &ap->args); + res = fuse_simple_request(NULL, fm, &ap->args); fuse_unlock_inode(inode, locked); if (res >= 0) { if (!res) { diff --git a/fs/fuse/xattr.c b/fs/fuse/xattr.c index 5b423fdbb13f..6f8f1453b550 100644 --- a/fs/fuse/xattr.c +++ b/fs/fuse/xattr.c @@ -37,7 +37,7 @@ int fuse_setxattr(struct inode *inode, const char *name, const void *value, args.in_args[1].value = name; args.in_args[2].size = size; args.in_args[2].value = value; - err = fuse_simple_request(fm, &args); + err = fuse_simple_request(NULL, fm, &args); if (err == -ENOSYS) { fm->fc->no_setxattr = 1; err = -EOPNOTSUPP; @@ -79,7 +79,7 @@ ssize_t fuse_getxattr(struct inode *inode, const char *name, void *value, args.out_args[0].size = sizeof(outarg); args.out_args[0].value = &outarg; } - ret = fuse_simple_request(fm, &args); + ret = fuse_simple_request(NULL, fm, &args); if (!ret && !size) ret = min_t(ssize_t, outarg.size, XATTR_SIZE_MAX); if (ret == -ENOSYS) { @@ -141,7 +141,7 @@ ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size) args.out_args[0].size = sizeof(outarg); args.out_args[0].value = &outarg; } - ret = fuse_simple_request(fm, &args); + ret = fuse_simple_request(NULL, fm, &args); if (!ret && !size) ret = min_t(ssize_t, outarg.size, XATTR_LIST_MAX); if (ret > 0 && size) @@ -167,7 +167,7 @@ int fuse_removexattr(struct inode *inode, const char *name) args.in_numargs = 1; args.in_args[0].size = strlen(name) + 1; args.in_args[0].value = name; - err = fuse_simple_request(fm, &args); + err = fuse_simple_request(NULL, fm, &args); if (err == -ENOSYS) { fm->fc->no_removexattr = 1; err = -EOPNOTSUPP; From patchwork Tue Sep 3 15:16:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13788883 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 23D9318BB8E for ; Tue, 3 Sep 2024 15:16:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376621; cv=none; b=BiRxEI53s2+zmc/MBmVJwhHPZLyZC4nBGISirb+qFW8xBsQbMcZRxH1BwujVFQoY2kXi2TzwXd8OrqoIM6nQSxTHZN7DyorMGG+awOKQ29qYA912jS6v8sM8lmASgb/jMGSu+OVn61DbdDDpdZ5OrWxL8LbW66cMj1XZpuH5gJo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376621; c=relaxed/simple; bh=+0zwTUGo6+RzPqyLPLoGhao9V7bGVcfHhuOQ58510LE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=er858B00057PCf+9Q8T1BAU4DIoVDjvBx3LqWfZGK9N/8UXYkN1k4OJ48HQU5TaxJaHy6PrsIfq+PIG6HnzdpAkFphhEoiH6jRot+oOaY8izlGOpdD+ZBg2Ek9Y+0B6Yp4c95Us9j4C5lRWTIpTX9Lg2jU+ku81W/YDQle5FKfE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=g+ofcIm+; arc=none smtp.client-ip=185.125.188.123 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="g+ofcIm+" 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 0B8AE3FE1F for ; Tue, 3 Sep 2024 15:16:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1725376616; bh=JC0kbEJjIhY7PwaINGFTAAblNYwex3Ap6OFdo5D4DqU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=g+ofcIm+rqDR6dWLcimaW9z0m2Ifg9eK0bJtFN2JHnGERtxRkruqxNfejY80PyShu oxseGvVNdE530qtdnGTlWe/oD4bR9w32Dxw3ftgptwWYrJyfYB6ILOuSdEqOPmudsM WCvd1t7M0Nv/niZXSLwUJ/2CKKffWVSE31HB86MniORNWIfp8ZCd8lyQRYLjTCDLS+ sUSIZeWl1zTeElmaGkgDkE0JUz/MWleR2NVuaUAs9JARzTz2UHfli2LyJwkXXpzwlJ B0XWtF/P1U4p59sLgA8e/16rD5Gkzj5d+qE1GAz1Va1GUH5naG+cDiN7AMwvwXUhZu o6DDCK0ssBVNg== Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-5c244732fe0so2932332a12.3 for ; Tue, 03 Sep 2024 08:16:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725376615; x=1725981415; 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=JC0kbEJjIhY7PwaINGFTAAblNYwex3Ap6OFdo5D4DqU=; b=q7lJrWwmaJC9lbK959WlsEJBn6TUF64SS/vgcGgSzRRtpFtePa8W6oP27vSRKB1T5H A0x6MpJDd0s/3854cw8nNtpccQZgnpiuOh6ENCTeqN4DyCUUiNYmIwIxB6edbZP98XEc cKorMuKTr02oIsTxK0z7AjGP9G3TM6FKy+wIyO6prCb2tr3znWPHp+oDx8inWfIYKblk rEPtIOaOE1qkej41Y/odBnbccweR7HLZjjugcf9FX7LJPbt7kamkCko8LbvM47DiVC3C lUXPboeE99Ql/6ERMz4HrrUdcqMNIQ3s03Yqr6azlFc817yS4TD3o1mmzd+Fzw9xzpD3 6O0Q== X-Forwarded-Encrypted: i=1; AJvYcCXQf0crpJKTjuyOYeMaM7F1EfgSBkSxn2NgILAElQMXNDAyC0TEWwROX2DyvsHfb2MBKONXnUcmSerEadip@vger.kernel.org X-Gm-Message-State: AOJu0YwqrpmRGjv4qkfSJ+TnaDE+13girh6E4B1bAQ9n3qVqLTNHHqYL 5U/Y3Sue2YrTEwMLiqva6osl7MuUfNKBXEBTqcjUad5WEmG6xKg2BLQpNSUlDzUYhlYH1SyMCdf EP2vA2GBmZOD65yj5j+OCY2Bcu5VXVijC+U4e07F48ZVqpsHaJOydlnkEEprTbfGn5L7s377vJN S2VUM= X-Received: by 2002:a17:907:7f22:b0:a7a:8586:d36b with SMTP id a640c23a62f3a-a8a32df201amr77097766b.3.1725376615495; Tue, 03 Sep 2024 08:16:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF6yFu1Bsw3W/nZaOc47kv/qKH1mcQ+bQ3WmyZBHT/KsKGUKlObSlloDjZT275IsdiJSzRa3A== X-Received: by 2002:a17:907:7f22:b0:a7a:8586:d36b with SMTP id a640c23a62f3a-a8a32df201amr77095866b.3.1725376614995; Tue, 03 Sep 2024 08:16:54 -0700 (PDT) Received: from amikhalitsyn.. ([188.192.113.77]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a19afb108sm156377166b.223.2024.09.03.08.16.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 08:16:54 -0700 (PDT) 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 v4 04/15] fs/fuse: support idmapped FUSE_EXT_GROUPS Date: Tue, 3 Sep 2024 17:16:15 +0200 Message-Id: <20240903151626.264609-5-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240903151626.264609-1-aleksandr.mikhalitsyn@canonical.com> References: <20240903151626.264609-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 remap parent_gid, but have to adjust group membership checks and take idmapping into account. Cc: Christian Brauner Cc: Seth Forshee Cc: Miklos Szeredi Cc: Amir Goldstein Cc: Bernd Schubert Cc: Signed-off-by: Alexander Mikhalitsyn --- v4: - this commit added --- fs/fuse/dir.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 2a8344776350..b0b57f383889 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -545,17 +545,21 @@ static u32 fuse_ext_size(size_t size) /* * This adds just a single supplementary group that matches the parent's group. */ -static int get_create_supp_group(struct inode *dir, struct fuse_in_arg *ext) +static int get_create_supp_group(struct mnt_idmap *idmap, + struct inode *dir, + struct fuse_in_arg *ext) { struct fuse_conn *fc = get_fuse_conn(dir); struct fuse_ext_header *xh; struct fuse_supp_groups *sg; kgid_t kgid = dir->i_gid; + vfsgid_t vfsgid = make_vfsgid(idmap, fc->user_ns, kgid); gid_t parent_gid = from_kgid(fc->user_ns, kgid); + u32 sg_len = fuse_ext_size(sizeof(*sg) + sizeof(sg->groups[0])); - if (parent_gid == (gid_t) -1 || gid_eq(kgid, current_fsgid()) || - !in_group_p(kgid)) + if (parent_gid == (gid_t) -1 || vfsgid_eq_kgid(vfsgid, current_fsgid()) || + !vfsgid_in_group_p(vfsgid)) return 0; xh = extend_arg(ext, sg_len); @@ -572,7 +576,8 @@ 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_create_ext(struct mnt_idmap *idmap, + struct fuse_args *args, struct inode *dir, struct dentry *dentry, umode_t mode) { @@ -583,7 +588,7 @@ static int get_create_ext(struct fuse_args *args, if (fc->init_security) err = get_security_context(dentry, mode, &ext); if (!err && fc->create_supp_group) - err = get_create_supp_group(dir, &ext); + err = get_create_supp_group(idmap, dir, &ext); if (!err && ext.size) { WARN_ON(args->in_numargs >= ARRAY_SIZE(args->in_args)); @@ -668,7 +673,7 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, args.out_args[1].size = sizeof(*outopenp); args.out_args[1].value = outopenp; - 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; @@ -798,7 +803,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; } From patchwork Tue Sep 3 15:16:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13788884 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 08C5818BBAF for ; Tue, 3 Sep 2024 15:17:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376622; cv=none; b=tRM9e1yB00+dDKr/8y42e/wYMDqwIDHzjZIN55dozC1HMzFTszDht/RuEaz+CJiaQITVqinwciMdoV/yNah1JebsvNMM3YOokgOk7R1YD8WJDyaLfzKbYuI8y+rI4hd/DyCMGKV8VAGLhgBIojdLX15OYLPUS4fkBuqMm7Qh12s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376622; c=relaxed/simple; bh=Yr7wQhBs5pebMPkKqO5eqjjytj+7qxLU8ExEBWlCpb0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SV9HYnyV+vvTnc0fxaq2v7c3GYy8558kw8zO8HVOzrN/VV2XBZlR+AiIo709j9/IizAUMHoWjxIDJrh3jdOA/r5CtcLA+QgqH7+9+wkTKv5mZJrOx5OOsR+xgPYi4RaBznpTgBQybN/tX8CGcGd8dSVfXRZX2/rm4SSL2NZvVVc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=Hmozy3iG; arc=none smtp.client-ip=185.125.188.123 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="Hmozy3iG" Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.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-1.canonical.com (Postfix) with ESMTPS id 94F93400E1 for ; Tue, 3 Sep 2024 15:16:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1725376619; bh=BpXAW2lUVronVaNHhSb0yzusLu0aiPuPE022IFBzXL8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Hmozy3iGov6XJmRVuFVAN7TpJSUnoa0IsAhpyeIaYCtPh1Kw7lJ5AGaTIiw8RNWQa 1kWVSIRDwpAa/XeKb9FrlzArfvK0VLpctMjuBGzxS9lWq6FMQVoz37aZlTTE63bGUC XaK3k8bA9ODLHcbaVun5AmXaC+4cNrxhqC/88L/3XZCJ5BEDgIrcDK7R0qdHcXkQQU HAIgP4mCaSScZThGU3eQMBjCIRIMxW8Xb4xcx41MTh5Bth615HMm1mkwJiyC1aYh5M KA7tCcVSUb9RbaU6oEwNQ4EQUTseZruT64ze6JygVqTPIfyDNMpsdcOQj8+xT4stTR NBs5eKFszjyjQ== Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-53440ff1ecfso5784011e87.3 for ; Tue, 03 Sep 2024 08:16:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725376618; x=1725981418; 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=BpXAW2lUVronVaNHhSb0yzusLu0aiPuPE022IFBzXL8=; b=dNsu2WoXUFTYkAhXJsXWFdo8Y0zAmgR7h6DeNJejEEkY0D/bP+8SnRclIjuqu9cwq2 5cITTgr1sU1XttzV7NrdjShb0K5Bo9mZP0i5UOXLQQtPpHKFYdK92/z2SFoUdMH2b8Iz HdNpYqxviQj7IWYe/i2kYJUaqXKv9Sm3jGTFtZrCWI9mCxdGd4JNee0m4U5c4+dWJCcW WoJjCoOGgy8CoIGT3FtFRRGZ4QloGLYULUPnUxxRxYXGMSVU6VyDAJ8jV3MI9Kg+EGZo PUKwBw3j8oVkC1bMMbLxO72TdjR/fHz1+l+HhulvZ/rjpPhztXOm+0rYkhkpB+KpzRvM qqag== X-Forwarded-Encrypted: i=1; AJvYcCXTeSC+3tZx+Yr6kIrawEtmc2UUCiGGGod6GdQuvD3BUWjN4C1uu8UQWAfSlgOIMr3khVuCKsI/bnb7Sw/i@vger.kernel.org X-Gm-Message-State: AOJu0YzkmPZ0h/CuGbqRPhQuw91lnXuVrbNznvnC0uvVb8aLoGBI84wm qrq/9G4UFROqy4MtSzV0xqdEsYWvqdjfjgClDzjP279AlENMdotqiq5/nNEox4S07UcCVnFCWRq nJKqPnxMtpKZHdfCKTuFLh9a4JdrukCrmtA8kQclgIRFOTroQ4mUBwFBofKM6CTwnglEHg8UAhR 89pfY= X-Received: by 2002:a05:6512:3b2b:b0:533:71f:3a53 with SMTP id 2adb3069b0e04-53546b053admr12510697e87.19.1725376618032; Tue, 03 Sep 2024 08:16:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGdwhaHs8FzcWgy+bcSv/A5Fb3K4tgSBYe1Zj63ijkeXEFavmBE5n3V1565EXlaJFFrj2Oa4g== X-Received: by 2002:a05:6512:3b2b:b0:533:71f:3a53 with SMTP id 2adb3069b0e04-53546b053admr12510667e87.19.1725376617503; Tue, 03 Sep 2024 08:16:57 -0700 (PDT) Received: from amikhalitsyn.. ([188.192.113.77]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a19afb108sm156377166b.223.2024.09.03.08.16.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 08:16:57 -0700 (PDT) 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 v4 05/15] fs/fuse: support idmap for mkdir/mknod/symlink/create/tmpfile Date: Tue, 3 Sep 2024 17:16:16 +0200 Message-Id: <20240903151626.264609-6-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240903151626.264609-1-aleksandr.mikhalitsyn@canonical.com> References: <20240903151626.264609-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 Reviewed-by: Christian Brauner --- v4: - pass idmapping to fuse_simple_request() --- fs/fuse/dir.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index b0b57f383889..19538b1c12e2 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -614,9 +614,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; @@ -673,11 +673,11 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, args.out_args[1].size = sizeof(*outopenp); args.out_args[1].value = outopenp; - 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; - err = fuse_simple_request(NULL, fm, &args); + err = fuse_simple_request(idmap, fm, &args); free_ext_value(&args); if (err) goto out_free_ff; @@ -734,6 +734,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; @@ -758,7 +759,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; @@ -769,7 +770,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: @@ -779,9 +780,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; @@ -803,12 +804,12 @@ 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; } - err = fuse_simple_request(NULL, fm, args); + err = fuse_simple_request(idmap, fm, args); free_ext_value(args); if (err) goto out_put_forget_req; @@ -869,13 +870,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, @@ -887,7 +888,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; @@ -914,7 +915,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, @@ -930,7 +931,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) @@ -1124,7 +1125,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(NULL, fm, &args, newdir, newent, inode->i_mode); if (!err) fuse_update_ctime_in_cache(inode); else if (err == -EINTR) From patchwork Tue Sep 3 15:16:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13788885 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 032C218E349 for ; Tue, 3 Sep 2024 15:17:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376626; cv=none; b=TKv3VpOJrn5n0NySvjchS4cpxbwV6sn05gvyBj36D29iI8Cfdywrr5yu+8peZWAoYkescCVAwJ6tOKHSEZvn611cIWctZXdemMgb+cnSjI9Ti04p7oHv9iZsATFqCIYHi1LTub3509ob3n3Fbs39OMnV+ohPmE9Y7SELS3y82OM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376626; c=relaxed/simple; bh=PaAk/eaWHJYrtpeNCjv4dfhLvGaJwWHZoj/fTJYrBoo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dIfkgi1ADZWvTRqFy8XF+xDyHdeVUYVu+12BUJ7fn5OmthQn1vL23NFGa7yRMr2+OKbd+gr+fj/IWTudCkhkx0y7YF21HVYoeuuDlazAHvjit4tSsLqsGV2aeLvF1NEGlgbTEOt/ZtmCccu45Otrmt+VU5llISXUxOK0VWYUsHE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=mUXJOX/J; arc=none smtp.client-ip=185.125.188.123 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="mUXJOX/J" Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.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-1.canonical.com (Postfix) with ESMTPS id 002A2402EB for ; Tue, 3 Sep 2024 15:17:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1725376621; bh=oliM0t1YZlK8AQPobnRlPgoF+ATvch875oLL0LQh984=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mUXJOX/JKEkI6pf610+HoME5lN+pfHYtxlq1Xp7d7nptuITTjpNGJd9qdy6jzcjNz FlCc8Kl6u5QEBFwxv3O624rjIbqlhbSILcwGd0xVPg7LeSWjvisbFRQ/qCiIAcscIc ceFJT40JP7pz2Ji9kbf+UsX5bXThywKxka3+Z37PvjTUKJc8grkD6BApaPNqsU6PNf ujvuuB1nwkZxo2oJnPFlIUEFoiWvPeovJ4f0GNFZ8TrMZO0E0EtPMj6xuoVX/dmxrh BNDUGNJJ23MG1+L6HN7AhlSpuxScK3gUXvFK53FjaidMR1BLOYL2BRaMknJlOJ7O7t x69xJes0JLQVQ== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a7a83fad218so475386466b.3 for ; Tue, 03 Sep 2024 08:17:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725376620; x=1725981420; 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=oliM0t1YZlK8AQPobnRlPgoF+ATvch875oLL0LQh984=; b=RaBYE1JeeqxXZbjDS5lbjpOGi+ut1Xj3xGP6R+AZoJqayvwuDzli6+egkRFpl8KRQ2 bK8yiL/DquTFfFcMN9ZCPf4qE8XgnuJoDG7SyMbWvyehnU6Fs02Mn/RYxMoK6bdg0ODa rTcLHw5hhV+TunzyPmt4ZTsexgX2wrV1oMajfsgp4S6oskPk1M6yQ1YyviRwx4g36RD0 nbqUwZligNO+sfU5MpjPar+cMfuF43jNqO2aNzre9/dJDfWvRrppEro1ftbJPQe8AA+7 1o0HbQp2xQq12vH99dNKeKSKYyjkisUBWI2foOIxAhq1t56U8AoJ/iWAUpeIv2H7JIo1 Bigw== X-Forwarded-Encrypted: i=1; AJvYcCXUkVAN+2RzZzeXX0IBlxpXccE0DOEk3mdBoB61yCSaps3bLEWVX6W0wZDeK465ooB5UdcAJGO2Ol0tQjR2@vger.kernel.org X-Gm-Message-State: AOJu0YzDSSnCsYF2yKY2nWrqwKURvDmA4q8PcPGroRPll3LjqMAT1Ujg 3Cay2RcwtY/dUdS8bHyBbT+Thhs9hAfvyvPrWLLpb9WpEjCYSL0tnXwZGjrq9aIvyx5R5oy1JMI czq/HIxJIW3GzWhhQhNfIrbr9tPa3Q5ftjV4g0U6t/RiQl7vUakQC/UtSgojzeCU/nuGTtTlEOC M3G/A= X-Received: by 2002:a17:907:1c1e:b0:a86:817e:d27b with SMTP id a640c23a62f3a-a89b96f8b2cmr841923566b.43.1725376620323; Tue, 03 Sep 2024 08:17:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPNpw2gqiAzwRWVbg8W7w5mbvdVshWLwdfJpDfVHqfWPAHPWbYqYWDRDznG8ehNU2TzIdLDQ== X-Received: by 2002:a17:907:1c1e:b0:a86:817e:d27b with SMTP id a640c23a62f3a-a89b96f8b2cmr841921066b.43.1725376619864; Tue, 03 Sep 2024 08:16:59 -0700 (PDT) Received: from amikhalitsyn.. ([188.192.113.77]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a19afb108sm156377166b.223.2024.09.03.08.16.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 08:16:59 -0700 (PDT) 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 v4 06/15] fs/fuse: support idmapped getattr inode op Date: Tue, 3 Sep 2024 17:16:17 +0200 Message-Id: <20240903151626.264609-7-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240903151626.264609-1-aleksandr.mikhalitsyn@canonical.com> References: <20240903151626.264609-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. In some cases we can just pass &nop_mnt_idmap, because idmapping won't be used in these codepaths. For example, when 3rd argument of fuse_do_getattr() is NULL then idmap argument is not used. 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 --- v2: - pass idmap in more cases to make code easier to understand --- 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 19538b1c12e2..1c28cdf9dd41 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -1134,18 +1134,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; @@ -1184,8 +1188,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; @@ -1238,15 +1242,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; @@ -1285,15 +1289,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); @@ -1324,17 +1328,17 @@ 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; err = 0; 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)) { @@ -1348,7 +1352,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, @@ -1492,7 +1496,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); } /* @@ -2071,7 +2075,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(idmap, inode, NULL, file); if (ret) return ret; @@ -2128,7 +2132,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 Tue Sep 3 15:16:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13788886 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 CAAF118F2CF for ; Tue, 3 Sep 2024 15:17:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376626; cv=none; b=M/H5B3Jixqdrownie3pZAfti2dmNKLbmTLp9oevWihWr5ZQI2sNCxqEPVviUL4RZXF+X82FU0cV0/Y86Xw1F5YW7un506+tAPjlBlhWC0m1d81YNSwUmYdDB1SZt5N8BxyNmMhYCXqNedmlxZ6F7MKov43hT349AOioYl5IFsfA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376626; c=relaxed/simple; bh=/KSxVyB7IT7zZF5p/b+JrUDxUP53IflmxMsoAbMzrQE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pEPEKGZ1lpNirxcCtZMlOFcJfrOBOEBaB/FpwntOvEvRnfqh9SFh3nSFiVA3OTcI5GDJAuwaWa+hFk2pADVV34Qbcsnx47aZ9Y+qbk7G5ae1GQZkEbPKZLkRaJ9aOj2/Z7QqR+/sstCQKds+cToiqgJQrgHzsgYP7t+VHVzBuGo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=eCFITWd6; arc=none smtp.client-ip=185.125.188.123 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="eCFITWd6" Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.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-1.canonical.com (Postfix) with ESMTPS id 5FF303F339 for ; Tue, 3 Sep 2024 15:17:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1725376623; bh=GgxPCzVaZ1cVZVunPaJCembmyRCPwoxjS+kDMNcCdhg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eCFITWd6K84eNO4iTeyQkjYIkmpK2gCgQIdPqUcrRYUGJdL0xhfaqvO+p5/I6kR8I ou8HAKvmFyTOkJyoIdmhtREeDGwEjIoB8JS+RvAJafmJBYetUOBr+P+NAbM86j2mbj X7hRbjkpn0JHcnwSUQldPm0HK+Ka62isuYn0PIzXyD5PFB5Mxs7cBOZndBMahJ+JO2 6IcyfNW4VHdRLNGCDfly3m1+PSrkE0hzupHwuTZgeRU7RMgA6aUQUPzrSwcESwzwU9 +9aVpfjKEWRYwm3v2ij7EVYGOjR5sTSPVI9lS7ZR7ZYVV3cadr4azHVY1hG1eb06es ELnLQP0+R1rDw== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a8683bd9e67so462501466b.1 for ; Tue, 03 Sep 2024 08:17:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725376623; x=1725981423; 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=GgxPCzVaZ1cVZVunPaJCembmyRCPwoxjS+kDMNcCdhg=; b=gj5op08g6OA4gjtDhPbITtG6BXz7O9/KLT9i8VJFWUYV/ZAmPdSJtBvBOrhu+DOrUV VL0g5AtRxeOGbDWiAtJC/d0I/+ZEAI7nqFdtu+UM3v1ZCFQIEbMMM7JzmHjeVtQ3WuFa u4tyIZJXG2d9A33gSVPj9vrGRIyQMSEWq6ArLBHHAjwuaauxJIPDL+HAE9TYPxwB4JBG FQ/yWaBz7GRdEy0xd+tgZberGgmV4vMYq9t8rKB2F75eAVyNaN4IOBbVrW+Kf/uBtcno Q+3QQPoUecS25k4t5hO4IObk7UBaENXXLCVvOnkY5LfQPjTEhFknnYYmfOkFh20GLFLo PVqQ== X-Forwarded-Encrypted: i=1; AJvYcCXKMRaTxlVgkdS+u1DPvCPjSFfi/r9HaxzzEh1gs6UaVL1Hkl31lLvwOahaZ8MRAgTze0eVCF0OwbsfpoO9@vger.kernel.org X-Gm-Message-State: AOJu0YyUiwP3RNHfG0z3cCZg7Xu4JKAA/ADC/flw7ArqtT6mFSF4qU1f bFSf29sBZ9x0ZipZiiHBwkNl7qP1rQInupGQ3k1k2TzNq9IE3tCS+eftHhZUkyduZsE1RQlDwbZ YhgHaYQRGD6T6Y1/3FwUB6ZpRbO72QnDKfFiDXjtRU1wYjC3Lb8U9ETZUL/BAggg9o7xCDJG5u4 5dmzY= X-Received: by 2002:a17:907:3f1c:b0:a86:789c:2d07 with SMTP id a640c23a62f3a-a8a1d29bc25mr284010866b.4.1725376622788; Tue, 03 Sep 2024 08:17:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHEt5VDltIc8zPXPIFeiCz8KAUJj0grhVupIthxizBUK009KgECFOvAGAbSM0OXZIC/NPX1VA== X-Received: by 2002:a17:907:3f1c:b0:a86:789c:2d07 with SMTP id a640c23a62f3a-a8a1d29bc25mr284008566b.4.1725376622275; Tue, 03 Sep 2024 08:17:02 -0700 (PDT) Received: from amikhalitsyn.. ([188.192.113.77]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a19afb108sm156377166b.223.2024.09.03.08.17.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 08:17:01 -0700 (PDT) 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 v4 07/15] fs/fuse: support idmapped ->permission inode op Date: Tue, 3 Sep 2024 17:16:18 +0200 Message-Id: <20240903151626.264609-8-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240903151626.264609-1-aleksandr.mikhalitsyn@canonical.com> References: <20240903151626.264609-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 Reviewed-by: Christian Brauner --- 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 1c28cdf9dd41..870932543aa0 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -1544,7 +1544,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 @@ -1552,7 +1552,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 Tue Sep 3 15:16:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13788887 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 436A518FDC9 for ; Tue, 3 Sep 2024 15:17:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.122 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376629; cv=none; b=jO5bWRqvrTQ82lAyUBV5PpJ4OWq8MJ08auBdXb08g+ElDHDD1GtLbkfjeaRkzGHGt4Et/coa5HEY7xA6nRz4PLiGSBVQhaM0nAkwGEVVhIrGyoUz+TIV7wEIyU5fqrn7l8mNiOvX0grNa+KNYe6Yzoz134CkeDcDdjx2GGI7G1o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376629; c=relaxed/simple; bh=d1QU9K0mCSLy9i49hu3VgHqnFt0IkZctbCF8EsYa5UY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=j01V+n9Bto4XXZMuw8vZ1bAcXhIy7Oxelbom75SlE3RLZfQcvRlWQ8p4WdJ7msxyhNZIhV140yWezEgLIgfJwQhUksmu228u3KySxn0nn49JXXXcw9aw1lM/ClADClNLY8LNsmaXGxXWbMqWCWmjrQgdh3WGCbGJYWfTq3tpLPQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=E1bLWoTR; arc=none smtp.client-ip=185.125.188.122 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="E1bLWoTR" Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.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 2A15F3FE21 for ; Tue, 3 Sep 2024 15:17:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1725376626; bh=RUXBxrexsYj2ubgYvgii/4vTEm7ycdd5RVigA12ybdw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=E1bLWoTRCOyKNzFittU23kdpNS11Zsoh6FVhJLNoITB6/RISLApjqwLpEKRZGCLMS BNrsodV7++g3mO1nLOVUt4CtCtvo9vk5UzkLR8GuCKuhDzAsMjX8IVSMRgfZyCBXYb 8NN74tvxySEcOQiOcTXRrplyb7vrrdrEhrjUX+pWHObxSZomMXeX0cyAai95dWi+on fiD3LMKCmwlZBt34A/0aQzH6tMvDi32cGu4JCcpSk+gMeD46HPEUy+mrPWNiBYlU5o +9WNTMFTC8b1nTwmv7pNXtlt+iXSh3rIBr5V7UBmD23dIy8XK509DcsWBqmj1pkue0 k9DBuyvSXbVYQ== Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-5334656d5c3so5588676e87.1 for ; Tue, 03 Sep 2024 08:17:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725376625; x=1725981425; 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=RUXBxrexsYj2ubgYvgii/4vTEm7ycdd5RVigA12ybdw=; b=Nv23xdRbdtgqipT7GCaSh7CHcxJWPhD3M71ErJofj9jG5WeVYuuohissyG/GS8QqTq 8sGgR7BSGb5hyBqmAtwqQukXEET7NPvp9nqXiorA5H0xui3EhjD0j2V2GI9IfQwD7dxb D8nWIrmvW//+MeOXvnr65k8U5ziXbmVBgH1X6UVgxMK+1j8VbIp2g8i3z8Q09n5dpFrw rDc/wB/aeWUEanyKftQ0HqoWajvQ14lXL0P3rxGzbClFGGe8YyFIksXuTMXbPqpNDak7 aInqy/YoCKQ4FUlT8s3PLWu4ziChQwsCjWk+0MepMuynxJNV7pc4pjkE2bh8OmbGcIAf KewQ== X-Forwarded-Encrypted: i=1; AJvYcCVfjdjDen/b7c6n8pQIgJIDmWoj+piEBDtB8E93Y+68uSpUsBmbyw8quZgSukA9GDBDiPyMqDvKJicgjO5s@vger.kernel.org X-Gm-Message-State: AOJu0YxOWcyjXkhh8BIGm59P65ghuylUywf6o55LkeITE0t+179lF4MB GTbpSN0j4+P0GGxF3i/gFm9h+h6ySP3d+DVaRzjvB8D+9+Pz34SMiLkmqofTZX2COhMSgSMhPxH +GzjOPp8dOGPoWGyD/oOm803l+11v7zTS8eGH/Mq/j8QK5A+vmiiZUwpvqlR8j/Ass6qpFjErBZ mkBv8= X-Received: by 2002:a05:6512:2387:b0:530:c1fc:1c32 with SMTP id 2adb3069b0e04-53546b8e196mr10335870e87.45.1725376625246; Tue, 03 Sep 2024 08:17:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHbdVNQw9JIGlffkc2qNWniuxTLPhkWGbYYHUXdBD/ban51LA6iUri9d3hyagPN6wYzcdu37w== X-Received: by 2002:a05:6512:2387:b0:530:c1fc:1c32 with SMTP id 2adb3069b0e04-53546b8e196mr10335839e87.45.1725376624758; Tue, 03 Sep 2024 08:17:04 -0700 (PDT) Received: from amikhalitsyn.. ([188.192.113.77]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a19afb108sm156377166b.223.2024.09.03.08.17.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 08:17:04 -0700 (PDT) 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 v4 08/15] fs/fuse: support idmapped ->setattr op Date: Tue, 3 Sep 2024 17:16:19 +0200 Message-Id: <20240903151626.264609-9-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240903151626.264609-1-aleksandr.mikhalitsyn@canonical.com> References: <20240903151626.264609-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 Reviewed-by: Christian Brauner --- v2: - pass idmap in more cases to make code easier to understand --- 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 870932543aa0..08bf9cc51a65 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -1748,17 +1748,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) { @@ -1878,8 +1888,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); @@ -1899,7 +1909,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; @@ -1958,7 +1968,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; @@ -2093,7 +2103,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 7d14d533dad1..06ff4742ab08 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -2966,7 +2966,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(file_mnt_idmap(file), 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 656575e3e4cf..de0ab2f14995 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1331,8 +1331,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 Tue Sep 3 15:16:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13788888 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 1A2C41917EF for ; Tue, 3 Sep 2024 15:17:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376631; cv=none; b=GqNsWBp/zg1neJ1tYHV/nJSBxj8BXJUX6oaui9lOqb42SYFEVov1VpZP+I6fpcsF8B45JxR7pfE5EN4cPRHiErxj7VgkuZOOMFeGfZNDT7nDk9l0C8sa/gHG18794V0424GhjHEglFgVs4SbGwl+vhuCANbDdau5sIPUbz5KlGs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376631; c=relaxed/simple; bh=4adc61tKzjK2fTdo7B9pTquQAHQKVd/XEnUnW9CoK7g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=frReaKpKjg2oPnjUQYs+9YHYhUKg/AdigM1ZgsHpnMuuXu08mdI4YmXXeX2KIkq6EV0gAMLO/UUL9YXiWdsq4FzebrleY5NS05zGaGZHlxWvOwofW0g9Tjtht6L0abLObExsytxGbZ5+H3DulQaoZba+FfyXJ9UV+mhGQeqdEG4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=AxoFDJrR; arc=none smtp.client-ip=185.125.188.123 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="AxoFDJrR" 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 B1C203F283 for ; Tue, 3 Sep 2024 15:17:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1725376628; bh=ftHOv+os2MH3Qk9OKnsGMHrGZxHBoFg3umKFJ4e1joU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AxoFDJrR/uAvx2WbQfxnvYk5PgY958HjeB1+ETaE1JDOhukN+meK7erSN4/UDSHfz 0GneFHw0ulyFq1IGnJEvknX8NCLVMNbEVZbRCNb51VplxrCWb37Q1kKrPPc6HAPMnb 604DJ/AN51av/3k1dFrvvRRMOAOo1xIxzrYzPfsZo1z87KhUCNQXFGnpHy0TtGgc0b JwEgok/I5/kabsva8iPoVYmdBmgSbCKuj8WSo3tDT7WbByzgw/6cQTvU3KVxglDHVw XFISOpAoRJGWTeLvPJ8qn6ikozoGJUxpFIZpz3qA5c3b/LziTY13DgBWKSXXxR3gJl MP8d2mZBqXtmg== Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-53440ff1ecfso5784290e87.3 for ; Tue, 03 Sep 2024 08:17:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725376628; x=1725981428; 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=ftHOv+os2MH3Qk9OKnsGMHrGZxHBoFg3umKFJ4e1joU=; b=dJwmvv84xlb12VQ/a8E4JQ8TzHSoX31vmTNPlqxE5XmugkEpfEUqX5MG3/MRAYJ3Iy 658Qu2ILlkHN4lDmR4Je5HB1Eqx8+YEMC9AVN0OWtwYtZtDGBpKi333r1bnRdtt5oarG oIZonWuFUvI9Nsqn7S2QmbwcQBkxT3pktlcRCy0lFXOXPK35oJ2LIkScqr/fHqrH1Wmh 5/bi5lSrXr0ELqRRWnDd/fOO5Muz8kK+lehPYNouex0GMrbRr4Kz749A12PcRzuBRnyK 2stPH9X2V3N80DK7IXzPpR7af0uklBawvBIf2tUJDiRJ0FViGZl21GK8P0Gk2yUCzrqu 8YfA== X-Forwarded-Encrypted: i=1; AJvYcCWKboSV/BeuXz6W7gT+lo3nvD542AC01z4lgKOWJsYsLlpUwgXpN+3o6JPsyXUtdWLbq9ulNRGlDooRx5sA@vger.kernel.org X-Gm-Message-State: AOJu0YyoTY/d4stP3alfVMVVqlEgVeEGhGlbotkNEwsyMKWkJIC5dcN8 CO9/zqMTXz2inJ9fZUHg8ioysMbsOsiP4HCMxBuZyk6Hrbn+JGTCHgwrhXmmmYxFjOQsUKYLWln RjcWLiPSL6AkODJYactK6Vjd7pXaHMhX21dnwmrRAPEZmugvujhpZZVUpI2vCFqRaZ30LBPT6Ec 5I/Sg= X-Received: by 2002:a05:6512:282a:b0:533:6f3:9844 with SMTP id 2adb3069b0e04-53546afa387mr10490574e87.11.1725376627979; Tue, 03 Sep 2024 08:17:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE5r2bdM4b8pU4WooC0ysEsGd9NXSqimzWCsNEiz5JuzrIziCYp6jmEEIfAj6my8kq7tExZbg== X-Received: by 2002:a05:6512:282a:b0:533:6f3:9844 with SMTP id 2adb3069b0e04-53546afa387mr10490545e87.11.1725376627555; Tue, 03 Sep 2024 08:17:07 -0700 (PDT) Received: from amikhalitsyn.. ([188.192.113.77]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a19afb108sm156377166b.223.2024.09.03.08.17.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 08:17:07 -0700 (PDT) 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 v4 09/15] fs/fuse: drop idmap argument from __fuse_get_acl Date: Tue, 3 Sep 2024 17:16:20 +0200 Message-Id: <20240903151626.264609-10-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240903151626.264609-1-aleksandr.mikhalitsyn@canonical.com> References: <20240903151626.264609-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 04cfd8fee992..897d813c5e92 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 Tue Sep 3 15:16:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13788889 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 118F11922F8 for ; Tue, 3 Sep 2024 15:17:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.122 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376635; cv=none; b=MwzLotu5OBsQxj45D7fDtHP5PF7z1ABXGVUHYMae2m4qI3KhKKWCq+2KpqDeM+6FD4q/LkX1zlBSu4VgCXLTTLdkrPC7Yl6Y4Xw4oHTu4zsadCOj1vhDiuMnl6M9AwQpIip7jeaukwywKHbyWXmtGlhoYur5JEFtQIPYOhH/60o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376635; c=relaxed/simple; bh=zCrcaSPlVef9fMgj6fnLuhDo1m+kzv16tHWQShTiBI4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=M9Gr48LnY9x7hqScN5fcTV1GLDxMHJPCVL0WfGoXsFB5WK3RZa0CYC4KBx6BEJMPVU4ccktjeT1lnNIH2QAC4tpbF0GUnRKUA6HQkkWmv36eikSQBYMyhnQ8nL2/9SisZIH44G4coP9NglouUKHRi+aLyXXkdeQO2KdDKD3yrnM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=vYYS8ckV; arc=none smtp.client-ip=185.125.188.122 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="vYYS8ckV" Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.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 6AF9E3FC04 for ; Tue, 3 Sep 2024 15:17:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1725376631; bh=btta7JvkwVu4o++SpqzGVQUNPal7Y+ZsmtoSEosWuhw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=vYYS8ckVqaTMWNJBCPphlcouEvbpQ2KhpU/o3bXj7JehDaFasNpBRRcwslGJytNXP G68b3Wgtu8Oz//s9oxjH65eYh0YWsNkLsa1e9PbHfiO1v8XbhcQj+QeklBAjzFxspI Gc6ZdOic9CaCy3KpF+nUVTKjMJHu0JrQC2Xvy9fVqHZudyLFdRLblMG5T+qTrZP8Ya VsISIcnC5UQrMuWdPPOoD3ZcwVjjjWoQq5sefhc0s6DyVXPfTM/feNuf/kM2yTNufo 3ptaApsEM5/Px+NIxZulySycVhrslzeams5WVkfjGE6cNKfLN5HfAu5G2cUvj52Psi 3tOiPI8mGXedA== Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-5343808962cso6211042e87.2 for ; Tue, 03 Sep 2024 08:17:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725376631; x=1725981431; 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=btta7JvkwVu4o++SpqzGVQUNPal7Y+ZsmtoSEosWuhw=; b=l9rh+iHn07GVLJOZZSluZGbHP1TSFsa1vTtgupjoSEE/XxoVjiYJf7bqjMCw4nQsBj K2DDbTsp98lzCn5RodmGsyLYXVMQULq3VMoFyHGu1VGXUrR4fN+1ZlvxZ+UG9TXOO011 79MXQZ9tNNxS7BZFlkqI1XO4beu3g1Nv2F7tX64h1os+sz/gq0r49vcj2FgGD4s2N7uv QUFVk3SUPiza/reTZSUvuXiTaSN4Bq5jiBblsQX9AHDWNWeLAuVrVs0ub42KlzKn3kY8 3DFKjNsCkmfxSBFlIgmrIOtr9EmgIxMqDzvf+8ep4tBg5ielPqhBQjVe9/NB1SM2W2ML hMWg== X-Forwarded-Encrypted: i=1; AJvYcCVdxk1j9EfVnenDI36go+jbJXzODKSgaCY5roXenkXRt+l3nJ4z8WGNX0N5DJvylWLPqY6xNQ9QM3dUL59A@vger.kernel.org X-Gm-Message-State: AOJu0YzaDiYwtPBqUg6e6nXTpBswTxNBOWHsRP/JJWFeaB6wCCAdjbT2 r5RQkUMYkxKq2Ja0wpQjDPIflkldRGadD+GHyWdbODUldFlOWFymtWRTraHqXUhRQfO7ZQM+Jbw WJoPuXx+dNN7sGdl3qfkYy2VaP0FLN6pTvYuOx27dpH5RXdVqB6I77BfSx0Dj0hxet8IJFf618G b9AOo= X-Received: by 2002:a05:6512:2215:b0:533:4676:c218 with SMTP id 2adb3069b0e04-53546b191c1mr10714026e87.8.1725376630617; Tue, 03 Sep 2024 08:17:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF9/hcou3cmyT9HFV+yv/KjP2e+D8E+jeLocrBSGTUTM5RMK5sgega+1/hOouRDW8vLnMtf4A== X-Received: by 2002:a05:6512:2215:b0:533:4676:c218 with SMTP id 2adb3069b0e04-53546b191c1mr10713999e87.8.1725376630113; Tue, 03 Sep 2024 08:17:10 -0700 (PDT) Received: from amikhalitsyn.. ([188.192.113.77]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a19afb108sm156377166b.223.2024.09.03.08.17.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 08:17:09 -0700 (PDT) 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 v4 10/15] fs/fuse: support idmapped ->set_acl Date: Tue, 3 Sep 2024 17:16:21 +0200 Message-Id: <20240903151626.264609-11-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240903151626.264609-1-aleksandr.mikhalitsyn@canonical.com> References: <20240903151626.264609-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 Reviewed-by: Christian Brauner --- 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 897d813c5e92..8f484b105f13 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 && - !in_group_or_capable(&nop_mnt_idmap, inode, - i_gid_into_vfsgid(&nop_mnt_idmap, inode))) + !in_group_or_capable(idmap, inode, + i_gid_into_vfsgid(idmap, inode))) extra_flags |= FUSE_SETXATTR_ACL_KILL_SGID; ret = fuse_setxattr(inode, name, value, size, 0, extra_flags); From patchwork Tue Sep 3 15:16:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13788890 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 D3BBC1925AA for ; Tue, 3 Sep 2024 15:17:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.122 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376637; cv=none; b=WMJT7ZVayDkp383t8SzDBDW4uYQ0Y174QTnuO0801bAh0t8fuEv8Ivmxa1IxPXlXIeSkkKLggGJTbuDo3BsNZy39eIN6yF62m5Wcuxj9/fEtbdZxsuJ6Ghx/tyTvUvXRJDeFaTuUjgdOCuxU0qTpXG3kOeZ2le//OVj+kI9Hv94= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376637; c=relaxed/simple; bh=ezrwIWPEtkVKsO2BZ8GHjfDUp3paNgF+C0sOeuA/x40=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lA+4UFpKKBi4ABdQmrjhLs/6DakUJqwYL4Y+pd2eCqK7qlsGNZl9lmX7JvqBRz1o7TAGvcawQcfXbiiSQnk7WlYdSA3tIE3VB4AwyAOdNJXKJB+lXFN/3XMZtv50odi60vZBR92QQpojkIyfW3PY00H4cKpNFyBbulz3pU0b5iM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=Q/Y5sx7H; arc=none smtp.client-ip=185.125.188.122 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="Q/Y5sx7H" Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.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-0.canonical.com (Postfix) with ESMTPS id BA36D3FADB for ; Tue, 3 Sep 2024 15:17:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1725376633; bh=UlVqr8qfq0zm4LadiFaTT35TCbrEM7DrGylkId+7er0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q/Y5sx7Hjj9AbUArEUlD5AOtdoWF3y4v3vXtcfd6nk7K8F9zM0xym8Zp7m4taBnI8 JVdquzhnM0MWeDE+S3T29vJJgT0tz+3eXd66a/DkGIRr+vB13t1BYeSc7uiRzpxOKb 6oeGYseQgLT7TahKYdTt1Je21izR/Ohy0lNF2pejpwyO3Lb7wChyz09w4snQwKIw3T KeSCwy1Sp2wEop2DTQALtgOpaWqe2q1wZmXC3HzARLQqkl2cvIipjlxbGIdEB2zMO1 btU6gfUX0sIyyjIPU6280CIoXvR1seSYXUgiyncTNV6QxZrck/TWegXOEdNaupB1f0 y2FDagf6g+gxw== Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a870cad2633so477433966b.1 for ; Tue, 03 Sep 2024 08:17:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725376633; x=1725981433; 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=UlVqr8qfq0zm4LadiFaTT35TCbrEM7DrGylkId+7er0=; b=SGKN3N1zwQjLEPCZxyZJBuBXmfxuf8FLcNyk9a77/ttj/G8Xx4eUhkWVNyV6qEI9oO R32XNnKK5Sg6nu8XosUEuIrjhurAYAByxTAJRvWiaRPg8SVi/lmxwp0tSdq5cRw8WMza UDSlkydnAKC0iieON6/kPulfJSwFyQJ1YJ+HEvPUVk2itAbXgdv3UAiEBtsfd5mLOstn Hx6ntAfQBUxOBD8MQZFndwE/9PL2F96B9VsP1DyepCZTfxtZewParLc5uDbZ56ROyfnb r9z9ZcLo7lZwqfs9NCt2wpQkMfskQRTQXLJ3HsHJS1QFMwiwWTqXN+i32lCjs4yK7lkG o/KA== X-Forwarded-Encrypted: i=1; AJvYcCUHKSOlZ1f83nDom+5bHM7jmiaNQk4fHsZ9Zqo1wR3j3zeqx7DBhxKWJGqYjmRuZ29wMCzAOevxMnWA6Prm@vger.kernel.org X-Gm-Message-State: AOJu0YyQJ/VaRPNauLvVTX/aRx6NemWIZmh6hpKpflr/QZotWE4CLjmn RZ3usYW2C3+1Q+KmFh4rTkakLTnqmbxm+SQz0he/cN2T1/1pwMB4fMvE+lDX3LJCoI3hel4npkU tkkPp3OnZiNwtM5/nFCsQXWZHi2q1K5lmtyjSn/KnRkwKU6tlc4r7ibIt1bx6VHOERwh73/gwNY y0e8I= X-Received: by 2002:a17:907:9487:b0:a77:c30c:341 with SMTP id a640c23a62f3a-a897f1c3e3dmr1290755866b.0.1725376633315; Tue, 03 Sep 2024 08:17:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGL2gL9kVUAD7c/U4EREwo/0f6jUYuTiYlOJEoA7Rsdp22DZQmd9M2c7KMwQk3rXunkx2Y1ag== X-Received: by 2002:a17:907:9487:b0:a77:c30c:341 with SMTP id a640c23a62f3a-a897f1c3e3dmr1290754566b.0.1725376632859; Tue, 03 Sep 2024 08:17:12 -0700 (PDT) Received: from amikhalitsyn.. ([188.192.113.77]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a19afb108sm156377166b.223.2024.09.03.08.17.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 08:17:12 -0700 (PDT) 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 v4 11/15] fs/fuse: support idmapped ->rename op Date: Tue, 3 Sep 2024 17:16:22 +0200 Message-Id: <20240903151626.264609-12-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240903151626.264609-1-aleksandr.mikhalitsyn@canonical.com> References: <20240903151626.264609-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 RENAME_WHITEOUT is a special case of ->rename and we need to take idmappings into account there. Cc: Christian Brauner Cc: Seth Forshee Cc: Miklos Szeredi Cc: Amir Goldstein Cc: Bernd Schubert Cc: Signed-off-by: Alexander Mikhalitsyn --- v2: - this commit added v4: - support idmapped ->rename for RENAME_WHITEOUT --- fs/fuse/dir.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 08bf9cc51a65..d316223bd00b 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -1025,7 +1025,7 @@ static int fuse_rmdir(struct inode *dir, struct dentry *entry) return err; } -static int fuse_rename_common(struct inode *olddir, struct dentry *oldent, +static int fuse_rename_common(struct mnt_idmap *idmap, struct inode *olddir, struct dentry *oldent, struct inode *newdir, struct dentry *newent, unsigned int flags, int opcode, size_t argsize) { @@ -1046,7 +1046,7 @@ static int fuse_rename_common(struct inode *olddir, struct dentry *oldent, args.in_args[1].value = oldent->d_name.name; args.in_args[2].size = newent->d_name.len + 1; args.in_args[2].value = newent->d_name.name; - err = fuse_simple_request(NULL, fm, &args); + err = fuse_simple_request(idmap, fm, &args); if (!err) { /* ctime changes */ fuse_update_ctime(d_inode(oldent)); @@ -1092,7 +1092,8 @@ static int fuse_rename2(struct mnt_idmap *idmap, struct inode *olddir, if (fc->no_rename2 || fc->minor < 23) return -EINVAL; - err = fuse_rename_common(olddir, oldent, newdir, newent, flags, + err = fuse_rename_common((flags & RENAME_WHITEOUT) ? idmap : NULL, + olddir, oldent, newdir, newent, flags, FUSE_RENAME2, sizeof(struct fuse_rename2_in)); if (err == -ENOSYS) { @@ -1100,7 +1101,7 @@ static int fuse_rename2(struct mnt_idmap *idmap, struct inode *olddir, err = -EINVAL; } } else { - err = fuse_rename_common(olddir, oldent, newdir, newent, 0, + err = fuse_rename_common(NULL, olddir, oldent, newdir, newent, 0, FUSE_RENAME, sizeof(struct fuse_rename_in)); } From patchwork Tue Sep 3 15:16:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13788891 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 D8DC518BC36 for ; Tue, 3 Sep 2024 15:17:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376640; cv=none; b=H+lOiEB+8NyDYqJRb/PBfxC95UeTIWu22Py5GaWncUMYOzJGD5B8LxH0ea+Fuc/f2ok80Yx/WjY1BNofEHAwEGzyNKv3LL41m546Y4JdACmNwJO2emNUvl0l0WWNRLL6ybkNQIwIVWEKU9l7aEBs5GguTWIGHuzpPe3IxoPxVi4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376640; c=relaxed/simple; bh=fapDmbcyv3OV3L5MVJ0ESyKv76DKH2gIdDF3OBkCKmU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=l+rMk+IOmdObYZfOrxIa9Weupnc404tO+2a5Cf3+h8kjD8YGsTMqJE2TSzhlBbZoFiyeZBBDeEq8zhm1lzMwyAqizevat/1JbW1uidcE7pUpxV4EiR38JTQTFffikBMcwfs3wS90weFYkXH8NP2HbhRyMvH1RJktWs3CA5wPM10= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=H4ZFARnH; arc=none smtp.client-ip=185.125.188.123 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="H4ZFARnH" Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.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 A863E3F17E for ; Tue, 3 Sep 2024 15:17:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1725376636; bh=GKlPAS/yke2oPrCeB1Al+EppMQBQKIKtDOu8hv7kn/0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=H4ZFARnHvMUb3znZMjPpYmHQhTNQaF7qfl89vPcE1bVCOdNWksqhpeHu979HCgLa3 hhTkEBfRhJ12wtq4csPXmJx1zFFXDdNGeYXoAXhthw7rFOZ4ciXrbRYElocZmloApG 9JDcrIKVywSuV6ZA6YegcYEjQjNTFYB7PBB2IZtWllnSq9za9YktNuGwdqR9mvHlwR shhrQ8pZJNPIi9kXLlrR+z+q3FAoYUKkMpGfWF34vLWi9IkJ0LCrd/Ec3M+zWwlDcS nTaQl8LQtzTdNDmR9EB6N84SFUdhywXq0Et343T9JE9gIqrXyMA4d/WZbLLGX28j6K LgDvqMzIDZMpg== Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-5334af2a84fso5906489e87.1 for ; Tue, 03 Sep 2024 08:17:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725376636; x=1725981436; 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=GKlPAS/yke2oPrCeB1Al+EppMQBQKIKtDOu8hv7kn/0=; b=CAOeQH/wmhCAWP1yzH9Blqn32KcqBxF5+1qZEMZS4vRBgI10BX73ToPIj0T1lcpJfw TMQP/ShrO+0Br0FFwVAMRRqJV2PeYAaYP9npPRbzJP+0qBQ1caQyeWyzZxeieR+6+8f1 Y8WWjMl8RXNYu+wztm2xFK7hbArkOXo88ovZn5p6BmervLYVRe/toJwkTmEeyUxo85hb JzGOcrZLpmwWC98H8ijP3qOIPVTKMIeyd6159gmptWFUx2bAsOK7OA83ggPTW6kyLNzM dmVinJ1GYJDx+6COY1lMpdMlWA9mL14YmUgzg6nMaMw2YyA5c1ijp9F4Mq2ETJMv/UZa m5EQ== X-Forwarded-Encrypted: i=1; AJvYcCUpDcXeDFGcrjWBfv2xcEwWURdf/HFyuha1103kJl3WB7DGfr26Gt4I3GasdwcTtUeJKuXjd4MRFXaV3m6+@vger.kernel.org X-Gm-Message-State: AOJu0YxmQQk65QhmIZVLrPnY9/l4Azrt+1RpN2BFyXcETlzSdVxATwMd try/Dt/u+MYJ54BPl5USPXvSuhZ4EezfIsbkXtqXghpOfb2MZpfSzp5jZQzQ4dBP8D6k7YfTccQ p29LGZweQZzkLnwnVhcQnyNRgSu5jFxw4Tr3058t6kLgYXmGTeGFRPQilh3OOW2HdTKDA4gUY3O VSsDo= X-Received: by 2002:a05:6512:238a:b0:52c:e1cd:39b7 with SMTP id 2adb3069b0e04-53546afd6d3mr9430364e87.5.1725376635828; Tue, 03 Sep 2024 08:17:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7xyi4/WNe4j3fu5EFB8IE3ilwNISUZWJq2BDcXmtXsVDh9f1cWld/tjAcEfAzJ5I9AOVJcA== X-Received: by 2002:a05:6512:238a:b0:52c:e1cd:39b7 with SMTP id 2adb3069b0e04-53546afd6d3mr9430338e87.5.1725376635314; Tue, 03 Sep 2024 08:17:15 -0700 (PDT) Received: from amikhalitsyn.. ([188.192.113.77]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a19afb108sm156377166b.223.2024.09.03.08.17.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 08:17:14 -0700 (PDT) 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 v4 12/15] fs/fuse: handle idmappings properly in ->write_iter Date: Tue, 3 Sep 2024 17:16:23 +0200 Message-Id: <20240903151626.264609-13-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240903151626.264609-1-aleksandr.mikhalitsyn@canonical.com> References: <20240903151626.264609-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 --- v4: - this commit added --- fs/fuse/file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 06ff4742ab08..dffc476f0bf2 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1398,6 +1398,7 @@ static void fuse_dio_unlock(struct kiocb *iocb, bool exclusive) static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) { struct file *file = iocb->ki_filp; + struct mnt_idmap *idmap = file_mnt_idmap(file); struct address_space *mapping = file->f_mapping; ssize_t written = 0; struct inode *inode = mapping->host; @@ -1412,7 +1413,7 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) return err; if (fc->handle_killpriv_v2 && - setattr_should_drop_suidgid(&nop_mnt_idmap, + setattr_should_drop_suidgid(idmap, file_inode(file))) { goto writethrough; } From patchwork Tue Sep 3 15:16:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13788893 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 6F1FE194A74 for ; Tue, 3 Sep 2024 15:17:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376644; cv=none; b=RliGfm7xEVIQ74uIML0hjXGre3++/HAB5FpwpSQkMxow4UOB+NCZ8fbM05a4p9cGr0N2xfLtvrN8Os2zxhWlQPl3mSMwV7vUhfaHNJwguTo6eun9EBWMrGO78TR70Cfx9bn/0C4/dvalzMAQuRQj3mJm8xwspO7IYUtkAbnb0WE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376644; c=relaxed/simple; bh=n1q/EIb8QE/gzlW7TGaoEUxhlzstWKJksL6EQ5xdUDQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GQrIRc5VvAWTX5CJc1vQjBTi+LGHyZ2vZI35aZvhxPsXt3Llym+5aCWIVCz4KHRE+lUVSb/pDnLkvy62fbJH8DQrO9tUc66Qx69vi6KflEtzgvTtNvyB5UzcuMkOiBA4OW+ceqprSfz713Hs6S4/JPX5ddSHIMd234+ur3Ffhzc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=tANZBw5B; arc=none smtp.client-ip=185.125.188.123 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="tANZBw5B" 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 214433FB55 for ; Tue, 3 Sep 2024 15:17:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1725376641; bh=q/dJXF5eC+NKzBxw8fqNSmpQ4hPcGmLwxIIccnA2zek=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tANZBw5BR951V0tjNwoKsuCYGXFvAADclmIOKRfh4mAc9V6XqygI96+/3hwQFfqVZ iWK3AP1xGmUHwSi3ubmPRlMQM9OvTXCxoujZz+k3lQrZZyRjFZZSVVN4DFqchMYsYC RFifrzgq/cky5RMbsvQjz6Fd8FhGx6LHgz+BgjZ+PzEnkh3tLvi9gFi1y8EWxce/5/ MgKw9P30rpfXNhQkrUL/y6ZLwvhULr4q7jiWx+EsGCj6Iix1RGrVBpNOuDKQIZG6nD jk8Zie9OAU0KNPlBd/DvoFqEeF3i8FabPTGLlu70NvpIxaAmUtChH6JZy28RWzxcsM 2zB19K9FqQYGQ== Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-53436749138so5964769e87.2 for ; Tue, 03 Sep 2024 08:17:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725376638; x=1725981438; 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=q/dJXF5eC+NKzBxw8fqNSmpQ4hPcGmLwxIIccnA2zek=; b=dt7bAownsI8vapmIVTcAR9otAD4Nz6x3B7T9B2wCui2/Pn5HSzsxXNppeXWn5+MKwG ONQJEEd5X7XJKPUi1WGdOBuTFZ8w9R6FCW5Z0DpANbkR+/E06H06HJFqGaLny5+fT0/U bPW2EuOl9IIfa3bi8L2fAG09cf36w+tsuEACmm6Ok3VZBgVYO99o92Pft/VxBsOj0/Uo OZLvHhzuyG9rwal5mNcbhxtLJbv/4n0SR2XMsQMOAsKEh3WHWxoL0VpK7ZIRdAEOyOwI owgQFKSrMuMl+6MYAal4cSrj1FAVw907kQAB61mkZ+949seGNYoFfUdCyVC4j+YMSFKF IwVQ== X-Forwarded-Encrypted: i=1; AJvYcCV1umaK3X/hIJybRIjCnW88ufthxKb5aUvMS5TrLEZyOIbFVhyI0BiVf2sEKB11sDVfAzk8uAMm56xBTdLQ@vger.kernel.org X-Gm-Message-State: AOJu0YzxgMjxzMQbbAgW9xS8OQGPRfUstzHDFKsGmpdUe7j09+rVRzJ9 Jj+uFgfj6fwz9VwhcSGiNKKV5Nuei2fyUoQ4EfIhMaNRCaFiBhdAtGmu8Id3iGS6m10OmiPV6d7 4FvhHvvlYcux3De0Q7tRq5RdxeiDBJ7rXycWnBSD210Kgfx6k698cJjJKPMm9eYEW98VnGxujo3 1DAN0= X-Received: by 2002:a05:6512:12cb:b0:52c:8979:9627 with SMTP id 2adb3069b0e04-53546afaadamr9026103e87.3.1725376638412; Tue, 03 Sep 2024 08:17:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFGeAr4W1tnViv/aJ8AvVT1RQIyOxpEgki6TmTjrWHhDfkxMRoGBh6oqad2TrUHYX4xemgG9Q== X-Received: by 2002:a05:6512:12cb:b0:52c:8979:9627 with SMTP id 2adb3069b0e04-53546afaadamr9026067e87.3.1725376637915; Tue, 03 Sep 2024 08:17:17 -0700 (PDT) Received: from amikhalitsyn.. ([188.192.113.77]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a19afb108sm156377166b.223.2024.09.03.08.17.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 08:17:17 -0700 (PDT) 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 v4 13/15] fs/fuse: warn if fuse_access is called when idmapped mounts are allowed Date: Tue, 3 Sep 2024 17:16:24 +0200 Message-Id: <20240903151626.264609-14-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240903151626.264609-1-aleksandr.mikhalitsyn@canonical.com> References: <20240903151626.264609-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 is not possible with the current fuse code, but let's protect ourselves from regressions in the future. Cc: Christian Brauner Cc: Seth Forshee Cc: Miklos Szeredi Cc: Amir Goldstein Cc: Bernd Schubert Cc: Signed-off-by: Alexander Mikhalitsyn --- v4: - this commit added --- fs/fuse/dir.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index d316223bd00b..dd967402bf12 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -1473,6 +1473,14 @@ static int fuse_access(struct inode *inode, int mask) BUG_ON(mask & MAY_NOT_BLOCK); + /* + * We should not send FUSE_ACCESS to the userspace + * when idmapped mounts are enabled as for this case + * we have fc->default_permissions = 1 and access + * permission checks are done on the kernel side. + */ + WARN_ON_ONCE(!(fm->sb->s_iflags & SB_I_NOIDMAP)); + if (fm->fc->no_access) return 0; From patchwork Tue Sep 3 15:16:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13788892 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 2A9F8194A53 for ; Tue, 3 Sep 2024 15:17:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376644; cv=none; b=iSeNIXNG95saR7EeoqGyBHHTlTvd8XIMAZLJSwW7+vKU/OGlzBaOlXbSn/zEiVOHZWKc2ems9LjdpxsR2kiSrGsoO47YnimIlzIxjuAGcjg5P6nspgPksz6H928oUsu/ZTYTQDiBRcF1I2HhHAjzUGz7mdqv9EHZv5O7vqNa7Lw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376644; c=relaxed/simple; bh=ehliGmnl1/v4OS1SBQ/1Yg/WkwK3kW52iOkryOLCfho=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mA+O2ZpTV/3IJPZmzJnBoSQ4O5k9BzLumm8lnJ1cwCmvyL1Zl3r1xbdWaGm8TZgMB6Lp62reusRJFDod5rDM0vjeDJs9c66EVCWcCIZJb6B4sV+emMj3Jw8BT0+WCRualiDjBe8sNmF5wNVD3UXaZ9Iz461geHBiwzMEi84CnMk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=FMzhZ5fd; arc=none smtp.client-ip=185.125.188.123 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="FMzhZ5fd" Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.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 AF5AE400E1 for ; Tue, 3 Sep 2024 15:17:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1725376641; bh=0EwUiOf4L2/aseOZrM6YVYPxFzCl5APUlbrPGfv+97I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FMzhZ5fdMLpcaqZyivI941BaUfUrRwNqqMBvai9wiPMw66yfj/BDGgH6dBtlWbniu BiBo+QsO1xUSsRI25NPe0H44Eo9HJ9NaaHpegGtY16xFGt4O1WJgIIN35ffQ8xWiWQ SsLvAy5L9gUbwqioWL7EYR3bbYDhe0stCw4ZkC4vW8bVWLusnpyUXoIeNpwF00P7+Y xzP6ibhRmtX7o0VCXRr0JdLcIHCHVK0uPRvgCICiemDTk6nISRJKDDOu/MrFZi3llF OxB8WMbzJ/Ptw+4xgbCFwEHxasYXML5q1wPV0BUZuOkNiDhMNwQyonxUnQn3YHsfMg fuWI0KfQovHOg== Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a869ee1755fso428398866b.0 for ; Tue, 03 Sep 2024 08:17:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725376641; x=1725981441; 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=0EwUiOf4L2/aseOZrM6YVYPxFzCl5APUlbrPGfv+97I=; b=I7LkmxlaU0E/BfwHSxd6CZPX7cXzhHDBW9osLgvy5ub9uTtYTvr43Uz8Z24Fnu1Jb+ kwgQYXmu1Sc9yGsmouHBA2Vx5gASEYS0Ssn2CQNE1VPP1F9gfswWmz/9Xc6HAPW6Xf8k R6nC4Ng2INFjhjejsRle2eOUEMd0rpL0YVQgK9Ek18igz6UU1F7ZS7MVKBUy4TKNgSXp sh+WJnz29heaUsIz4id5I6WsvvFR0bO5q5RaRjKzDTZpX4NsS8EOKCWtpDdTeiVlFQRu 7jsUVh8LTJA2jv0QnzWlrP3cxlLl6eAo9pHnCYhOD0RNdJ2yvUMzROSfTyTn0UD9QQ3i Aq3Q== X-Forwarded-Encrypted: i=1; AJvYcCWI3J+yKH5CtJyDcP6fo7w8/hF2zoI5kBc2Thhwo5DVmxJouU6oEalPpXWGn54Krs25WmXXqiH9Gh8JtdtJ@vger.kernel.org X-Gm-Message-State: AOJu0YzDPLP4CuMqnOF/l/BFHu+kEuCcZ/c7zdHuJbMmbeArL9tcn7jk dvAX/T4g70mLKAjOPqhbV+gbXFfnUVvX7YkdR6JUPGbHOeF7Wr318vjgeQuqWk32KjpCqDp5OI2 R5G0YkFTEVmDb0OkddEyXBOfAuxj4zRRMPFLEK26ZB80/vFMymLWCnoZEgJALqX6sEkYUSbmnbR 15vCA= X-Received: by 2002:a17:906:6a05:b0:a7a:c106:364f with SMTP id a640c23a62f3a-a89d8848ef5mr664472866b.43.1725376641017; Tue, 03 Sep 2024 08:17:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFuhIDZFbjriLVnYlTwRiB6qVXiOIP9ae8CETX4GnhIzLIqUwYrJLE5OqCJ4zuyI2v2otWlOA== X-Received: by 2002:a17:906:6a05:b0:a7a:c106:364f with SMTP id a640c23a62f3a-a89d8848ef5mr664471266b.43.1725376640573; Tue, 03 Sep 2024 08:17:20 -0700 (PDT) Received: from amikhalitsyn.. ([188.192.113.77]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a19afb108sm156377166b.223.2024.09.03.08.17.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 08:17:20 -0700 (PDT) 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 v4 14/15] fs/fuse: allow idmapped mounts Date: Tue, 3 Sep 2024 17:16:25 +0200 Message-Id: <20240903151626.264609-15-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240903151626.264609-1-aleksandr.mikhalitsyn@canonical.com> References: <20240903151626.264609-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. 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 Reviewed-by: Christian Brauner --- v2: - simplified and get rid of ->allow_idmap global VFS callback v3: - now use a new SB_I_NOIDMAP flag v4: - small rebase changes --- fs/fuse/inode.c | 12 +++++++++--- include/uapi/linux/fuse.h | 20 +++++++++++++++++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 2e26810066e8..9f9456d3e466 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -1343,6 +1343,12 @@ static void process_init_reply(struct fuse_mount *fm, struct fuse_args *args, } if (flags & FUSE_NO_EXPORT_SUPPORT) fm->sb->s_export_op = &fuse_export_fid_operations; + if (flags & FUSE_ALLOW_IDMAP) { + if (fc->default_permissions) + fm->sb->s_iflags &= ~SB_I_NOIDMAP; + else + ok = false; + } } else { ra_pages = fc->max_read / PAGE_SIZE; fc->no_lock = 1; @@ -1390,7 +1396,7 @@ void fuse_send_init(struct fuse_mount *fm) 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_NO_EXPORT_SUPPORT | FUSE_HAS_RESEND; + FUSE_NO_EXPORT_SUPPORT | FUSE_HAS_RESEND | FUSE_ALLOW_IDMAP; #ifdef CONFIG_FUSE_DAX if (fm->fc->dax) flags |= FUSE_MAP_ALIGNMENT; @@ -1980,7 +1986,7 @@ static void fuse_kill_sb_anon(struct super_block *sb) 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, .kill_sb = fuse_kill_sb_anon, @@ -2001,7 +2007,7 @@ static struct file_system_type fuseblk_fs_type = { .init_fs_context = fuse_init_fs_context, .parameters = fuse_fs_parameters, .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 2ccf38181df2..f1e99458e29e 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h @@ -217,6 +217,9 @@ * - add backing_id to fuse_open_out, add FOPEN_PASSTHROUGH open flag * - add FUSE_NO_EXPORT_SUPPORT init flag * - add FUSE_NOTIFY_RESEND, add FUSE_HAS_RESEND init flag + * + * 7.41 + * - add FUSE_ALLOW_IDMAP */ #ifndef _LINUX_FUSE_H @@ -252,7 +255,7 @@ #define FUSE_KERNEL_VERSION 7 /** Minor version number of this interface */ -#define FUSE_KERNEL_MINOR_VERSION 40 +#define FUSE_KERNEL_MINOR_VERSION 41 /** The node ID of the root inode */ #define FUSE_ROOT_ID 1 @@ -421,6 +424,7 @@ struct fuse_file_lock { * FUSE_NO_EXPORT_SUPPORT: explicitly disable export support * FUSE_HAS_RESEND: kernel supports resending pending requests, and the high bit * of the request ID indicates resend requests + * FUSE_ALLOW_IDMAP: allow creation of idmapped mounts */ #define FUSE_ASYNC_READ (1 << 0) #define FUSE_POSIX_LOCKS (1 << 1) @@ -466,6 +470,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_ALLOW_IDMAP (1ULL << 40) /** * CUSE INIT request/reply flags @@ -984,6 +989,19 @@ struct fuse_fallocate_in { */ #define FUSE_UNIQUE_RESEND (1ULL << 63) +/** + * This value will be set by the kernel to + * (struct fuse_in_header).{uid,gid} fields in + * case when: + * - fuse daemon enabled FUSE_ALLOW_IDMAP + * - idmapping information is not available and uid/gid + * can not be mapped in accordance with an idmapping. + * + * Note: an idmapping information always available + * for inode creation operations like: + * FUSE_MKNOD, FUSE_SYMLINK, FUSE_MKDIR, FUSE_TMPFILE, + * FUSE_CREATE and FUSE_RENAME2 (with RENAME_WHITEOUT). + */ #define FUSE_INVALID_UIDGID ((uint32_t)(-1)) struct fuse_in_header { From patchwork Tue Sep 3 15:16:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13788894 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 86FE21990B3 for ; Tue, 3 Sep 2024 15:17:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.122 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376647; cv=none; b=s86mpquu/aWiFM7O833nJ9m0je2pd9D52bwhnc9LNhIFcZH+RklxKBGbMwBjcmZEox7FqnWtyLuFYEOGVxdF/4KbvIvyL+oWpmJJlRTqTqJPilITU4C4S15LW0oG7+tLKOtrlNyUXkweEC40XTVniYfqlzrEJEMm1Wyhz655F5Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376647; c=relaxed/simple; bh=I5Ej9tXxsELnQaLpNn7Un8jHm6ABGkNJE4SsL33oa8Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Bz7XZ/NdkX8PLW0APHWTQ8d7NaFZP3lD+XebxUb+g7bxLXNwEcsHMxEs+dIzDRqmYiBh1i06OP0NgzIoSAXAEOp0S49LRFuiVlNJZ/Bf2SH6NYcMZVnrlhXE6BQjEH9fkdUC5vnVlmVEV/nyKR5JpGntTc+4FTB8RoL7BhqTI3k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=OWMqMlUb; arc=none smtp.client-ip=185.125.188.122 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="OWMqMlUb" Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.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 E54763FE28 for ; Tue, 3 Sep 2024 15:17:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1725376644; bh=8g+CuHEOVaIi/oyMU4FT/dyfPKPOx4hjrvyEeKrnVIU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OWMqMlUbTfa646WlBogFxWZT13bkJUqeKkvfJwMQT9BXP+KMu28yHQ/Xrcbm4X1Z+ wyDUTG82PWoeAf3TFvkxXaBzX9KDBBfQ/Pby5ieJoYNOsNm8AY0mcADF6AzvmE3gx7 1zaLBM6i7qQZVIgyfY9EQC7gQwf7RCvySBGOgL8k+X16V8UBPmOlRJ2MVZPywssSQO 4PeB0R3e+Zi6F9lx4D6ugSD3vf5xlw8i9v5ZmYo90Ked8CZsVefa4HCSATNmmrOFU9 RBW/MNAyFSr2k48NYdydz0O0QL5I8x+joJf505rt64+dgPSTopn7Lbk42xfXahjanB yAa7s9Q3orB2g== Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-53445c8a9c8so889862e87.2 for ; Tue, 03 Sep 2024 08:17:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725376644; x=1725981444; 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=8g+CuHEOVaIi/oyMU4FT/dyfPKPOx4hjrvyEeKrnVIU=; b=UbWwQGoIvTm9EyO35IxNk/EDRUs9YKvIkIpjWiSO68IISfjWQ32bayv25EuKILngz2 yRhqnX1ohASBGZpp4jr7x+37ydy5DrbrYDfcQmOA0jwqnGKYeOTq3reyxzqlS0bPPIni WT+Q+IGg35CWbc7Ytv5kvcGggY34uOPMhSMUAV8Y8Hz8I8IsjGjvMyy4EZLKa6DOvlPV X9p6pMn5AQUt/7dNpbd7XSkGI8pHvKc1bpWxyaOTl2ZhfrsqdyrkUm2AM9CYfbaspVU0 M3hE2oHn9tZLytkpzKHXsm4zTY4fUxTiYFDOwYM4MEPeWpFLoq9RuNMgqjTehdrin72I 2s5g== X-Forwarded-Encrypted: i=1; AJvYcCXL0ZUWJP8s7RHhpV0BVLeR09Sa3pSG8JM5ldZJEJpV7ZqzOEf3telyrFTYM6t72vG9+cBiWw3i+T9qq6jl@vger.kernel.org X-Gm-Message-State: AOJu0Yx0v7h/47BA/jdD9tjNFsmZzY9f1QzY6TuRAD4zj0xjobbKhzAA 23Men51Ibw/W/R/vvwt4DgLvThYpRqmHQtWcD9f7RnryM5lQoWt3h9by3OXn6HR4HuTX9P8poY/ ACRBeT2jr9n5HMpfKQWxyIbPw/y1N+kmVE6pK9o/mLdCU292ve+jqRk/UqKYhLX2FTV0pB6r4Bc g37BE= X-Received: by 2002:a05:6512:3ca3:b0:52c:def3:44b with SMTP id 2adb3069b0e04-53546b2b5e7mr8720707e87.31.1725376643656; Tue, 03 Sep 2024 08:17:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF+bq1GZV9X9d7kfysJWIp+YqAiYHgnriynd3aEYFL4ojAqTYw0oKyoeFn1hFPXtYAGSanyXw== X-Received: by 2002:a05:6512:3ca3:b0:52c:def3:44b with SMTP id 2adb3069b0e04-53546b2b5e7mr8720683e87.31.1725376643137; Tue, 03 Sep 2024 08:17:23 -0700 (PDT) Received: from amikhalitsyn.. ([188.192.113.77]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a19afb108sm156377166b.223.2024.09.03.08.17.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 08:17:22 -0700 (PDT) From: Alexander Mikhalitsyn To: mszeredi@redhat.com Cc: brauner@kernel.org, stgraber@stgraber.org, linux-fsdevel@vger.kernel.org, Seth Forshee , Miklos Szeredi , Vivek Goyal , German Maglione , Amir Goldstein , Bernd Schubert , Alexander Mikhalitsyn , Stefan Hajnoczi , =?utf-8?q?Eugenio_P=C3=A9rez?= , linux-kernel@vger.kernel.org, virtualization@lists.linux.dev Subject: [PATCH v4 15/15] fs/fuse/virtio_fs: allow idmapped mounts Date: Tue, 3 Sep 2024 17:16:26 +0200 Message-Id: <20240903151626.264609-16-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240903151626.264609-1-aleksandr.mikhalitsyn@canonical.com> References: <20240903151626.264609-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 Allow idmapped mounts for virtiofs. It's absolutely safe as for virtiofs we have the same feature negotiation mechanism as for classical fuse filesystems. This does not affect any existing setups anyhow. virtiofsd support: https://gitlab.com/virtio-fs/virtiofsd/-/merge_requests/245 Cc: Christian Brauner Cc: Seth Forshee Cc: Miklos Szeredi Cc: Vivek Goyal Cc: German Maglione Cc: Amir Goldstein Cc: Bernd Schubert Cc: Signed-off-by: Alexander Mikhalitsyn Reviewed-by: Christian Brauner Reviewed-by: Stefan Hajnoczi --- v3: - this commit added --- fs/fuse/virtio_fs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c index dd5260141615..7e5bbaef6f76 100644 --- a/fs/fuse/virtio_fs.c +++ b/fs/fuse/virtio_fs.c @@ -1628,6 +1628,7 @@ static struct file_system_type virtio_fs_type = { .name = "virtiofs", .init_fs_context = virtio_fs_init_fs_context, .kill_sb = virtio_kill_sb, + .fs_flags = FS_ALLOW_IDMAP, }; static int virtio_fs_uevent(const struct kobject *kobj, struct kobj_uevent_env *env)