Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp3021701rwb; Mon, 7 Aug 2023 07:10:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE8Ahmx7p41mvbwb9kxWl1cMYRH2PvX88JT/eCT9H+v0aMubiN1mj38F0dxt1Stj06q+WR6 X-Received: by 2002:a05:6a20:13d8:b0:133:2a73:fdd5 with SMTP id ho24-20020a056a2013d800b001332a73fdd5mr8180107pzc.32.1691417405804; Mon, 07 Aug 2023 07:10:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691417405; cv=none; d=google.com; s=arc-20160816; b=a/bQ1ilD+sJGEpnxdxKQFe8VKzpV5qZQBD+eZFOB8DaQyBljXrBwRw8mcSdrakCUtT GQ9WHxW8dPG67ECXAaJg1NxR+6U5Ny5dxBaIl9ZVO7/qgHE7EpxZ9yPry855dYctWlfm Vs6Z9L7EXkd+bU2OuIsY9SWExnxHCm6q+KTlWa0orOnhnYoSbq8y6HrIt32HvwnF1IaE 3xog6Kf+JYbMAVBZqwcLiiUOBP5xXrfhhJ0alk26pFYcLb6b/FTU5dMzGUACVmbY33O8 OjBFEsnLqWIjsZSIm8rDn0GQxMA91MZnVGaPvjy2/xby6fkP4RZQ0yMWT2nuSPz9J3TJ +gYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CQAHRH/ms/cFOl3S4jtiakCJJYzaMB08Yq0KPV8/UVY=; fh=Z2mkFIQPI1atT1PXylFFs5aXkUtGzwkgwqJaEftWDsI=; b=EoOxWfkAwv2iJtu7jWjkZ4Tjcl5/msAwbEJ0D4iV8wIbOEpG3nnjQYA01JyksvNMKw WogDWYNozWd50q80gG/GrSyKuQiTZNWGj7bXKCuAFJ6E0nvLvjfgMVZLFMx7dRIn44AH HMJhRNR2X2edn91d/kGg6LLr4y2n4jyy0xY9pbc0pNvmYPOZwFIkKgYMYmjtM1SOwqYw vkwDKY7jhw9f9iZoQAUeUn72oT10Sd1iqvKcPHs8s9HWxOMQb+3FvoW7VUKJwiNZCd76 qDOPh470XeJY5ndmW+03SlHk7BmDzdbI1ZD11qbIHOteiy6+M72Tq2yqUJxHC36hGprK PI0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b="wQ1hU/pp"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d5-20020a170902654500b001b682a513desi5824402pln.400.2023.08.07.07.09.52; Mon, 07 Aug 2023 07:10:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b="wQ1hU/pp"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233967AbjHGNa6 (ORCPT + 99 others); Mon, 7 Aug 2023 09:30:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234256AbjHGNam (ORCPT ); Mon, 7 Aug 2023 09:30:42 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32FA319B9 for ; Mon, 7 Aug 2023 06:29:46 -0700 (PDT) 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-0.canonical.com (Postfix) with ESMTPS id BEB8944284 for ; Mon, 7 Aug 2023 13:28:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691414909; bh=CQAHRH/ms/cFOl3S4jtiakCJJYzaMB08Yq0KPV8/UVY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=wQ1hU/ppKY7wcxL7+1DWkdjyQPUulMHa/ItrbOMcJBRnYdtkPwFl+O/ByVMPamc2B d6++rk0yp5CQkMYdqRc5cxFYJNUsy56OQl3ZXZnu4pfoTCk43WD9po1NDCcVgwlW0o IyR4A08xXl4uP7kmA/anf9HoLbRVMVZhdYLx72CbWt4et1XiENgEN/3zZQ1BJzowa1 KsSdA0hkDDBsyN5apkYGYCKhYVtkmCJmppFRq6g+hzmI7uFJnMvBLLW6se8OwOYfLz r3lHsNgO85FmVPW0vFvyR6TbHSPqMmwLMJKpWL+k7U7B23Bxr27g3RRRHYold5gZUR +jAmueKqVPYqA== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-99beea69484so344969766b.0 for ; Mon, 07 Aug 2023 06:28:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691414909; x=1692019709; 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=CQAHRH/ms/cFOl3S4jtiakCJJYzaMB08Yq0KPV8/UVY=; b=MaJNK8yWOXdZvBtseO+tUDYNu69WwNfe8aciP8N1fucsMt4ICff/y3Dv1cLzWzTwst zo3472quxqowzBY0GuhnhxSjijaK0knSDcXxXW4aC5uBLVFEtjOD1JLXIkO/KEnTKJLV V+tzCKqsYSIhWqOqylRZb5hA8e9xaH5d6iT6nrs+v+FwWcRa57Jo6J0Q/1y0guV8j+st 2rOJ2HX0jgZv8TlwnXweCOHqpwodcOyuhD9pgct9OwI4Gqz0+OnwraKjfY9tiKc323mI bAiF2wHsUue4dB0U6CRU31xc9hIjLm9jwg1Qk4JVI1KuMAVL/xiVrIgnuCWE/rb7x7nz wgQA== X-Gm-Message-State: AOJu0YzTQzOLQ6BPIH0fMj7XYs+zlSUF9KnYxgf/ZgVTI4u9ON1qfLIj sHETUpRD8u5bOqZzvX9NdKkcmNgrd6lq3HekJeGotFVY2+7LTDGOWkKsrnbqtSg5XzYXctG7CPA 83mlzBUXqe+m6ACr0SGVBHy7j1SHFhibsRnDwf1FPoQ== X-Received: by 2002:a17:906:41:b0:99c:47a:8bcd with SMTP id 1-20020a170906004100b0099c047a8bcdmr9099861ejg.67.1691414909457; Mon, 07 Aug 2023 06:28:29 -0700 (PDT) X-Received: by 2002:a17:906:41:b0:99c:47a:8bcd with SMTP id 1-20020a170906004100b0099c047a8bcdmr9099847ejg.67.1691414909294; Mon, 07 Aug 2023 06:28:29 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 06:28:29 -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 09/12] ceph: allow idmapped setattr inode op Date: Mon, 7 Aug 2023 15:26:23 +0200 Message-Id: <20230807132626.182101-10-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-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christian Brauner Enable __ceph_setattr() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner [ adapted to b27c82e12965 ("attr: port attribute changes to new types") ] Signed-off-by: Alexander Mikhalitsyn --- v4: - introduced fsuid/fsgid local variables v3: - reworked as Christian suggested here: https://lore.kernel.org/lkml/20230602-vorzeichen-praktikum-f17931692301@brauner/ --- fs/ceph/inode.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 6c4cc009d819..0a8cc0327f85 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2553,33 +2553,37 @@ int __ceph_setattr(struct mnt_idmap *idmap, struct inode *inode, #endif /* CONFIG_FS_ENCRYPTION */ if (ia_valid & ATTR_UID) { + kuid_t fsuid = from_vfsuid(idmap, i_user_ns(inode), attr->ia_vfsuid); + doutc(cl, "%p %llx.%llx uid %d -> %d\n", inode, ceph_vinop(inode), from_kuid(&init_user_ns, inode->i_uid), from_kuid(&init_user_ns, attr->ia_uid)); if (issued & CEPH_CAP_AUTH_EXCL) { - inode->i_uid = attr->ia_uid; + inode->i_uid = fsuid; dirtied |= CEPH_CAP_AUTH_EXCL; } else if ((issued & CEPH_CAP_AUTH_SHARED) == 0 || - !uid_eq(attr->ia_uid, inode->i_uid)) { + !uid_eq(fsuid, inode->i_uid)) { req->r_args.setattr.uid = cpu_to_le32( - from_kuid(&init_user_ns, attr->ia_uid)); + from_kuid(&init_user_ns, fsuid)); mask |= CEPH_SETATTR_UID; release |= CEPH_CAP_AUTH_SHARED; } } if (ia_valid & ATTR_GID) { + kgid_t fsgid = from_vfsgid(idmap, i_user_ns(inode), attr->ia_vfsgid); + doutc(cl, "%p %llx.%llx gid %d -> %d\n", inode, ceph_vinop(inode), from_kgid(&init_user_ns, inode->i_gid), from_kgid(&init_user_ns, attr->ia_gid)); if (issued & CEPH_CAP_AUTH_EXCL) { - inode->i_gid = attr->ia_gid; + inode->i_gid = fsgid; dirtied |= CEPH_CAP_AUTH_EXCL; } else if ((issued & CEPH_CAP_AUTH_SHARED) == 0 || - !gid_eq(attr->ia_gid, inode->i_gid)) { + !gid_eq(fsgid, inode->i_gid)) { req->r_args.setattr.gid = cpu_to_le32( - from_kgid(&init_user_ns, attr->ia_gid)); + from_kgid(&init_user_ns, fsgid)); mask |= CEPH_SETATTR_GID; release |= CEPH_CAP_AUTH_SHARED; } @@ -2807,7 +2811,7 @@ int ceph_setattr(struct mnt_idmap *idmap, struct dentry *dentry, if (err) return err; - err = setattr_prepare(&nop_mnt_idmap, dentry, attr); + err = setattr_prepare(idmap, dentry, attr); if (err != 0) return err; @@ -2822,7 +2826,7 @@ int ceph_setattr(struct mnt_idmap *idmap, struct dentry *dentry, err = __ceph_setattr(idmap, inode, attr, NULL); if (err >= 0 && (attr->ia_valid & ATTR_MODE)) - err = posix_acl_chmod(&nop_mnt_idmap, dentry, attr->ia_mode); + err = posix_acl_chmod(idmap, dentry, attr->ia_mode); return err; } -- 2.34.1