History

ceph: handle idmapped mounts in create_request_message()

Inode operations that create a new filesystem object such as ->mknod, ->create, ->mkdir() and others don't take a {g,u}id argument explicitly. Instead the caller's fs{g,u}id is used for the {g,u}id of the new filesystem object. In order to ensure that the correct {g,u}id is used map the caller's fs{g,u}id for creation requests. This doesn't require complex changes. It suffices to pass in the relevant idmapping recorded in the request message. If this request message was triggered from an inode operation that creates filesystem objects it will have passed down the relevant idmaping. If this is a request message that was triggered from an inode operation that doens't need to take idmappings into account the initial idmapping is passed down which is an identity mapping. This change uses a new cephfs protocol extension CEPHFS_FEATURE_HAS_OWNER_UIDGID which adds two new fields (owner_{u,g}id) to the request head structure. So, we need to ensure that MDS supports it otherwise we need to fail any IO that comes through an idmapped mount because we can't process it in a proper way. MDS server without such an extension will use caller_{u,g}id fields to set a new inode owner UID/GID which is incorrect because caller_{u,g}id values are unmapped. At the same time we can't map these fields with an idmapping as it can break UID/GID-based permission checks logic on the MDS side. This problem was described with a lot of details at [1], [2]. [1] https://lore.kernel.org/lkml/CAEivzxfw1fHO2TFA4dx3u23ZKK6Q+EThfzuibrhA3RKM=ZOYLg@mail.gmail.com/ [2] https://lore.kernel.org/all/20220104140414.155198-3-brauner@kernel.org/

Christian Brauner committed 3 years ago

Commit 5ccd8531 parent 9c2df223 files · +65 −6Browse files

Showing the changes to include/linux/ceph (1 of 3 files). Show all

Unified · Split

include/linux/ceph/ceph_fs.h+9−1
@@ -357,6 +357,11 @@ enum { · 356 unmodified lines
357357 CEPH_MDS_OP_RENAMESNAP = 0x01403,
358358 };
359359
360+#define IS_CEPH_MDS_OP_NEWINODE(op) (op == CEPH_MDS_OP_CREATE || \
361+ op == CEPH_MDS_OP_MKNOD || \
362+ op == CEPH_MDS_OP_MKDIR || \
363+ op == CEPH_MDS_OP_SYMLINK)
364+
360365 extern const char *ceph_mds_op_name(int op);
361366
362367 #define CEPH_SETATTR_MODE (1 << 0)
@@ -497,7 +502,7 @@ struct ceph_mds_request_head_legacy { · 134 unmodified lines
497502 union ceph_mds_request_args args;
498503 } __attribute__ ((packed));
499504
500−#define CEPH_MDS_REQUEST_HEAD_VERSION 2
505+#define CEPH_MDS_REQUEST_HEAD_VERSION 3
501506
502507 struct ceph_mds_request_head_old {
503508 __le16 version; /* struct version */
@@ -528,6 +533,9 @@ struct ceph_mds_request_head { · 24 unmodified lines
528533
529534 __le32 ext_num_retry; /* new count retry attempts */
530535 __le32 ext_num_fwd; /* new count fwd attempts */
536+
537+ __le32 struct_len; /* to store size of struct ceph_mds_request_head */
538+ __le32 owner_uid, owner_gid; /* used for OPs which create inodes */
531539 } __attribute__ ((packed));
532540
533541 /* cap/lease release record */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t