From nobody Tue Sep 9 22:29:19 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DA33C001DB for ; Mon, 7 Aug 2023 13:29:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234223AbjHGN33 (ORCPT ); Mon, 7 Aug 2023 09:29:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234104AbjHGN3O (ORCPT ); Mon, 7 Aug 2023 09:29:14 -0400 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 443012102 for ; Mon, 7 Aug 2023 06:28:51 -0700 (PDT) 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 3DB1B417B9 for ; Mon, 7 Aug 2023 13:28:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691414891; bh=9n6Y3+R2z8MxgQphIes473oPxL5sL8PFIQL+RUTLs6I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=m4qhKaTImBND8WcuT2ePvUE9SDmU/9xC+DMM6b6agp1PfWK+4M5QX6tqAei19opL8 4YZ6E3TlUoP5M3BKJApBR/7cXAaKtk34tK1cszvtvfunqnZI/w00K0jXWrf2b+Ne3+ PQJWKgap38TAqnN8tul3jHX5lSTgCJjjX0TP7mqYxYt/0BwTA3Z+RSqyjg1RMXmes3 MEnQFx8B9laGDzxT++6cLlqK3npATjXC9uRHZGsuXkw5r52xyKRCb2aHlVfpnvTMQB +4i+5qRFUmgv7yArprYEAxfbUIvm3gt+kEGBLSmdG4CIlFYp/vrSfUE0E6U36052d0 KhSHm+5vx6b5Q== Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-94a34a0b75eso300606766b.1 for ; Mon, 07 Aug 2023 06:28:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691414891; x=1692019691; 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=9n6Y3+R2z8MxgQphIes473oPxL5sL8PFIQL+RUTLs6I=; b=cCuHsfIKC1dIUPmABGvnq3Llte1J5h1ExBHDVYNM/21Pb/UmtkkQfoZ12MFfk6AlBO JOHYzmGGvXLYUhp8uvWCuidFoM4/Eb6BW4CBhe5V+sRyjLDkxMs5Nocj37767EqwZKSj vr8xr7AFuL0O2oEK4xKQtBeNKemWKERWGpZnZBkBHjjv5Sajr1ib5jxVIXda4N26kB0m v6pKGi22T3Z7Igrp9CECwUpZago8PyKZSPc4XBVfCS+lrLh3rF6zrYQQssKyuei94Dbf 2V0pfs1kgERvHq7eI05kFwLyQnJUZxkctI9MCGvO3hexmbZd2irqQo86LCR4TykMO7QP iuZw== X-Gm-Message-State: AOJu0YxoUDosk58zR86mJtMfQGik12Ykj7HS9CHokwPPkMREoTbQ3cNj Vh0v56qUD5gtP5Y5zlrcCcjveBa3BcDoNPRNsTYVOh4Cp6wSSkyM1PVvnFUgBzqUeYVHClzjaqS M0AYZzd3x4cCxc0w4bi7lxtgih5DtTS/zpwzt6plivA== X-Received: by 2002:a17:907:2c44:b0:99c:825:6076 with SMTP id hf4-20020a1709072c4400b0099c08256076mr6544992ejc.35.1691414890933; Mon, 07 Aug 2023 06:28:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEBU4i6R38ul+frqeZevZOxWpLNRxj0oiRwvcU1y4whm1La4MwJf9y9wAgsB1yXAlivGYfFGw== X-Received: by 2002:a17:907:2c44:b0:99c:825:6076 with SMTP id hf4-20020a1709072c4400b0099c08256076mr6544975ejc.35.1691414890543; Mon, 07 Aug 2023 06:28:10 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-066-182-192.088.066.pools.vodafone-ip.de. [88.66.182.192]) by smtp.gmail.com with ESMTPSA id lg12-20020a170906f88c00b00992ca779f42sm5175257ejb.97.2023.08.07.06.28.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 06:28:10 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v10 04/12] ceph: add enable_unsafe_idmap module parameter Date: Mon, 7 Aug 2023 15:26:18 +0200 Message-Id: <20230807132626.182101-5-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807132626.182101-1-aleksandr.mikhalitsyn@canonical.com> References: <20230807132626.182101-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This parameter is used to decide if we allow to perform IO on idmapped mount in case when MDS lacks support of CEPHFS_FEATURE_HAS_OWNER_UIDGID feature. In this case we can't properly handle MDS permission checks and if UID/GID-based restrictions are enabled on the MDS side then IO requests which go through an idmapped mount may fail with -EACCESS/-EPERM. Fortunately, for most of users it's not a case and everything should work fine. But we put work "unsafe" in the module parameter name to warn users about possible problems with this feature and encourage update of cephfs MDS. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Suggested-by: St=C3=A9phane Graber Signed-off-by: Alexander Mikhalitsyn Acked-by: Christian Brauner --- fs/ceph/mds_client.c | 28 +++++++++++++++++++++------- fs/ceph/mds_client.h | 2 ++ fs/ceph/super.c | 5 +++++ 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 5114de5ea65e..90c4b0689cd6 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -2949,6 +2949,8 @@ static struct ceph_msg *create_request_message(struct= ceph_mds_session *session, int ret; bool legacy =3D !(session->s_con.peer_features & CEPH_FEATURE_FS_BTIME); u16 request_head_version =3D mds_supported_head_version(session); + kuid_t caller_fsuid =3D req->r_cred->fsuid; + kgid_t caller_fsgid =3D req->r_cred->fsgid; =20 ret =3D set_request_path_attr(mdsc, req->r_inode, req->r_dentry, req->r_parent, req->r_path1, req->r_ino1.ino, @@ -3046,12 +3048,24 @@ static struct ceph_msg *create_request_message(stru= ct ceph_mds_session *session, !test_bit(CEPHFS_FEATURE_HAS_OWNER_UIDGID, &session->s_features)) { WARN_ON_ONCE(!IS_CEPH_MDS_OP_NEWINODE(req->r_op)); =20 - pr_err_ratelimited_client(cl, - "idmapped mount is used and CEPHFS_FEATURE_HAS_OWNER_UIDGID" - " is not supported by MDS. Fail request with -EIO.\n"); + if (enable_unsafe_idmap) { + pr_warn_once_client(cl, + "idmapped mount is used and CEPHFS_FEATURE_HAS_OWNER_UIDGID" + " is not supported by MDS. UID/GID-based restrictions may" + " not work properly.\n"); =20 - ret =3D -EIO; - goto out_err; + caller_fsuid =3D from_vfsuid(req->r_mnt_idmap, &init_user_ns, + VFSUIDT_INIT(req->r_cred->fsuid)); + caller_fsgid =3D from_vfsgid(req->r_mnt_idmap, &init_user_ns, + VFSGIDT_INIT(req->r_cred->fsgid)); + } else { + pr_err_ratelimited_client(cl, + "idmapped mount is used and CEPHFS_FEATURE_HAS_OWNER_UIDGID" + " is not supported by MDS. Fail request with -EIO.\n"); + + ret =3D -EIO; + goto out_err; + } } =20 /* @@ -3103,9 +3117,9 @@ static struct ceph_msg *create_request_message(struct= ceph_mds_session *session, lhead->mdsmap_epoch =3D cpu_to_le32(mdsc->mdsmap->m_epoch); lhead->op =3D cpu_to_le32(req->r_op); lhead->caller_uid =3D cpu_to_le32(from_kuid(&init_user_ns, - req->r_cred->fsuid)); + caller_fsuid)); lhead->caller_gid =3D cpu_to_le32(from_kgid(&init_user_ns, - req->r_cred->fsgid)); + caller_fsgid)); lhead->ino =3D cpu_to_le64(req->r_deleg_ino); lhead->args =3D req->r_args; =20 diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h index 8f683e8203bd..0945ae4cf3c5 100644 --- a/fs/ceph/mds_client.h +++ b/fs/ceph/mds_client.h @@ -619,4 +619,6 @@ static inline int ceph_wait_on_async_create(struct inod= e *inode) extern int ceph_wait_on_conflict_unlink(struct dentry *dentry); extern u64 ceph_get_deleg_ino(struct ceph_mds_session *session); extern int ceph_restore_deleg_ino(struct ceph_mds_session *session, u64 in= o); + +extern bool enable_unsafe_idmap; #endif diff --git a/fs/ceph/super.c b/fs/ceph/super.c index 49fd17fbba9f..18bfdfd48cef 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c @@ -1680,6 +1680,11 @@ static const struct kernel_param_ops param_ops_mount= _syntax =3D { module_param_cb(mount_syntax_v1, ¶m_ops_mount_syntax, &mount_support, = 0444); module_param_cb(mount_syntax_v2, ¶m_ops_mount_syntax, &mount_support, = 0444); =20 +bool enable_unsafe_idmap =3D false; +module_param(enable_unsafe_idmap, bool, 0644); +MODULE_PARM_DESC(enable_unsafe_idmap, + "Allow to use idmapped mounts with MDS without CEPHFS_FEATURE_HAS_OWNER= _UIDGID"); + module_init(init_ceph); module_exit(exit_ceph); =20 --=20 2.34.1