Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp885327rwd; Thu, 8 Jun 2023 09:01:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4BqHX9uAszfdFFOo0L1REW2WaMEH8YKbZjSxuAXTZGNk2eoKAWe5XixXZB401YyovQWy/6 X-Received: by 2002:a17:903:1207:b0:1aa:feca:b616 with SMTP id l7-20020a170903120700b001aafecab616mr7787960plh.65.1686240109331; Thu, 08 Jun 2023 09:01:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686240109; cv=none; d=google.com; s=arc-20160816; b=LNsM3SS9nOt8B9rh3N0oAqxFvXHlSd1jtx95qhIfgU5NBlLaBSslf61BJ0mtcoanot jb/d7wS/UlqaTmEwASQBjN0MixCG9p/sqvtKtCVYJ5Jm2dczi1l87f/9rmB2VMdqS+6b ANeCTJ2xB2TtaJwl1lipJTXrY6zgTTweK1w3U9B3umLobMyvC7ocuv/hMHoWU0Xu1vQA Jwm7dmD2m2fx3tm/LJoaKe3nux9Cy1Dq46hCxnfb+1hM2ZtqQ9AlwYyuAvJpSaV1t1yD RlInmxvjttljnhlFc5HECNoBnh3wV1jgy49Dv8TRal3sLAK3LXC69vuTQXK4u79Kg25a s/Ig== 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=gghyNGCh9Nhwv51CwrkrRVAEuotD0ib4eCZetw54L9Q=; b=IyoMpUVLN/3Ttrq/2asFwDSGdDRtOU/TuWTpqVTCmovZwJcED8nClrrPt686dFi7v4 0qWPS8BJ22pv4wBwXkKVM0df1VJCPeVu/Q7I8FY+li4e4X+qipqnYOiUedI9+/EsS0Ur sjVpc9125k5BQ3JdL7BtxbOxDmR1ahri1VjC1YM4d0c/lNOl1eN/4xYAI0qJ8vItnvpG JJfhgfR/JiSg8PXT8be292NHmz1pHY9sxZa5WLHcXd8r3QfSGUKX32TpwIzVVW1tKrtr 3LzoMn9fpJ0UpjP4vGx3D4eTQAtxEMlfSnsfFkm0daCE0C1jrtMKa8lB57U/3hJNVzAZ Pd+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=TtS9Bh64; 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 n7-20020a170902e54700b001adf26a9390si1287986plf.191.2023.06.08.09.01.34; Thu, 08 Jun 2023 09:01:49 -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=TtS9Bh64; 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 S237365AbjFHPoi (ORCPT + 99 others); Thu, 8 Jun 2023 11:44:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237236AbjFHPoR (ORCPT ); Thu, 8 Jun 2023 11:44:17 -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 BB10B30C8 for ; Thu, 8 Jun 2023 08:43:51 -0700 (PDT) Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id C32F03F374 for ; Thu, 8 Jun 2023 15:43:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686239022; bh=gghyNGCh9Nhwv51CwrkrRVAEuotD0ib4eCZetw54L9Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TtS9Bh644+5q0boodMQLUJ4lTBcUTjo9TteChfFF9hij/Y9chzQAQspjQE6avG+9X N+hV8WeWvPcuVo19hYohumj1sHWZ7YusJWHw56wtRQNPT+u5iD/L+e9uyZVDgli9h6 pGhdrtWe24hIj6gqvswg5lNHZa1L6e3iX8B4Kjet+rF50BoExtCK+c1gRfis//Cr0Y wA+fFGEQhhUL+NgdY0EPrebF8zccAQSuFow0UW9S6sT7rpRl25r8yCDUwUu+oPE8JI 94ltbnnVNOh4fdCAup3DnO/3QgdLFCMfD4KQfaJ+Hhbnh9ZJhcLpKnqALsxSqqaMBP bgKc0JbZfqq8g== Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-50ddef368e4so706575a12.0 for ; Thu, 08 Jun 2023 08:43:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686239022; x=1688831022; 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=gghyNGCh9Nhwv51CwrkrRVAEuotD0ib4eCZetw54L9Q=; b=TwUvzty3w/KJB0FnJz1WPdjh9W1bfJwJJHZdaZf3TWVZHrCuew7RnFPfz3HwPaZtLR qCs5x+0J9xVLPnwoATB0/5Vqe56+MG/0x5jjGQTU7w/B0RWwXBVNYtMok1MnM8fjzk39 puifV91VHPa898sQWitMXc0qAnM+/HQAhf0jYYFlpxcJJVyrR2pT0yFbnw2v6B/66O4y Ldmkh1T4KkK4+l3maNCUSs2EiHZZDOs6AGw1Kz+UWRgcaO5psIwimZ51eOPT70WDaVIJ uiJXfvN5QBCOBzOwBWx7rBOXR/N6xecx3/nlqEVtjDcFIuR8xnk8LYwI+Mhd4oR58Tbe ZNdA== X-Gm-Message-State: AC+VfDybK8vO9RJOj1nH6/UbRxvwt2KM8NE7K0rer62QjwkJLbU1pl5U k4CKeNXF3rK8m0XErGRU1r7GgIZSiLNTPf5dl6MVI6uqL57nAK7UqNeQ/tb0IJJ7aRSHwd9pxf+ hJmDlKDqcrmRLLJMCcD/SaPUGNqX42p4QsdC57sc70A== X-Received: by 2002:a05:6402:2cc:b0:514:ae18:1637 with SMTP id b12-20020a05640202cc00b00514ae181637mr7681215edx.23.1686239022298; Thu, 08 Jun 2023 08:43:42 -0700 (PDT) X-Received: by 2002:a05:6402:2cc:b0:514:ae18:1637 with SMTP id b12-20020a05640202cc00b00514ae181637mr7681197edx.23.1686239022090; Thu, 08 Jun 2023 08:43:42 -0700 (PDT) Received: from amikhalitsyn.local (dslb-002-205-064-187.002.205.pools.vodafone-ip.de. [2.205.64.187]) by smtp.gmail.com with ESMTPSA id y8-20020aa7c248000000b005164ae1c482sm678387edo.11.2023.06.08.08.43.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 08:43:41 -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, Christian Brauner , Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v5 08/14] ceph: allow idmapped setattr inode op Date: Thu, 8 Jun 2023 17:42:49 +0200 Message-Id: <20230608154256.562906-9-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> References: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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.kern --- 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 bface707c9bb..58ec603a55af 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2052,31 +2052,35 @@ int __ceph_setattr(struct mnt_idmap *idmap, struct inode *inode, dout("setattr %p issued %s\n", inode, ceph_cap_string(issued)); if (ia_valid & ATTR_UID) { + kuid_t fsuid = from_vfsuid(idmap, i_user_ns(inode), attr->ia_vfsuid); + dout("setattr %p uid %d -> %d\n", 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); + dout("setattr %p gid %d -> %d\n", 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; } @@ -2242,7 +2246,7 @@ int ceph_setattr(struct mnt_idmap *idmap, struct dentry *dentry, if (ceph_inode_is_shutdown(inode)) return -ESTALE; - err = setattr_prepare(&nop_mnt_idmap, dentry, attr); + err = setattr_prepare(idmap, dentry, attr); if (err != 0) return err; @@ -2257,7 +2261,7 @@ int ceph_setattr(struct mnt_idmap *idmap, struct dentry *dentry, err = __ceph_setattr(idmap, inode, attr); 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