Skip to contentSkip to conversation

ceph: fix kernel crash in ceph_open()

PATCH Superseded Viacheslav Dubeyko 4 participants 18 messages Dec 15, 2025 – Dec 22, 2025

Subsystems (3)

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Viacheslav Dubeyko

author maintainer
#0 lore raw

PATCH v2 1/1 ceph: fix kernel crash in ceph_open()

From: Viacheslav Dubeyko <[email protected]>

The CephFS kernel client has regression starting from 6.18-rc1.

sudo ./check -g quick
FSTYP -- ceph
PLATFORM -- Linux/x86_64 ceph-0005 6.18.0-rc5+ #52 SMP PREEMPT_DYNAMIC Fri

Nov 14 11:26:14 PST 2025

MKFS_OPTIONS -- 192.168.1.213:3300:/scratch
MOUNT_OPTIONS -- -o name=admin,ms_mode=secure 192.168.1.213:3300:/scratch /mnt/cephfs/scratch

Killed

Nov 14 11:48:10 ceph-0005 kernel: [  154.723902] libceph: mon0
(2)192.168.1.213:3300 session established
Nov 14 11:48:10 ceph-0005 kernel: [  154.727225] libceph: client167616
Nov 14 11:48:11 ceph-0005 kernel: [  155.087260] BUG: kernel NULL pointer
dereference, address: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.087756] #PF: supervisor read access in
kernel mode
Nov 14 11:48:11 ceph-0005 kernel: [  155.088043] #PF: error_code(0x0000) - not-
present page
Nov 14 11:48:11 ceph-0005 kernel: [  155.088302] PGD 0 P4D 0
Nov 14 11:48:11 ceph-0005 kernel: [  155.088688] Oops: Oops: 0000 [#1] SMP KASAN
NOPTI
Nov 14 11:48:11 ceph-0005 kernel: [  155.090080] CPU: 4 UID: 0 PID: 3453 Comm:
xfs_io Not tainted 6.18.0-rc5+ #52 PREEMPT(voluntary)
Nov 14 11:48:11 ceph-0005 kernel: [  155.091245] Hardware name: QEMU Standard PC
(i440FX + PIIX, 1996), BIOS 1.17.0-5.fc42 04/01/2014
Nov 14 11:48:11 ceph-0005 kernel: [  155.092103] RIP: 0010:strcmp+0x1c/0x40
Nov 14 11:48:11 ceph-0005 kernel: [  155.092493] Code: 90 90 90 90 90 90 90 90
90 90 90 90 90 90 31 c0 eb 14 66 66 2e 0f 1f 84 00 00 00 00 00 90 48 83 c0 01 84
d2 74 19 0f b6 14 07 <3a> 14 06 74 ef 19 c0 83 c8 01 31 d2 31 f6 31 ff c3 cc cc
cc cc 31
Nov 14 11:48:11 ceph-0005 kernel: [  155.094057] RSP: 0018:ffff8881536875c0
EFLAGS: 00010246
Nov 14 11:48:11 ceph-0005 kernel: [  155.094522] RAX: 0000000000000000 RBX:
ffff888116003200 RCX: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.095114] RDX: 0000000000000063 RSI:
0000000000000000 RDI: ffff88810126c900
Nov 14 11:48:11 ceph-0005 kernel: [  155.095714] RBP: ffff8881536876a8 R08:
0000000000000000 R09: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.096297] R10: 0000000000000000 R11:
0000000000000000 R12: dffffc0000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.096889] R13: ffff8881061d0000 R14:
0000000000000000 R15: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.097490] FS:  000074a85c082840(0000)
GS:ffff8882401a4000(0000) knlGS:0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.098146] CS:  0010 DS: 0000 ES: 0000
CR0: 0000000080050033
Nov 14 11:48:11 ceph-0005 kernel: [  155.098630] CR2: 0000000000000000 CR3:
0000000110ebd001 CR4: 0000000000772ef0
Nov 14 11:48:11 ceph-0005 kernel: [  155.099219] PKRU: 55555554
Nov 14 11:48:11 ceph-0005 kernel: [  155.099476] Call Trace:
Nov 14 11:48:11 ceph-0005 kernel: [  155.099686]  <TASK>
Nov 14 11:48:11 ceph-0005 kernel: [  155.099873]  ?
ceph_mds_check_access+0x348/0x1760
Nov 14 11:48:11 ceph-0005 kernel: [  155.100267]  ?
__kasan_check_write+0x14/0x30
Nov 14 11:48:11 ceph-0005 kernel: [  155.100671]  ? lockref_get+0xb1/0x170
Nov 14 11:48:11 ceph-0005 kernel: [  155.100979]  ?
__pfx__raw_spin_lock+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.101372]  ceph_open+0x322/0xef0
Nov 14 11:48:11 ceph-0005 kernel: [  155.101669]  ? __pfx_ceph_open+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.101996]  ?
__pfx_apparmor_file_open+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.102434]  ?
__ceph_caps_issued_mask_metric+0xd6/0x180
Nov 14 11:48:11 ceph-0005 kernel: [  155.102911]  do_dentry_open+0x7bf/0x10e0
Nov 14 11:48:11 ceph-0005 kernel: [  155.103249]  ? __pfx_ceph_open+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.103508]  vfs_open+0x6d/0x450
Nov 14 11:48:11 ceph-0005 kernel: [  155.103697]  ? may_open+0xec/0x370
Nov 14 11:48:11 ceph-0005 kernel: [  155.103893]  path_openat+0x2017/0x50a0
Nov 14 11:48:11 ceph-0005 kernel: [  155.104110]  ? __pfx_path_openat+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.104345]  ?
__pfx_stack_trace_save+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.104599]  ?
stack_depot_save_flags+0x28/0x8f0
Nov 14 11:48:11 ceph-0005 kernel: [  155.104865]  ? stack_depot_save+0xe/0x20
Nov 14 11:48:11 ceph-0005 kernel: [  155.105063]  do_filp_open+0x1b4/0x450
Nov 14 11:48:11 ceph-0005 kernel: [  155.105253]  ?
__pfx__raw_spin_lock_irqsave+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.105538]  ? __pfx_do_filp_open+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.105748]  ? __link_object+0x13d/0x2b0
Nov 14 11:48:11 ceph-0005 kernel: [  155.105949]  ?
__pfx__raw_spin_lock+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.106169]  ?
__check_object_size+0x453/0x600
Nov 14 11:48:11 ceph-0005 kernel: [  155.106428]  ? _raw_spin_unlock+0xe/0x40
Nov 14 11:48:11 ceph-0005 kernel: [  155.106635]  do_sys_openat2+0xe6/0x180
Nov 14 11:48:11 ceph-0005 kernel: [  155.106827]  ?
__pfx_do_sys_openat2+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.107052]  __x64_sys_openat+0x108/0x240
Nov 14 11:48:11 ceph-0005 kernel: [  155.107258]  ?
__pfx___x64_sys_openat+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.107529]  ?
__pfx___handle_mm_fault+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.107783]  x64_sys_call+0x134f/0x2350
Nov 14 11:48:11 ceph-0005 kernel: [  155.108007]  do_syscall_64+0x82/0xd50
Nov 14 11:48:11 ceph-0005 kernel: [  155.108201]  ?
fpregs_assert_state_consistent+0x5c/0x100
Nov 14 11:48:11 ceph-0005 kernel: [  155.108467]  ? do_syscall_64+0xba/0xd50
Nov 14 11:48:11 ceph-0005 kernel: [  155.108626]  ? __kasan_check_read+0x11/0x20
Nov 14 11:48:11 ceph-0005 kernel: [  155.108801]  ?
count_memcg_events+0x25b/0x400
Nov 14 11:48:11 ceph-0005 kernel: [  155.109013]  ? handle_mm_fault+0x38b/0x6a0
Nov 14 11:48:11 ceph-0005 kernel: [  155.109216]  ? __kasan_check_read+0x11/0x20
Nov 14 11:48:11 ceph-0005 kernel: [  155.109457]  ?
fpregs_assert_state_consistent+0x5c/0x100
Nov 14 11:48:11 ceph-0005 kernel: [  155.109724]  ?
irqentry_exit_to_user_mode+0x2e/0x2a0
Nov 14 11:48:11 ceph-0005 kernel: [  155.109991]  ? irqentry_exit+0x43/0x50
Nov 14 11:48:11 ceph-0005 kernel: [  155.110180]  ? exc_page_fault+0x95/0x100
Nov 14 11:48:11 ceph-0005 kernel: [  155.110389]
entry_SYSCALL_64_after_hwframe+0x76/0x7e
Nov 14 11:48:11 ceph-0005 kernel: [  155.110638] RIP: 0033:0x74a85bf145ab
Nov 14 11:48:11 ceph-0005 kernel: [  155.110821] Code: 25 00 00 41 00 3d 00 00
41 00 74 4b 64 8b 04 25 18 00 00 00 85 c0 75 67 44 89 e2 48 89 ee bf 9c ff ff ff
b8 01 01 00 00 0f 05 <48> 3d 00 f0 ff ff 0f 87 91 00 00 00 48 8b 54 24 28 64 48
2b 14 25
Nov 14 11:48:11 ceph-0005 kernel: [  155.111724] RSP: 002b:00007ffc77d316d0
EFLAGS: 00000246 ORIG_RAX: 0000000000000101
Nov 14 11:48:11 ceph-0005 kernel: [  155.112080] RAX: ffffffffffffffda RBX:
0000000000000002 RCX: 000074a85bf145ab
Nov 14 11:48:11 ceph-0005 kernel: [  155.112442] RDX: 0000000000000000 RSI:
00007ffc77d32789 RDI: 00000000ffffff9c
Nov 14 11:48:11 ceph-0005 kernel: [  155.112790] RBP: 00007ffc77d32789 R08:
00007ffc77d31980 R09: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.113125] R10: 0000000000000000 R11:
0000000000000246 R12: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.113502] R13: 00000000ffffffff R14:
0000000000000180 R15: 0000000000000001
Nov 14 11:48:11 ceph-0005 kernel: [  155.113838]  </TASK>
Nov 14 11:48:11 ceph-0005 kernel: [  155.113957] Modules linked in:

intel_rapl_msr intel_rapl_common intel_uncore_frequency_common intel_pmc_core pmt_telemetry pmt_discovery pmt_class intel_pmc_ssram_telemetry intel_vsec kvm_intel kvm joydev irqbypass polyval_clmulni ghash_clmulni_intel aesni_intel rapl floppy input_leds psmouse i2c_piix4 vga16fb mac_hid i2c_smbus vgastate serio_raw bochs qemu_fw_cfg pata_acpi sch_fq_codel rbd msr parport_pc ppdev lp parport efi_pstore

Nov 14 11:48:11 ceph-0005 kernel: [  155.116339] CR2: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.116574] ---[ end trace 0000000000000000
]---
Nov 14 11:48:11 ceph-0005 kernel: [  155.116826] RIP: 0010:strcmp+0x1c/0x40
Nov 14 11:48:11 ceph-0005 kernel: [  155.117058] Code: 90 90 90 90 90 90 90 90
90 90 90 90 90 90 31 c0 eb 14 66 66 2e 0f 1f 84 00 00 00 00 00 90 48 83 c0 01 84
d2 74 19 0f b6 14 07 <3a> 14 06 74 ef 19 c0 83 c8 01 31 d2 31 f6 31 ff c3 cc cc
cc cc 31
Nov 14 11:48:11 ceph-0005 kernel: [  155.118070] RSP: 0018:ffff8881536875c0
EFLAGS: 00010246
Nov 14 11:48:11 ceph-0005 kernel: [  155.118362] RAX: 0000000000000000 RBX:
ffff888116003200 RCX: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.118748] RDX: 0000000000000063 RSI:
0000000000000000 RDI: ffff88810126c900
Nov 14 11:48:11 ceph-0005 kernel: [  155.119116] RBP: ffff8881536876a8 R08:
0000000000000000 R09: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.119492] R10: 0000000000000000 R11:
0000000000000000 R12: dffffc0000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.119865] R13: ffff8881061d0000 R14:
0000000000000000 R15: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.120242] FS:  000074a85c082840(0000)
GS:ffff8882401a4000(0000) knlGS:0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.120704] CS:  0010 DS: 0000 ES: 0000
CR0: 0000000080050033
Nov 14 11:48:11 ceph-0005 kernel: [  155.121008] CR2: 0000000000000000 CR3:
0000000110ebd001 CR4: 0000000000772ef0
Nov 14 11:48:11 ceph-0005 kernel: [  155.121409] PKRU: 55555554

We have issue here [1] if fs_name == NULL:

const char fs_name = mdsc->fsc->mount_options->mds_namespace;
    ...
    if (auth->match.fs_name && strcmp(auth->match.fs_name, fs_name)) {
            / fsname mismatch, try next one */
            return 0;
    }

v2
Patrick Donnelly suggested that: In summary, we should definitely start decoding fs_name from the MDSMap and do strict authorizations checks against it. Note that the --mds_namespace should only be used for selecting the file system to mount and nothing else. It's possible no mds_namespace is specified but the kernel will mount the only file system that exists which may have name "foo".

This patch reworks ceph_mdsmap_decode() and namespace_equals() with the goal of supporting the suggested concept. Now struct ceph_mdsmap contains m_fs_name field that receives copy of extracted FS name by ceph_extract_encoded_string(). For the case of "old" CephFS file systems, it is used "cephfs" name. Also, namespace_equals() method has been reworked with the goal of proper names comparison.

[1] https://elixir.bootlin.com/linux/v6.18-rc4/source/fs/ceph/mds_client.c#L5666

Fixes 22c73d52a6d0 ("ceph: fix multifs mds auth caps issue")
cc Kotresh Hiremath Ravishankar <[email protected]>
cc Alex Markuze <[email protected]>
cc Ilya Dryomov <[email protected]>
cc Patrick Donnelly <[email protected]>
cc Ceph Development <[email protected]>
---
 fs/ceph/mds_client.c         |  2 +-
 fs/ceph/mdsmap.c             | 26 ++++++++++++++++++++------
 fs/ceph/mdsmap.h             |  1 +
 fs/ceph/super.h              | 19 ++++++++++++++++---
 include/linux/ceph/ceph_fs.h |  6 ++++++
 5 files changed, 44 insertions(+), 10 deletions(-)
fs/ceph/mds_client.c +1 -1
index 7e4eab824dae..1c02f97c5b52 100644
@@ -5671,7 +5671,7 @@ static int ceph_mds_auth_match(struct ceph_mds_client *mdsc,
 	u32 caller_uid = from_kuid(&init_user_ns, cred->fsuid);
 	u32 caller_gid = from_kgid(&init_user_ns, cred->fsgid);
 	struct ceph_client *cl = mdsc->fsc->client;
-	const char *fs_name = mdsc->fsc->mount_options->mds_namespace;
+	const char *fs_name = mdsc->mdsmap->m_fs_name;
 	const char *spath = mdsc->fsc->mount_options->server_path;
 	bool gid_matched = false;
 	u32 gid, tlen, len;
fs/ceph/mdsmap.c +20 -6
index 2c7b151a7c95..b54a226510f1 100644
@@ -353,22 +353,35 @@ struct ceph_mdsmap *ceph_mdsmap_decode(struct ceph_mds_client *mdsc, void **p,
 		__decode_and_drop_type(p, end, u8, bad_ext);
 	}
 	if (mdsmap_ev >= 8) {
-		u32 fsname_len;
+		size_t fsname_len;
+
 		/* enabled */
 		ceph_decode_8_safe(p, end, m->m_enabled, bad_ext);
+
 		/* fs_name */
-		ceph_decode_32_safe(p, end, fsname_len, bad_ext);
+		m->m_fs_name = ceph_extract_encoded_string(p, end,
+							   &fsname_len,
+							   GFP_NOFS);
+		if (IS_ERR(m->m_fs_name)) {
+			m->m_fs_name = NULL;
+			goto nomem;
+		}
 
 		/* validate fsname against mds_namespace */
-		if (!namespace_equals(mdsc->fsc->mount_options, *p,
+		if (!namespace_equals(mdsc->fsc->mount_options, m->m_fs_name,
 				      fsname_len)) {
 			pr_warn_client(cl, "fsname %*pE doesn't match mds_namespace %s\n",
-				       (int)fsname_len, (char *)*p,
+				       (int)fsname_len, m->m_fs_name,
 				       mdsc->fsc->mount_options->mds_namespace);
 			goto bad;
 		}
-		/* skip fsname after validation */
-		ceph_decode_skip_n(p, end, fsname_len, bad);
+	} else {
+		m->m_enabled = false;
+		/*
+		 * name for "old" CephFS file systems,
+		 * see ceph.git e2b151d009640114b2565c901d6f41f6cd5ec652
+		 */
+		m->m_fs_name = kstrdup(CEPH_OLD_FS_NAME, GFP_NOFS);
 	}
 	/* damaged */
 	if (mdsmap_ev >= 9) {
@@ -430,6 +443,7 @@ void ceph_mdsmap_destroy(struct ceph_mdsmap *m)
 		kfree(m->m_info);
 	}
 	kfree(m->m_data_pg_pools);
+	kfree(m->m_fs_name);
 	kfree(m);
 }
 
fs/ceph/mdsmap.h +1 -0
index 1f2171dd01bf..d48d07c3516d 100644
@@ -45,6 +45,7 @@ struct ceph_mdsmap {
 	bool m_enabled;
 	bool m_damaged;
 	int m_num_laggy;
+	char *m_fs_name;
 };
 
 static inline struct ceph_entity_addr *
fs/ceph/super.h +16 -3
index a1f781c46b41..c53bec40ea69 100644
@@ -104,6 +104,8 @@ struct ceph_mount_options {
 	struct fscrypt_dummy_policy dummy_enc_policy;
 };
 
+#define CEPH_NAMESPACE_WIDCARD		"*"
+
 /*
  * Check if the mds namespace in ceph_mount_options matches
  * the passed in namespace string. First time match (when
@@ -113,9 +115,20 @@ struct ceph_mount_options {
 static inline int namespace_equals(struct ceph_mount_options *fsopt,
 				   const char *namespace, size_t len)
 {
-	return !(fsopt->mds_namespace &&
-		 (strlen(fsopt->mds_namespace) != len ||
-		  strncmp(fsopt->mds_namespace, namespace, len)));
+	if (!fsopt->mds_namespace && !namespace)
+		return true;
+
+	if (!fsopt->mds_namespace)
+		return true;
+
+	if (strcmp(fsopt->mds_namespace, CEPH_NAMESPACE_WIDCARD) == 0)
+		return true;
+
+	if (!namespace)
+		return false;
+
+	return !(strlen(fsopt->mds_namespace) != len ||
+		  strncmp(fsopt->mds_namespace, namespace, len));
 }
 
 /* mount state */
include/linux/ceph/ceph_fs.h +6 -0
index c7f2c63b3bc3..08e5dbe15ca4 100644
@@ -31,6 +31,12 @@
 #define CEPH_INO_CEPH   2            /* hidden .ceph dir */
 #define CEPH_INO_GLOBAL_SNAPREALM  3 /* global dummy snaprealm */
 
+/*
+ * name for "old" CephFS file systems,
+ * see ceph.git e2b151d009640114b2565c901d6f41f6cd5ec652
+ */
+#define CEPH_OLD_FS_NAME	"cephfs"
+
 /* arbitrary limit on max # of monitors (cluster of 3 is typical) */
 #define CEPH_MAX_MON   31
 
Signature · 1 line
2.52.0
#1 lore raw

Hi Slava,

A few things:

* CEPH_NAMESPACE_WIDCARD -> CEPH_NAMESPACE_WILDCARD ?
* The comment "name for "old" CephFS file systems," appears twice. Probably only necessary in the header.
* You also need to update ceph_mds_auth_match to call namespace_equals. Suggest documenting (in the man page) that mds_namespace mntopt can be "*" now.

Patrick

Quoted 347 lines · Viacheslav Dubeyko

From: Viacheslav Dubeyko <[email protected]>

The CephFS kernel client has regression starting from 6.18-rc1.

sudo ./check -g quick
FSTYP -- ceph
PLATFORM -- Linux/x86_64 ceph-0005 6.18.0-rc5+ #52 SMP PREEMPT_DYNAMIC Fri

Nov 14 11:26:14 PST 2025

MKFS_OPTIONS -- 192.168.1.213:3300:/scratch
MOUNT_OPTIONS -- -o name=admin,ms_mode=secure 192.168.1.213:3300:/scratch /mnt/cephfs/scratch

Killed

Nov 14 11:48:10 ceph-0005 kernel: [  154.723902] libceph: mon0
(2)192.168.1.213:3300 session established
Nov 14 11:48:10 ceph-0005 kernel: [  154.727225] libceph: client167616
Nov 14 11:48:11 ceph-0005 kernel: [  155.087260] BUG: kernel NULL pointer
dereference, address: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.087756] #PF: supervisor read access in
kernel mode
Nov 14 11:48:11 ceph-0005 kernel: [  155.088043] #PF: error_code(0x0000) - not-
present page
Nov 14 11:48:11 ceph-0005 kernel: [  155.088302] PGD 0 P4D 0
Nov 14 11:48:11 ceph-0005 kernel: [  155.088688] Oops: Oops: 0000 [#1] SMP KASAN
NOPTI
Nov 14 11:48:11 ceph-0005 kernel: [  155.090080] CPU: 4 UID: 0 PID: 3453 Comm:
xfs_io Not tainted 6.18.0-rc5+ #52 PREEMPT(voluntary)
Nov 14 11:48:11 ceph-0005 kernel: [  155.091245] Hardware name: QEMU Standard PC
(i440FX + PIIX, 1996), BIOS 1.17.0-5.fc42 04/01/2014
Nov 14 11:48:11 ceph-0005 kernel: [  155.092103] RIP: 0010:strcmp+0x1c/0x40
Nov 14 11:48:11 ceph-0005 kernel: [  155.092493] Code: 90 90 90 90 90 90 90 90
90 90 90 90 90 90 31 c0 eb 14 66 66 2e 0f 1f 84 00 00 00 00 00 90 48 83 c0 01 84
d2 74 19 0f b6 14 07 <3a> 14 06 74 ef 19 c0 83 c8 01 31 d2 31 f6 31 ff c3 cc cc
cc cc 31
Nov 14 11:48:11 ceph-0005 kernel: [  155.094057] RSP: 0018:ffff8881536875c0
EFLAGS: 00010246
Nov 14 11:48:11 ceph-0005 kernel: [  155.094522] RAX: 0000000000000000 RBX:
ffff888116003200 RCX: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.095114] RDX: 0000000000000063 RSI:
0000000000000000 RDI: ffff88810126c900
Nov 14 11:48:11 ceph-0005 kernel: [  155.095714] RBP: ffff8881536876a8 R08:
0000000000000000 R09: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.096297] R10: 0000000000000000 R11:
0000000000000000 R12: dffffc0000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.096889] R13: ffff8881061d0000 R14:
0000000000000000 R15: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.097490] FS:  000074a85c082840(0000)
GS:ffff8882401a4000(0000) knlGS:0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.098146] CS:  0010 DS: 0000 ES: 0000
CR0: 0000000080050033
Nov 14 11:48:11 ceph-0005 kernel: [  155.098630] CR2: 0000000000000000 CR3:
0000000110ebd001 CR4: 0000000000772ef0
Nov 14 11:48:11 ceph-0005 kernel: [  155.099219] PKRU: 55555554
Nov 14 11:48:11 ceph-0005 kernel: [  155.099476] Call Trace:
Nov 14 11:48:11 ceph-0005 kernel: [  155.099686]  <TASK>
Nov 14 11:48:11 ceph-0005 kernel: [  155.099873]  ?
ceph_mds_check_access+0x348/0x1760
Nov 14 11:48:11 ceph-0005 kernel: [  155.100267]  ?
__kasan_check_write+0x14/0x30
Nov 14 11:48:11 ceph-0005 kernel: [  155.100671]  ? lockref_get+0xb1/0x170
Nov 14 11:48:11 ceph-0005 kernel: [  155.100979]  ?
__pfx__raw_spin_lock+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.101372]  ceph_open+0x322/0xef0
Nov 14 11:48:11 ceph-0005 kernel: [  155.101669]  ? __pfx_ceph_open+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.101996]  ?
__pfx_apparmor_file_open+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.102434]  ?
__ceph_caps_issued_mask_metric+0xd6/0x180
Nov 14 11:48:11 ceph-0005 kernel: [  155.102911]  do_dentry_open+0x7bf/0x10e0
Nov 14 11:48:11 ceph-0005 kernel: [  155.103249]  ? __pfx_ceph_open+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.103508]  vfs_open+0x6d/0x450
Nov 14 11:48:11 ceph-0005 kernel: [  155.103697]  ? may_open+0xec/0x370
Nov 14 11:48:11 ceph-0005 kernel: [  155.103893]  path_openat+0x2017/0x50a0
Nov 14 11:48:11 ceph-0005 kernel: [  155.104110]  ? __pfx_path_openat+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.104345]  ?
__pfx_stack_trace_save+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.104599]  ?
stack_depot_save_flags+0x28/0x8f0
Nov 14 11:48:11 ceph-0005 kernel: [  155.104865]  ? stack_depot_save+0xe/0x20
Nov 14 11:48:11 ceph-0005 kernel: [  155.105063]  do_filp_open+0x1b4/0x450
Nov 14 11:48:11 ceph-0005 kernel: [  155.105253]  ?
__pfx__raw_spin_lock_irqsave+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.105538]  ? __pfx_do_filp_open+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.105748]  ? __link_object+0x13d/0x2b0
Nov 14 11:48:11 ceph-0005 kernel: [  155.105949]  ?
__pfx__raw_spin_lock+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.106169]  ?
__check_object_size+0x453/0x600
Nov 14 11:48:11 ceph-0005 kernel: [  155.106428]  ? _raw_spin_unlock+0xe/0x40
Nov 14 11:48:11 ceph-0005 kernel: [  155.106635]  do_sys_openat2+0xe6/0x180
Nov 14 11:48:11 ceph-0005 kernel: [  155.106827]  ?
__pfx_do_sys_openat2+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.107052]  __x64_sys_openat+0x108/0x240
Nov 14 11:48:11 ceph-0005 kernel: [  155.107258]  ?
__pfx___x64_sys_openat+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.107529]  ?
__pfx___handle_mm_fault+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.107783]  x64_sys_call+0x134f/0x2350
Nov 14 11:48:11 ceph-0005 kernel: [  155.108007]  do_syscall_64+0x82/0xd50
Nov 14 11:48:11 ceph-0005 kernel: [  155.108201]  ?
fpregs_assert_state_consistent+0x5c/0x100
Nov 14 11:48:11 ceph-0005 kernel: [  155.108467]  ? do_syscall_64+0xba/0xd50
Nov 14 11:48:11 ceph-0005 kernel: [  155.108626]  ? __kasan_check_read+0x11/0x20
Nov 14 11:48:11 ceph-0005 kernel: [  155.108801]  ?
count_memcg_events+0x25b/0x400
Nov 14 11:48:11 ceph-0005 kernel: [  155.109013]  ? handle_mm_fault+0x38b/0x6a0
Nov 14 11:48:11 ceph-0005 kernel: [  155.109216]  ? __kasan_check_read+0x11/0x20
Nov 14 11:48:11 ceph-0005 kernel: [  155.109457]  ?
fpregs_assert_state_consistent+0x5c/0x100
Nov 14 11:48:11 ceph-0005 kernel: [  155.109724]  ?
irqentry_exit_to_user_mode+0x2e/0x2a0
Nov 14 11:48:11 ceph-0005 kernel: [  155.109991]  ? irqentry_exit+0x43/0x50
Nov 14 11:48:11 ceph-0005 kernel: [  155.110180]  ? exc_page_fault+0x95/0x100
Nov 14 11:48:11 ceph-0005 kernel: [  155.110389]
entry_SYSCALL_64_after_hwframe+0x76/0x7e
Nov 14 11:48:11 ceph-0005 kernel: [  155.110638] RIP: 0033:0x74a85bf145ab
Nov 14 11:48:11 ceph-0005 kernel: [  155.110821] Code: 25 00 00 41 00 3d 00 00
41 00 74 4b 64 8b 04 25 18 00 00 00 85 c0 75 67 44 89 e2 48 89 ee bf 9c ff ff ff
b8 01 01 00 00 0f 05 <48> 3d 00 f0 ff ff 0f 87 91 00 00 00 48 8b 54 24 28 64 48
2b 14 25
Nov 14 11:48:11 ceph-0005 kernel: [  155.111724] RSP: 002b:00007ffc77d316d0
EFLAGS: 00000246 ORIG_RAX: 0000000000000101
Nov 14 11:48:11 ceph-0005 kernel: [  155.112080] RAX: ffffffffffffffda RBX:
0000000000000002 RCX: 000074a85bf145ab
Nov 14 11:48:11 ceph-0005 kernel: [  155.112442] RDX: 0000000000000000 RSI:
00007ffc77d32789 RDI: 00000000ffffff9c
Nov 14 11:48:11 ceph-0005 kernel: [  155.112790] RBP: 00007ffc77d32789 R08:
00007ffc77d31980 R09: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.113125] R10: 0000000000000000 R11:
0000000000000246 R12: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.113502] R13: 00000000ffffffff R14:
0000000000000180 R15: 0000000000000001
Nov 14 11:48:11 ceph-0005 kernel: [  155.113838]  </TASK>
Nov 14 11:48:11 ceph-0005 kernel: [  155.113957] Modules linked in:

intel_rapl_msr intel_rapl_common intel_uncore_frequency_common intel_pmc_core pmt_telemetry pmt_discovery pmt_class intel_pmc_ssram_telemetry intel_vsec kvm_intel kvm joydev irqbypass polyval_clmulni ghash_clmulni_intel aesni_intel rapl floppy input_leds psmouse i2c_piix4 vga16fb mac_hid i2c_smbus vgastate serio_raw bochs qemu_fw_cfg pata_acpi sch_fq_codel rbd msr parport_pc ppdev lp parport efi_pstore

Nov 14 11:48:11 ceph-0005 kernel: [  155.116339] CR2: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.116574] ---[ end trace 0000000000000000
]---
Nov 14 11:48:11 ceph-0005 kernel: [  155.116826] RIP: 0010:strcmp+0x1c/0x40
Nov 14 11:48:11 ceph-0005 kernel: [  155.117058] Code: 90 90 90 90 90 90 90 90
90 90 90 90 90 90 31 c0 eb 14 66 66 2e 0f 1f 84 00 00 00 00 00 90 48 83 c0 01 84
d2 74 19 0f b6 14 07 <3a> 14 06 74 ef 19 c0 83 c8 01 31 d2 31 f6 31 ff c3 cc cc
cc cc 31
Nov 14 11:48:11 ceph-0005 kernel: [  155.118070] RSP: 0018:ffff8881536875c0
EFLAGS: 00010246
Nov 14 11:48:11 ceph-0005 kernel: [  155.118362] RAX: 0000000000000000 RBX:
ffff888116003200 RCX: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.118748] RDX: 0000000000000063 RSI:
0000000000000000 RDI: ffff88810126c900
Nov 14 11:48:11 ceph-0005 kernel: [  155.119116] RBP: ffff8881536876a8 R08:
0000000000000000 R09: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.119492] R10: 0000000000000000 R11:
0000000000000000 R12: dffffc0000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.119865] R13: ffff8881061d0000 R14:
0000000000000000 R15: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.120242] FS:  000074a85c082840(0000)
GS:ffff8882401a4000(0000) knlGS:0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.120704] CS:  0010 DS: 0000 ES: 0000
CR0: 0000000080050033
Nov 14 11:48:11 ceph-0005 kernel: [  155.121008] CR2: 0000000000000000 CR3:
0000000110ebd001 CR4: 0000000000772ef0
Nov 14 11:48:11 ceph-0005 kernel: [  155.121409] PKRU: 55555554

We have issue here [1] if fs_name == NULL:

const char fs_name = mdsc->fsc->mount_options->mds_namespace;
    ...
    if (auth->match.fs_name && strcmp(auth->match.fs_name, fs_name)) {
            / fsname mismatch, try next one */
            return 0;
    }

v2
Patrick Donnelly suggested that: In summary, we should definitely start decoding fs_name from the MDSMap and do strict authorizations checks against it. Note that the --mds_namespace should only be used for selecting the file system to mount and nothing else. It's possible no mds_namespace is specified but the kernel will mount the only file system that exists which may have name "foo".

This patch reworks ceph_mdsmap_decode() and namespace_equals() with the goal of supporting the suggested concept. Now struct ceph_mdsmap contains m_fs_name field that receives copy of extracted FS name by ceph_extract_encoded_string(). For the case of "old" CephFS file systems, it is used "cephfs" name. Also, namespace_equals() method has been reworked with the goal of proper names comparison.

[1] https://elixir.bootlin.com/linux/v6.18-rc4/source/fs/ceph/mds_client.c#L5666

Fixes 22c73d52a6d0 ("ceph: fix multifs mds auth caps issue")
cc Kotresh Hiremath Ravishankar <[email protected]>
cc Alex Markuze <[email protected]>
cc Ilya Dryomov <[email protected]>
cc Patrick Donnelly <[email protected]>
cc Ceph Development <[email protected]>
---
 fs/ceph/mds_client.c         |  2 +-
 fs/ceph/mdsmap.c             | 26 ++++++++++++++++++++------
 fs/ceph/mdsmap.h             |  1 +
 fs/ceph/super.h              | 19 ++++++++++++++++---
 include/linux/ceph/ceph_fs.h |  6 ++++++
 5 files changed, 44 insertions(+), 10 deletions(-)
fs/ceph/mds_client.c +1 -1
index 7e4eab824dae..1c02f97c5b52 100644
@@ -5671,7 +5671,7 @@ static int ceph_mds_auth_match(struct ceph_mds_client *mdsc,
        u32 caller_uid = from_kuid(&init_user_ns, cred->fsuid);
        u32 caller_gid = from_kgid(&init_user_ns, cred->fsgid);
        struct ceph_client *cl = mdsc->fsc->client;
-       const char *fs_name = mdsc->fsc->mount_options->mds_namespace;
+       const char *fs_name = mdsc->mdsmap->m_fs_name;
        const char *spath = mdsc->fsc->mount_options->server_path;
        bool gid_matched = false;
        u32 gid, tlen, len;
fs/ceph/mdsmap.c +20 -6
index 2c7b151a7c95..b54a226510f1 100644
@@ -353,22 +353,35 @@ struct ceph_mdsmap *ceph_mdsmap_decode(struct ceph_mds_client *mdsc, void **p,
                __decode_and_drop_type(p, end, u8, bad_ext);
        }
        if (mdsmap_ev >= 8) {
-               u32 fsname_len;
+               size_t fsname_len;
+
                /* enabled */
                ceph_decode_8_safe(p, end, m->m_enabled, bad_ext);
+
                /* fs_name */
-               ceph_decode_32_safe(p, end, fsname_len, bad_ext);
+               m->m_fs_name = ceph_extract_encoded_string(p, end,
+                                                          &fsname_len,
+                                                          GFP_NOFS);
+               if (IS_ERR(m->m_fs_name)) {
+                       m->m_fs_name = NULL;
+                       goto nomem;
+               }
 
                /* validate fsname against mds_namespace */
-               if (!namespace_equals(mdsc->fsc->mount_options, *p,
+               if (!namespace_equals(mdsc->fsc->mount_options, m->m_fs_name,
                                      fsname_len)) {
                        pr_warn_client(cl, "fsname %*pE doesn't match mds_namespace %s\n",
-                                      (int)fsname_len, (char *)*p,
+                                      (int)fsname_len, m->m_fs_name,
                                       mdsc->fsc->mount_options->mds_namespace);
                        goto bad;
                }
-               /* skip fsname after validation */
-               ceph_decode_skip_n(p, end, fsname_len, bad);
+       } else {
+               m->m_enabled = false;
+               /*
+                * name for "old" CephFS file systems,
+                * see ceph.git e2b151d009640114b2565c901d6f41f6cd5ec652
+                */
+               m->m_fs_name = kstrdup(CEPH_OLD_FS_NAME, GFP_NOFS);
        }
        /* damaged */
        if (mdsmap_ev >= 9) {
@@ -430,6 +443,7 @@ void ceph_mdsmap_destroy(struct ceph_mdsmap *m)
                kfree(m->m_info);
        }
        kfree(m->m_data_pg_pools);
+       kfree(m->m_fs_name);
        kfree(m);
 }
 
fs/ceph/mdsmap.h +1 -0
index 1f2171dd01bf..d48d07c3516d 100644
@@ -45,6 +45,7 @@ struct ceph_mdsmap {
        bool m_enabled;
        bool m_damaged;
        int m_num_laggy;
+       char *m_fs_name;
 };
 
 static inline struct ceph_entity_addr *
fs/ceph/super.h +16 -3
index a1f781c46b41..c53bec40ea69 100644
@@ -104,6 +104,8 @@ struct ceph_mount_options {
        struct fscrypt_dummy_policy dummy_enc_policy;
 };
 
+#define CEPH_NAMESPACE_WIDCARD         "*"
+
 /*
  * Check if the mds namespace in ceph_mount_options matches
  * the passed in namespace string. First time match (when
@@ -113,9 +115,20 @@ struct ceph_mount_options {
 static inline int namespace_equals(struct ceph_mount_options *fsopt,
                                   const char *namespace, size_t len)
 {
-       return !(fsopt->mds_namespace &&
-                (strlen(fsopt->mds_namespace) != len ||
-                 strncmp(fsopt->mds_namespace, namespace, len)));
+       if (!fsopt->mds_namespace && !namespace)
+               return true;
+
+       if (!fsopt->mds_namespace)
+               return true;
+
+       if (strcmp(fsopt->mds_namespace, CEPH_NAMESPACE_WIDCARD) == 0)
+               return true;
+
+       if (!namespace)
+               return false;
+
+       return !(strlen(fsopt->mds_namespace) != len ||
+                 strncmp(fsopt->mds_namespace, namespace, len));
 }
 
 /* mount state */
include/linux/ceph/ceph_fs.h +6 -1
index c7f2c63b3bc3..08e5dbe15ca4 100644
@@ -31,6 +31,12 @@
 #define CEPH_INO_CEPH   2            /* hidden .ceph dir */
 #define CEPH_INO_GLOBAL_SNAPREALM  3 /* global dummy snaprealm */
 
+/*
+ * name for "old" CephFS file systems,
+ * see ceph.git e2b151d009640114b2565c901d6f41f6cd5ec652
+ */
+#define CEPH_OLD_FS_NAME       "cephfs"
+
 /* arbitrary limit on max # of monitors (cluster of 3 is typical) */
 #define CEPH_MAX_MON   31
 
--

2.52.0

Signature · 5 lines
Patrick Donnelly, Ph.D.
He / Him / His
Red Hat Partner Engineer
IBM, Inc.
GPG: 19F28A586F808C2402351B93C3301A3E258DD79D
#2 lore raw
Quoted 5 lines · Patrick Donnelly

Hi Slava,

A few things:

* CEPH_NAMESPACE_WIDCARD -> CEPH_NAMESPACE_WILDCARD ?

Yeah, sure :) My bad.

Quoted 2 lines

* The comment "name for "old" CephFS file systems," appears twice. Probably only necessary in the header.

Makes sense.

Quoted 3 lines

* You also need to update ceph_mds_auth_match to call namespace_equals.

Do you mean this code [1]?

Quoted 3 lines

Suggest documenting (in the man page) that
mds_namespace mntopt can be "*" now.

Agreed. Which man page do you mean? Because 'man mount' contains no info about Ceph. And it is my worry that we have nothing there. We should do something about it. Do I miss something here?

Thanks,
Slava.

[1] https://elixir.bootlin.com/linux/v6.18-rc6/source/fs/ceph/mds_client.c#L5666

Quoted 351 lines

Patrick

Quoted 347 lines · Viacheslav Dubeyko

From: Viacheslav Dubeyko <[email protected]>

The CephFS kernel client has regression starting from 6.18-rc1.

sudo ./check -g quick
FSTYP -- ceph
PLATFORM -- Linux/x86_64 ceph-0005 6.18.0-rc5+ #52 SMP PREEMPT_DYNAMIC Fri

Nov 14 11:26:14 PST 2025

MKFS_OPTIONS -- 192.168.1.213:3300:/scratch
MOUNT_OPTIONS -- -o name=admin,ms_mode=secure 192.168.1.213:3300:/scratch /mnt/cephfs/scratch

Killed

Nov 14 11:48:10 ceph-0005 kernel: [  154.723902] libceph: mon0
(2)192.168.1.213:3300 session established
Nov 14 11:48:10 ceph-0005 kernel: [  154.727225] libceph: client167616
Nov 14 11:48:11 ceph-0005 kernel: [  155.087260] BUG: kernel NULL pointer
dereference, address: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.087756] #PF: supervisor read access in
kernel mode
Nov 14 11:48:11 ceph-0005 kernel: [  155.088043] #PF: error_code(0x0000) - not-
present page
Nov 14 11:48:11 ceph-0005 kernel: [  155.088302] PGD 0 P4D 0
Nov 14 11:48:11 ceph-0005 kernel: [  155.088688] Oops: Oops: 0000 [#1] SMP KASAN
NOPTI
Nov 14 11:48:11 ceph-0005 kernel: [  155.090080] CPU: 4 UID: 0 PID: 3453 Comm:
xfs_io Not tainted 6.18.0-rc5+ #52 PREEMPT(voluntary)
Nov 14 11:48:11 ceph-0005 kernel: [  155.091245] Hardware name: QEMU Standard PC
(i440FX + PIIX, 1996), BIOS 1.17.0-5.fc42 04/01/2014
Nov 14 11:48:11 ceph-0005 kernel: [  155.092103] RIP: 0010:strcmp+0x1c/0x40
Nov 14 11:48:11 ceph-0005 kernel: [  155.092493] Code: 90 90 90 90 90 90 90 90
90 90 90 90 90 90 31 c0 eb 14 66 66 2e 0f 1f 84 00 00 00 00 00 90 48 83 c0 01 84
d2 74 19 0f b6 14 07 <3a> 14 06 74 ef 19 c0 83 c8 01 31 d2 31 f6 31 ff c3 cc cc
cc cc 31
Nov 14 11:48:11 ceph-0005 kernel: [  155.094057] RSP: 0018:ffff8881536875c0
EFLAGS: 00010246
Nov 14 11:48:11 ceph-0005 kernel: [  155.094522] RAX: 0000000000000000 RBX:
ffff888116003200 RCX: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.095114] RDX: 0000000000000063 RSI:
0000000000000000 RDI: ffff88810126c900
Nov 14 11:48:11 ceph-0005 kernel: [  155.095714] RBP: ffff8881536876a8 R08:
0000000000000000 R09: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.096297] R10: 0000000000000000 R11:
0000000000000000 R12: dffffc0000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.096889] R13: ffff8881061d0000 R14:
0000000000000000 R15: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.097490] FS:  000074a85c082840(0000)
GS:ffff8882401a4000(0000) knlGS:0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.098146] CS:  0010 DS: 0000 ES: 0000
CR0: 0000000080050033
Nov 14 11:48:11 ceph-0005 kernel: [  155.098630] CR2: 0000000000000000 CR3:
0000000110ebd001 CR4: 0000000000772ef0
Nov 14 11:48:11 ceph-0005 kernel: [  155.099219] PKRU: 55555554
Nov 14 11:48:11 ceph-0005 kernel: [  155.099476] Call Trace:
Nov 14 11:48:11 ceph-0005 kernel: [  155.099686]  <TASK>
Nov 14 11:48:11 ceph-0005 kernel: [  155.099873]  ?
ceph_mds_check_access+0x348/0x1760
Nov 14 11:48:11 ceph-0005 kernel: [  155.100267]  ?
__kasan_check_write+0x14/0x30
Nov 14 11:48:11 ceph-0005 kernel: [  155.100671]  ? lockref_get+0xb1/0x170
Nov 14 11:48:11 ceph-0005 kernel: [  155.100979]  ?
__pfx__raw_spin_lock+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.101372]  ceph_open+0x322/0xef0
Nov 14 11:48:11 ceph-0005 kernel: [  155.101669]  ? __pfx_ceph_open+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.101996]  ?
__pfx_apparmor_file_open+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.102434]  ?
__ceph_caps_issued_mask_metric+0xd6/0x180
Nov 14 11:48:11 ceph-0005 kernel: [  155.102911]  do_dentry_open+0x7bf/0x10e0
Nov 14 11:48:11 ceph-0005 kernel: [  155.103249]  ? __pfx_ceph_open+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.103508]  vfs_open+0x6d/0x450
Nov 14 11:48:11 ceph-0005 kernel: [  155.103697]  ? may_open+0xec/0x370
Nov 14 11:48:11 ceph-0005 kernel: [  155.103893]  path_openat+0x2017/0x50a0
Nov 14 11:48:11 ceph-0005 kernel: [  155.104110]  ? __pfx_path_openat+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.104345]  ?
__pfx_stack_trace_save+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.104599]  ?
stack_depot_save_flags+0x28/0x8f0
Nov 14 11:48:11 ceph-0005 kernel: [  155.104865]  ? stack_depot_save+0xe/0x20
Nov 14 11:48:11 ceph-0005 kernel: [  155.105063]  do_filp_open+0x1b4/0x450
Nov 14 11:48:11 ceph-0005 kernel: [  155.105253]  ?
__pfx__raw_spin_lock_irqsave+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.105538]  ? __pfx_do_filp_open+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.105748]  ? __link_object+0x13d/0x2b0
Nov 14 11:48:11 ceph-0005 kernel: [  155.105949]  ?
__pfx__raw_spin_lock+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.106169]  ?
__check_object_size+0x453/0x600
Nov 14 11:48:11 ceph-0005 kernel: [  155.106428]  ? _raw_spin_unlock+0xe/0x40
Nov 14 11:48:11 ceph-0005 kernel: [  155.106635]  do_sys_openat2+0xe6/0x180
Nov 14 11:48:11 ceph-0005 kernel: [  155.106827]  ?
__pfx_do_sys_openat2+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.107052]  __x64_sys_openat+0x108/0x240
Nov 14 11:48:11 ceph-0005 kernel: [  155.107258]  ?
__pfx___x64_sys_openat+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.107529]  ?
__pfx___handle_mm_fault+0x10/0x10
Nov 14 11:48:11 ceph-0005 kernel: [  155.107783]  x64_sys_call+0x134f/0x2350
Nov 14 11:48:11 ceph-0005 kernel: [  155.108007]  do_syscall_64+0x82/0xd50
Nov 14 11:48:11 ceph-0005 kernel: [  155.108201]  ?
fpregs_assert_state_consistent+0x5c/0x100
Nov 14 11:48:11 ceph-0005 kernel: [  155.108467]  ? do_syscall_64+0xba/0xd50
Nov 14 11:48:11 ceph-0005 kernel: [  155.108626]  ? __kasan_check_read+0x11/0x20
Nov 14 11:48:11 ceph-0005 kernel: [  155.108801]  ?
count_memcg_events+0x25b/0x400
Nov 14 11:48:11 ceph-0005 kernel: [  155.109013]  ? handle_mm_fault+0x38b/0x6a0
Nov 14 11:48:11 ceph-0005 kernel: [  155.109216]  ? __kasan_check_read+0x11/0x20
Nov 14 11:48:11 ceph-0005 kernel: [  155.109457]  ?
fpregs_assert_state_consistent+0x5c/0x100
Nov 14 11:48:11 ceph-0005 kernel: [  155.109724]  ?
irqentry_exit_to_user_mode+0x2e/0x2a0
Nov 14 11:48:11 ceph-0005 kernel: [  155.109991]  ? irqentry_exit+0x43/0x50
Nov 14 11:48:11 ceph-0005 kernel: [  155.110180]  ? exc_page_fault+0x95/0x100
Nov 14 11:48:11 ceph-0005 kernel: [  155.110389]
entry_SYSCALL_64_after_hwframe+0x76/0x7e
Nov 14 11:48:11 ceph-0005 kernel: [  155.110638] RIP: 0033:0x74a85bf145ab
Nov 14 11:48:11 ceph-0005 kernel: [  155.110821] Code: 25 00 00 41 00 3d 00 00
41 00 74 4b 64 8b 04 25 18 00 00 00 85 c0 75 67 44 89 e2 48 89 ee bf 9c ff ff ff
b8 01 01 00 00 0f 05 <48> 3d 00 f0 ff ff 0f 87 91 00 00 00 48 8b 54 24 28 64 48
2b 14 25
Nov 14 11:48:11 ceph-0005 kernel: [  155.111724] RSP: 002b:00007ffc77d316d0
EFLAGS: 00000246 ORIG_RAX: 0000000000000101
Nov 14 11:48:11 ceph-0005 kernel: [  155.112080] RAX: ffffffffffffffda RBX:
0000000000000002 RCX: 000074a85bf145ab
Nov 14 11:48:11 ceph-0005 kernel: [  155.112442] RDX: 0000000000000000 RSI:
00007ffc77d32789 RDI: 00000000ffffff9c
Nov 14 11:48:11 ceph-0005 kernel: [  155.112790] RBP: 00007ffc77d32789 R08:
00007ffc77d31980 R09: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.113125] R10: 0000000000000000 R11:
0000000000000246 R12: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.113502] R13: 00000000ffffffff R14:
0000000000000180 R15: 0000000000000001
Nov 14 11:48:11 ceph-0005 kernel: [  155.113838]  </TASK>
Nov 14 11:48:11 ceph-0005 kernel: [  155.113957] Modules linked in:

intel_rapl_msr intel_rapl_common intel_uncore_frequency_common intel_pmc_core pmt_telemetry pmt_discovery pmt_class intel_pmc_ssram_telemetry intel_vsec kvm_intel kvm joydev irqbypass polyval_clmulni ghash_clmulni_intel aesni_intel rapl floppy input_leds psmouse i2c_piix4 vga16fb mac_hid i2c_smbus vgastate serio_raw bochs qemu_fw_cfg pata_acpi sch_fq_codel rbd msr parport_pc ppdev lp parport efi_pstore

Nov 14 11:48:11 ceph-0005 kernel: [  155.116339] CR2: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.116574] ---[ end trace 0000000000000000
]---
Nov 14 11:48:11 ceph-0005 kernel: [  155.116826] RIP: 0010:strcmp+0x1c/0x40
Nov 14 11:48:11 ceph-0005 kernel: [  155.117058] Code: 90 90 90 90 90 90 90 90
90 90 90 90 90 90 31 c0 eb 14 66 66 2e 0f 1f 84 00 00 00 00 00 90 48 83 c0 01 84
d2 74 19 0f b6 14 07 <3a> 14 06 74 ef 19 c0 83 c8 01 31 d2 31 f6 31 ff c3 cc cc
cc cc 31
Nov 14 11:48:11 ceph-0005 kernel: [  155.118070] RSP: 0018:ffff8881536875c0
EFLAGS: 00010246
Nov 14 11:48:11 ceph-0005 kernel: [  155.118362] RAX: 0000000000000000 RBX:
ffff888116003200 RCX: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.118748] RDX: 0000000000000063 RSI:
0000000000000000 RDI: ffff88810126c900
Nov 14 11:48:11 ceph-0005 kernel: [  155.119116] RBP: ffff8881536876a8 R08:
0000000000000000 R09: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.119492] R10: 0000000000000000 R11:
0000000000000000 R12: dffffc0000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.119865] R13: ffff8881061d0000 R14:
0000000000000000 R15: 0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.120242] FS:  000074a85c082840(0000)
GS:ffff8882401a4000(0000) knlGS:0000000000000000
Nov 14 11:48:11 ceph-0005 kernel: [  155.120704] CS:  0010 DS: 0000 ES: 0000
CR0: 0000000080050033
Nov 14 11:48:11 ceph-0005 kernel: [  155.121008] CR2: 0000000000000000 CR3:
0000000110ebd001 CR4: 0000000000772ef0
Nov 14 11:48:11 ceph-0005 kernel: [  155.121409] PKRU: 55555554

We have issue here [1] if fs_name == NULL:

const char fs_name = mdsc->fsc->mount_options->mds_namespace;
    ...
    if (auth->match.fs_name && strcmp(auth->match.fs_name, fs_name)) {
            / fsname mismatch, try next one */
            return 0;
    }

v2
Patrick Donnelly suggested that: In summary, we should definitely start decoding fs_name from the MDSMap and do strict authorizations checks against it. Note that the --mds_namespace should only be used for selecting the file system to mount and nothing else. It's possible no mds_namespace is specified but the kernel will mount the only file system that exists which may have name "foo".

This patch reworks ceph_mdsmap_decode() and namespace_equals() with the goal of supporting the suggested concept. Now struct ceph_mdsmap contains m_fs_name field that receives copy of extracted FS name by ceph_extract_encoded_string(). For the case of "old" CephFS file systems, it is used "cephfs" name. Also, namespace_equals() method has been reworked with the goal of proper names comparison.

[1] https://elixir.bootlin.com/linux/v6.18-rc4/source/fs/ceph/mds_client.c#L5666

Fixes 22c73d52a6d0 ("ceph: fix multifs mds auth caps issue")
cc Kotresh Hiremath Ravishankar <[email protected]>
cc Alex Markuze <[email protected]>
cc Ilya Dryomov <[email protected]>
cc Patrick Donnelly <[email protected]>
cc Ceph Development <[email protected]>
---
 fs/ceph/mds_client.c         |  2 +-
 fs/ceph/mdsmap.c             | 26 ++++++++++++++++++++------
 fs/ceph/mdsmap.h             |  1 +
 fs/ceph/super.h              | 19 ++++++++++++++++---
 include/linux/ceph/ceph_fs.h |  6 ++++++
 5 files changed, 44 insertions(+), 10 deletions(-)
fs/ceph/mds_client.c +1 -1
index 7e4eab824dae..1c02f97c5b52 100644
@@ -5671,7 +5671,7 @@ static int ceph_mds_auth_match(struct ceph_mds_client *mdsc,
        u32 caller_uid = from_kuid(&init_user_ns, cred->fsuid);
        u32 caller_gid = from_kgid(&init_user_ns, cred->fsgid);
        struct ceph_client *cl = mdsc->fsc->client;
-       const char *fs_name = mdsc->fsc->mount_options->mds_namespace;
+       const char *fs_name = mdsc->mdsmap->m_fs_name;
        const char *spath = mdsc->fsc->mount_options->server_path;
        bool gid_matched = false;
        u32 gid, tlen, len;
fs/ceph/mdsmap.c +20 -6
index 2c7b151a7c95..b54a226510f1 100644
@@ -353,22 +353,35 @@ struct ceph_mdsmap *ceph_mdsmap_decode(struct ceph_mds_client *mdsc, void **p,
                __decode_and_drop_type(p, end, u8, bad_ext);
        }
        if (mdsmap_ev >= 8) {
-               u32 fsname_len;
+               size_t fsname_len;
+
                /* enabled */
                ceph_decode_8_safe(p, end, m->m_enabled, bad_ext);
+
                /* fs_name */
-               ceph_decode_32_safe(p, end, fsname_len, bad_ext);
+               m->m_fs_name = ceph_extract_encoded_string(p, end,
+                                                          &fsname_len,
+                                                          GFP_NOFS);
+               if (IS_ERR(m->m_fs_name)) {
+                       m->m_fs_name = NULL;
+                       goto nomem;
+               }
 
                /* validate fsname against mds_namespace */
-               if (!namespace_equals(mdsc->fsc->mount_options, *p,
+               if (!namespace_equals(mdsc->fsc->mount_options, m->m_fs_name,
                                      fsname_len)) {
                        pr_warn_client(cl, "fsname %*pE doesn't match mds_namespace %s\n",
-                                      (int)fsname_len, (char *)*p,
+                                      (int)fsname_len, m->m_fs_name,
                                       mdsc->fsc->mount_options->mds_namespace);
                        goto bad;
                }
-               /* skip fsname after validation */
-               ceph_decode_skip_n(p, end, fsname_len, bad);
+       } else {
+               m->m_enabled = false;
+               /*
+                * name for "old" CephFS file systems,
+                * see ceph.git e2b151d009640114b2565c901d6f41f6cd5ec652
+                */
+               m->m_fs_name = kstrdup(CEPH_OLD_FS_NAME, GFP_NOFS);
        }
        /* damaged */
        if (mdsmap_ev >= 9) {
@@ -430,6 +443,7 @@ void ceph_mdsmap_destroy(struct ceph_mdsmap *m)
                kfree(m->m_info);
        }
        kfree(m->m_data_pg_pools);
+       kfree(m->m_fs_name);
        kfree(m);
 }
 
fs/ceph/mdsmap.h +1 -0
index 1f2171dd01bf..d48d07c3516d 100644
@@ -45,6 +45,7 @@ struct ceph_mdsmap {
        bool m_enabled;
        bool m_damaged;
        int m_num_laggy;
+       char *m_fs_name;
 };
 
 static inline struct ceph_entity_addr *
fs/ceph/super.h +16 -3
index a1f781c46b41..c53bec40ea69 100644
@@ -104,6 +104,8 @@ struct ceph_mount_options {
        struct fscrypt_dummy_policy dummy_enc_policy;
 };
 
+#define CEPH_NAMESPACE_WIDCARD         "*"
+
 /*
  * Check if the mds namespace in ceph_mount_options matches
  * the passed in namespace string. First time match (when
@@ -113,9 +115,20 @@ struct ceph_mount_options {
 static inline int namespace_equals(struct ceph_mount_options *fsopt,
                                   const char *namespace, size_t len)
 {
-       return !(fsopt->mds_namespace &&
-                (strlen(fsopt->mds_namespace) != len ||
-                 strncmp(fsopt->mds_namespace, namespace, len)));
+       if (!fsopt->mds_namespace && !namespace)
+               return true;
+
+       if (!fsopt->mds_namespace)
+               return true;
+
+       if (strcmp(fsopt->mds_namespace, CEPH_NAMESPACE_WIDCARD) == 0)
+               return true;
+
+       if (!namespace)
+               return false;
+
+       return !(strlen(fsopt->mds_namespace) != len ||
+                 strncmp(fsopt->mds_namespace, namespace, len));
 }
 
 /* mount state */
include/linux/ceph/ceph_fs.h +6 -1
index c7f2c63b3bc3..08e5dbe15ca4 100644
@@ -31,6 +31,12 @@
 #define CEPH_INO_CEPH   2            /* hidden .ceph dir */
 #define CEPH_INO_GLOBAL_SNAPREALM  3 /* global dummy snaprealm */
 
+/*
+ * name for "old" CephFS file systems,
+ * see ceph.git e2b151d009640114b2565c901d6f41f6cd5ec652
+ */
+#define CEPH_OLD_FS_NAME       "cephfs"
+
 /* arbitrary limit on max # of monitors (cluster of 3 is typical) */
 #define CEPH_MAX_MON   31
 
--

2.52.0

Signature · 1 line
Viacheslav Dubeyko <[email protected]>
#3 lore raw
Quoted 13 lines · Viacheslav Dubeyko
Quoted 5 lines · Patrick Donnelly

Hi Slava,

A few things:

* CEPH_NAMESPACE_WIDCARD -> CEPH_NAMESPACE_WILDCARD ?

Yeah, sure :) My bad.

Quoted 2 lines

* The comment "name for "old" CephFS file systems," appears twice. Probably only necessary in the header.

Quoted 7 lines

Makes sense.

Quoted 3 lines

* You also need to update ceph_mds_auth_match to call namespace_equals.

Do you mean this code [1]?

Yes, that's it.

Quoted 7 lines
Quoted 3 lines

Suggest documenting (in the man page) that
mds_namespace mntopt can be "*" now.

Agreed. Which man page do you mean? Because 'man mount' contains no info about Ceph. And it is my worry that we have nothing there. We should do something about it. Do I miss something here?

https://github.com/ceph/ceph/blob/2e87714b94a9e16c764ef6f97de50aecf1b0c41e/doc/man/8/mount.ceph.rst

^ that file. (There may be others but I think that's the main one users look at.)

Signature · 5 lines
Patrick Donnelly, Ph.D.
He / Him / His
Red Hat Partner Engineer
IBM, Inc.
GPG: 19F28A586F808C2402351B93C3301A3E258DD79D
maintainer
#4 lore raw
Quoted 4 lines · Patrick Donnelly
Quoted 4 lines
Quoted 3 lines

Suggest documenting (in the man page) that
mds_namespace mntopt can be "*" now.

Quoted 8 lines
Quoted 3 lines

Agreed. Which man page do you mean? Because 'man mount' contains no info about Ceph. And it is my worry that we have nothing there. We should do something about it. Do I miss something here?

https://github.com/ceph/ceph/blob/2e87714b94a9e16c764ef6f97de50aecf1b0c41e/doc/man/8/mount.ceph.rst

^ that file. (There may be others but I think that's the main one users look at.)

Hi Patrick,

Is that actually desired? After having to take a look at the userspace code to suggest the path forward in the thread for the previous version of Slava's patch, I got the impression that "*" was just an MDSAuthCaps thing. It's one of the two ways to express a match for any fs_name (the other is not specifying fs_name in the cap at all).

I don't think this kind of matching is supposed to occur when mounting. When fs_name is passed via ceph_select_filesystem() API or --client_fs option on mount it appears to be a literal comparison that happens in FSMapUser::get_fs_cid(). Assuming "*" isn't a valid fs_name (it it was the cap syntax wouldn't make sense), the user passing "*" for fs_name when mounting would always lead to an error.

Thanks,

Ilya

#5 lore raw
Quoted 15 lines · Ilya Dryomov
Quoted 4 lines · Patrick Donnelly
Quoted 4 lines
Quoted 3 lines

Suggest documenting (in the man page) that
mds_namespace mntopt can be "*" now.

Quoted 8 lines
Quoted 3 lines

Agreed. Which man page do you mean? Because 'man mount' contains no info about Ceph. And it is my worry that we have nothing there. We should do something about it. Do I miss something here?

https://github.com/ceph/ceph/blob/2e87714b94a9e16c764ef6f97de50aecf1b0c41e/doc/man/8/mount.ceph.rst

^ that file. (There may be others but I think that's the main one users look at.)

Quoted 7 lines

Hi Patrick,

Is that actually desired? After having to take a look at the userspace code to suggest the path forward in the thread for the previous version of Slava's patch, I got the impression that "*" was just an MDSAuthCaps thing. It's one of the two ways to express a match for any fs_name (the other is not specifying fs_name in the cap at all).

Well, '*' is not a valid name for a file system (enforced via src/mon/MonCommands.h) so it's fairly harmless to allow. I think there is a potential issue with "legacy fscid" (which indicates what the default file system to mount should be according to the ceph admin). That only really influences the ceph-fuse client I think because -- after now looking at the kernel code -- it seems the kernel just mounts whatever it can find in the FSMap if no mds_namespace is specified. (If it were to respect the configured legacy file system, it should sub to "mdsmap" if no mds_namespace is specified. s.f. src/mon/MDSMonitor.cc)

So I think there is a potential for "*" to be different from nothing. The latter is supposed to be whatever the legacy fscid is.

Slava: I also want to point out that ceph_mdsc_handle_fsmap should also be calling namespace_equals (it currently duplicates the old logic).

Quoted 4 lines

I don't think this kind of matching is supposed to occur when mounting. When fs_name is passed via ceph_select_filesystem() API or --client_fs option on mount it appears to be a literal comparison that happens in FSMapUser::get_fs_cid().

Sorry, are you mixing the kernel and C++? I'm not following.

Signature · 5 lines
Patrick Donnelly, Ph.D.
He / Him / His
Red Hat Partner Engineer
IBM, Inc.
GPG: 19F28A586F808C2402351B93C3301A3E258DD79D
maintainer
#6 lore raw
Quoted 19 lines · Patrick Donnelly
Quoted 17 lines · Ilya Dryomov
Quoted 4 lines · Patrick Donnelly
Quoted 4 lines
Quoted 3 lines

Suggest documenting (in the man page) that
mds_namespace mntopt can be "*" now.

Quoted 8 lines
Quoted 3 lines

Agreed. Which man page do you mean? Because 'man mount' contains no info about Ceph. And it is my worry that we have nothing there. We should do something about it. Do I miss something here?

https://github.com/ceph/ceph/blob/2e87714b94a9e16c764ef6f97de50aecf1b0c41e/doc/man/8/mount.ceph.rst

^ that file. (There may be others but I think that's the main one users look at.)

Hi Patrick,

Quoted 8 lines
Quoted 5 lines

Is that actually desired? After having to take a look at the userspace code to suggest the path forward in the thread for the previous version of Slava's patch, I got the impression that "*" was just an MDSAuthCaps thing. It's one of the two ways to express a match for any fs_name (the other is not specifying fs_name in the cap at all).

Well, '*' is not a valid name for a file system (enforced via src/mon/MonCommands.h) so it's fairly harmless to allow. I think there

By "allow", do you mean "handle specially"? AFAIU passing "-o mds_namespace=*" on mount is already allowed in the sense that the value (a single "*" character) would be accepted and then matched literally against the names in the fsmap. Because "*" isn't a valid name, such an attempt to mount is guaranteed to fail with ENOENT.

Quoted 8 lines

is a potential issue with "legacy fscid" (which indicates what the default file system to mount should be according to the ceph admin). That only really influences the ceph-fuse client I think because -- after now looking at the kernel code -- it seems the kernel just mounts whatever it can find in the FSMap if no mds_namespace is specified. (If it were to respect the configured legacy file system, it should sub to "mdsmap" if no mds_namespace is specified. s.f. src/mon/MDSMonitor.cc)

In create_fs_client() the kernel asks for an unqualified mdsmap if no mds_namespace is specified:

    if (!fsopt->mds_namespace) {
            ceph_monc_want_map(&fsc->client->monc, CEPH_SUB_MDSMAP,
                               0, true);
    } else {
            ceph_monc_want_map(&fsc->client->monc, CEPH_SUB_FSMAP,
                               0, false);
    }

I thought a subscription for an unqualified mdsmap (i.e. a generic "mdsmap" instead of a specific "mdsmap.<fscid>") was how the default filesystem thing worked. Does this get overridden somewhere or am I missing something else?

Quoted 3 lines

So I think there is a potential for "*" to be different from nothing. The latter is supposed to be whatever the legacy fscid is.

Are you stating this in the context of mounting or in the context of the MDS auth cap matching? In my previous message, I was trying to separate the case of mounting (where the name can be supplied by the user via mds_namespace option) from the case of ceph_mds_auth_match() where the name that is coming from the mdsmap is matched against the name in the cap. AFAIU in userspace "*" has special meaning only in the latter case.

Quoted 11 lines

Slava: I also want to point out that ceph_mdsc_handle_fsmap should also be calling namespace_equals (it currently duplicates the old logic).

Quoted 4 lines

I don't think this kind of matching is supposed to occur when mounting. When fs_name is passed via ceph_select_filesystem() API or --client_fs option on mount it appears to be a literal comparison that happens in FSMapUser::get_fs_cid().

Sorry, are you mixing the kernel and C++? I'm not following.

I'm trying to ensure that we don't introduce an unnecessary discrepancy in behavior between the kernel client and the userspace client/gateways. If passing "*" for fs_name is a sure way to make Client::mount() fail with ENOENT in userspace, the kernel client shouldn't be doing (and on top of that documenting) something different IMO.

Thanks,

Ilya

#7 lore raw
Quoted 27 lines · Ilya Dryomov
Quoted 25 lines · Patrick Donnelly
Quoted 22 lines · Ilya Dryomov
Quoted 4 lines · Patrick Donnelly
Quoted 4 lines
Quoted 3 lines

Suggest documenting (in the man page) that
mds_namespace mntopt can be "*" now.

Quoted 8 lines
Quoted 3 lines

Agreed. Which man page do you mean? Because 'man mount' contains no info about Ceph. And it is my worry that we have nothing there. We should do something about it. Do I miss something here?

https://github.com/ceph/ceph/blob/2e87714b94a9e16c764ef6f97de50aecf1b0c41e/doc/man/8/mount.ceph.rst

^ that file. (There may be others but I think that's the main one users look at.)

Hi Patrick,

Is that actually desired? After having to take a look at the userspace code to suggest the path forward in the thread for the previous version of Slava's patch, I got the impression that "*" was just an MDSAuthCaps thing. It's one of the two ways to express a match for any fs_name (the other is not specifying fs_name in the cap at all).

Quoted 8 lines
Quoted 2 lines

Well, '*' is not a valid name for a file system (enforced via src/mon/MonCommands.h) so it's fairly harmless to allow. I think there

By "allow", do you mean "handle specially"? AFAIU passing "-o mds_namespace=*" on mount is already allowed in the sense that the value (a single "*" character) would be accepted and then matched literally against the names in the fsmap. Because "*" isn't a valid name, such an attempt to mount is guaranteed to fail with ENOENT.

Yes, correct.

Quoted 20 lines
Quoted 8 lines

is a potential issue with "legacy fscid" (which indicates what the default file system to mount should be according to the ceph admin). That only really influences the ceph-fuse client I think because -- after now looking at the kernel code -- it seems the kernel just mounts whatever it can find in the FSMap if no mds_namespace is specified. (If it were to respect the configured legacy file system, it should sub to "mdsmap" if no mds_namespace is specified. s.f. src/mon/MDSMonitor.cc)

In create_fs_client() the kernel asks for an unqualified mdsmap if no mds_namespace is specified:

    if (!fsopt->mds_namespace) {
            ceph_monc_want_map(&fsc->client->monc, CEPH_SUB_MDSMAP,
                               0, true);
    } else {
            ceph_monc_want_map(&fsc->client->monc, CEPH_SUB_FSMAP,
                               0, false);
    }
Quoted 4 lines

I thought a subscription for an unqualified mdsmap (i.e. a generic "mdsmap" instead of a specific "mdsmap.<fscid>") was how the default filesystem thing worked. Does this get overridden somewhere or am I missing something else?

Ah, I didn't see that code. Yes, this looks right then.

Quoted 6 lines
Quoted 3 lines

So I think there is a potential for "*" to be different from nothing. The latter is supposed to be whatever the legacy fscid is.

Are you stating this in the context of mounting or in the context of the MDS auth cap matching?

mounting.

Quoted 6 lines

In my previous message, I was trying to
separate the case of mounting (where the name can be supplied by the user via mds_namespace option) from the case of ceph_mds_auth_match() where the name that is coming from the mdsmap is matched against the name in the cap. AFAIU in userspace "*" has special meaning only in the latter case.

I understand what you've been saying. I contend that treating "*" specially for mds_namespace mntopt could be useful: you can select *any* available file system even if none of them are marked as the legacy fscid.

Big picture I don't think this matters much. It'd probably be better to only use namespace_equals (no "*" handling) for mntopt matching and something else for the mds auth cap matching (yes "*" handling).

Quoted 9 lines
Quoted 9 lines

Slava: I also want to point out that ceph_mdsc_handle_fsmap should also be calling namespace_equals (it currently duplicates the old logic).

Quoted 4 lines

I don't think this kind of matching is supposed to occur when mounting. When fs_name is passed via ceph_select_filesystem() API or --client_fs option on mount it appears to be a literal comparison that happens in FSMapUser::get_fs_cid().

Quoted 7 lines
Quoted 1 line

Sorry, are you mixing the kernel and C++? I'm not following.

I'm trying to ensure that we don't introduce an unnecessary discrepancy in behavior between the kernel client and the userspace client/gateways. If passing "*" for fs_name is a sure way to make Client::mount() fail with ENOENT in userspace, the kernel client shouldn't be doing (and on top of that documenting) something different IMO.

I wouldn't suggest the kernel change without also updating userspace. In any case, we can drop the suggestion.

Signature · 5 lines
Patrick Donnelly, Ph.D.
He / Him / His
Red Hat Partner Engineer
IBM, Inc.
GPG: 19F28A586F808C2402351B93C3301A3E258DD79D
#8 lore raw
Quoted 102 lines · Patrick Donnelly
Quoted 27 lines · Ilya Dryomov
Quoted 25 lines · Patrick Donnelly
Quoted 22 lines · Ilya Dryomov
Quoted 4 lines · Patrick Donnelly
Quoted 4 lines
Quoted 3 lines

Suggest documenting (in the man page) that
mds_namespace mntopt can be "*" now.

Quoted 8 lines
Quoted 3 lines

Agreed. Which man page do you mean? Because 'man mount' contains no info about Ceph. And it is my worry that we have nothing there. We should do something about it. Do I miss something here?

https://github.com/ceph/ceph/blob/2e87714b94a9e16c764ef6f97de50aecf1b0c41e/doc/man/8/mount.ceph.rst

^ that file. (There may be others but I think that's the main one users look at.)

Hi Patrick,

Is that actually desired? After having to take a look at the userspace code to suggest the path forward in the thread for the previous version of Slava's patch, I got the impression that "*" was just an MDSAuthCaps thing. It's one of the two ways to express a match for any fs_name (the other is not specifying fs_name in the cap at all).

Quoted 8 lines
Quoted 2 lines

Well, '*' is not a valid name for a file system (enforced via src/mon/MonCommands.h) so it's fairly harmless to allow. I think there

By "allow", do you mean "handle specially"? AFAIU passing "-o mds_namespace=*" on mount is already allowed in the sense that the value (a single "*" character) would be accepted and then matched literally against the names in the fsmap. Because "*" isn't a valid name, such an attempt to mount is guaranteed to fail with ENOENT.

Yes, correct.

Quoted 20 lines
Quoted 8 lines

is a potential issue with "legacy fscid" (which indicates what the default file system to mount should be according to the ceph admin). That only really influences the ceph-fuse client I think because -- after now looking at the kernel code -- it seems the kernel just mounts whatever it can find in the FSMap if no mds_namespace is specified. (If it were to respect the configured legacy file system, it should sub to "mdsmap" if no mds_namespace is specified. s.f. src/mon/MDSMonitor.cc)

In create_fs_client() the kernel asks for an unqualified mdsmap if no mds_namespace is specified:

    if (!fsopt->mds_namespace) {
            ceph_monc_want_map(&fsc->client->monc, CEPH_SUB_MDSMAP,
                               0, true);
    } else {
            ceph_monc_want_map(&fsc->client->monc, CEPH_SUB_FSMAP,
                               0, false);
    }
Quoted 4 lines

I thought a subscription for an unqualified mdsmap (i.e. a generic "mdsmap" instead of a specific "mdsmap.<fscid>") was how the default filesystem thing worked. Does this get overridden somewhere or am I missing something else?

Ah, I didn't see that code. Yes, this looks right then.

Quoted 6 lines
Quoted 3 lines

So I think there is a potential for "*" to be different from nothing. The latter is supposed to be whatever the legacy fscid is.

Are you stating this in the context of mounting or in the context of the MDS auth cap matching?

mounting.

Quoted 6 lines

In my previous message, I was trying to
separate the case of mounting (where the name can be supplied by the user via mds_namespace option) from the case of ceph_mds_auth_match() where the name that is coming from the mdsmap is matched against the name in the cap. AFAIU in userspace "*" has special meaning only in the latter case.

I understand what you've been saying. I contend that treating "*" specially for mds_namespace mntopt could be useful: you can select *any* available file system even if none of them are marked as the legacy fscid.

Big picture I don't think this matters much. It'd probably be better to only use namespace_equals (no "*" handling) for mntopt matching and something else for the mds auth cap matching (yes "*" handling).

Quoted 11 lines
Quoted 10 lines

Slava: I also want to point out that ceph_mdsc_handle_fsmap should also be calling namespace_equals (it currently duplicates the old logic).

Quoted 4 lines

I don't think this kind of matching is supposed to occur when mounting. When fs_name is passed via ceph_select_filesystem() API or --client_fs option on mount it appears to be a literal comparison that happens in FSMapUser::get_fs_cid().

Sorry, are you mixing the kernel and C++? I'm not following.

Quoted 8 lines
Quoted 5 lines

I'm trying to ensure that we don't introduce an unnecessary discrepancy in behavior between the kernel client and the userspace client/gateways. If passing "*" for fs_name is a sure way to make Client::mount() fail with ENOENT in userspace, the kernel client shouldn't be doing (and on top of that documenting) something different IMO.

I wouldn't suggest the kernel change without also updating userspace. In any case, we can drop the suggestion.

OK. Finally, I assume that we agreed to drop: "Suggest documenting (in the man page) that
mds_namespace mntopt can be "*" now." Am I correct? :)

Thanks,
Slava.

#9 lore raw
Quoted 110 lines · Viacheslav Dubeyko
Quoted 108 lines · Patrick Donnelly
Quoted 27 lines · Ilya Dryomov
Quoted 25 lines · Patrick Donnelly
Quoted 22 lines · Ilya Dryomov
Quoted 4 lines · Patrick Donnelly
Quoted 4 lines
Quoted 3 lines

Suggest documenting (in the man page) that
mds_namespace mntopt can be "*" now.

Quoted 8 lines
Quoted 3 lines

Agreed. Which man page do you mean? Because 'man mount' contains no info about Ceph. And it is my worry that we have nothing there. We should do something about it. Do I miss something here?

https://github.com/ceph/ceph/blob/2e87714b94a9e16c764ef6f97de50aecf1b0c41e/doc/man/8/mount.ceph.rst

^ that file. (There may be others but I think that's the main one users look at.)

Hi Patrick,

Is that actually desired? After having to take a look at the userspace code to suggest the path forward in the thread for the previous version of Slava's patch, I got the impression that "*" was just an MDSAuthCaps thing. It's one of the two ways to express a match for any fs_name (the other is not specifying fs_name in the cap at all).

Quoted 8 lines
Quoted 2 lines

Well, '*' is not a valid name for a file system (enforced via src/mon/MonCommands.h) so it's fairly harmless to allow. I think there

By "allow", do you mean "handle specially"? AFAIU passing "-o mds_namespace=*" on mount is already allowed in the sense that the value (a single "*" character) would be accepted and then matched literally against the names in the fsmap. Because "*" isn't a valid name, such an attempt to mount is guaranteed to fail with ENOENT.

Yes, correct.

Quoted 20 lines
Quoted 8 lines

is a potential issue with "legacy fscid" (which indicates what the default file system to mount should be according to the ceph admin). That only really influences the ceph-fuse client I think because -- after now looking at the kernel code -- it seems the kernel just mounts whatever it can find in the FSMap if no mds_namespace is specified. (If it were to respect the configured legacy file system, it should sub to "mdsmap" if no mds_namespace is specified. s.f. src/mon/MDSMonitor.cc)

In create_fs_client() the kernel asks for an unqualified mdsmap if no mds_namespace is specified:

    if (!fsopt->mds_namespace) {
            ceph_monc_want_map(&fsc->client->monc, CEPH_SUB_MDSMAP,
                               0, true);
    } else {
            ceph_monc_want_map(&fsc->client->monc, CEPH_SUB_FSMAP,
                               0, false);
    }
Quoted 4 lines

I thought a subscription for an unqualified mdsmap (i.e. a generic "mdsmap" instead of a specific "mdsmap.<fscid>") was how the default filesystem thing worked. Does this get overridden somewhere or am I missing something else?

Ah, I didn't see that code. Yes, this looks right then.

Quoted 6 lines
Quoted 3 lines

So I think there is a potential for "*" to be different from nothing. The latter is supposed to be whatever the legacy fscid is.

Are you stating this in the context of mounting or in the context of the MDS auth cap matching?

mounting.

Quoted 6 lines

In my previous message, I was trying to
separate the case of mounting (where the name can be supplied by the user via mds_namespace option) from the case of ceph_mds_auth_match() where the name that is coming from the mdsmap is matched against the name in the cap. AFAIU in userspace "*" has special meaning only in the latter case.

I understand what you've been saying. I contend that treating "*" specially for mds_namespace mntopt could be useful: you can select *any* available file system even if none of them are marked as the legacy fscid.

Big picture I don't think this matters much. It'd probably be better to only use namespace_equals (no "*" handling) for mntopt matching and something else for the mds auth cap matching (yes "*" handling).

Quoted 16 lines
Quoted 10 lines

Slava: I also want to point out that ceph_mdsc_handle_fsmap should also be calling namespace_equals (it currently duplicates the old logic).

Quoted 4 lines

I don't think this kind of matching is supposed to occur when mounting. When fs_name is passed via ceph_select_filesystem() API or --client_fs option on mount it appears to be a literal comparison that happens in FSMapUser::get_fs_cid().

Sorry, are you mixing the kernel and C++? I'm not following.

I'm trying to ensure that we don't introduce an unnecessary discrepancy in behavior between the kernel client and the userspace client/gateways. If passing "*" for fs_name is a sure way to make Client::mount() fail with ENOENT in userspace, the kernel client shouldn't be doing (and on top of that documenting) something different IMO.

Quoted 6 lines
Quoted 2 lines

I wouldn't suggest the kernel change without also updating userspace. In any case, we can drop the suggestion.

OK. Finally, I assume that we agreed to drop: "Suggest documenting (in the man page) that
mds_namespace mntopt can be "*" now." Am I correct? :)

Not just documentation but in the code too. namespace_equals should only be used for comparisons with the mds_namespace mntopt.

Signature · 5 lines
Patrick Donnelly, Ph.D.
He / Him / His
Red Hat Partner Engineer
IBM, Inc.
GPG: 19F28A586F808C2402351B93C3301A3E258DD79D
#10 lore raw
In reply to Patrick Donnelly
Quoted 29 lines · Patrick Donnelly
Quoted 13 lines · Viacheslav Dubeyko
Quoted 5 lines · Patrick Donnelly

Hi Slava,

A few things:

* CEPH_NAMESPACE_WIDCARD -> CEPH_NAMESPACE_WILDCARD ?

Yeah, sure :) My bad.

Quoted 2 lines

* The comment "name for "old" CephFS file systems," appears twice. Probably only necessary in the header.

Quoted 7 lines

Makes sense.

Quoted 3 lines

* You also need to update ceph_mds_auth_match to call namespace_equals.

Do you mean this code [1]?

Yes, that's it.

Quoted 4 lines
Quoted 3 lines

Suggest documenting (in the man page) that
mds_namespace mntopt can be "*" now.

Quoted 8 lines
Quoted 3 lines

Agreed. Which man page do you mean? Because 'man mount' contains no info about Ceph. And it is my worry that we have nothing there. We should do something about it. Do I miss something here?

https://github.com/ceph/ceph/blob/2e87714b94a9e16c764ef6f97de50aecf1b0c41e/doc/man/8/mount.ceph.rst

^ that file. (There may be others but I think that's the main one users look at.)

So, should we consider to add CephFS mount options' details into man page for generic mount command?

Thanks,
Slava.

#11 lore raw
Quoted 35 lines · Viacheslav Dubeyko
Quoted 33 lines · Patrick Donnelly
Quoted 13 lines · Viacheslav Dubeyko
Quoted 5 lines · Patrick Donnelly

Hi Slava,

A few things:

* CEPH_NAMESPACE_WIDCARD -> CEPH_NAMESPACE_WILDCARD ?

Yeah, sure :) My bad.

Quoted 2 lines

* The comment "name for "old" CephFS file systems," appears twice. Probably only necessary in the header.

Quoted 7 lines

Makes sense.

Quoted 3 lines

* You also need to update ceph_mds_auth_match to call namespace_equals.

Do you mean this code [1]?

Yes, that's it.

Quoted 7 lines
Quoted 3 lines

Suggest documenting (in the man page) that
mds_namespace mntopt can be "*" now.

Agreed. Which man page do you mean? Because 'man mount' contains no info about Ceph. And it is my worry that we have nothing there. We should do something about it. Do I miss something here?

Quoted 7 lines
Quoted 4 lines

https://github.com/ceph/ceph/blob/2e87714b94a9e16c764ef6f97de50aecf1b0c41e/doc/man/8/mount.ceph.rst

^ that file. (There may be others but I think that's the main one users look at.)

So, should we consider to add CephFS mount options' details into man page for generic mount command?

For the generic mount command? No, only in mount.ceph(8).

Signature · 5 lines
Patrick Donnelly, Ph.D.
He / Him / His
Red Hat Partner Engineer
IBM, Inc.
GPG: 19F28A586F808C2402351B93C3301A3E258DD79D
#12 lore raw
Quoted 39 lines · Patrick Donnelly
Quoted 37 lines · Viacheslav Dubeyko
Quoted 35 lines · Patrick Donnelly
Quoted 13 lines · Viacheslav Dubeyko
Quoted 5 lines · Patrick Donnelly

Hi Slava,

A few things:

* CEPH_NAMESPACE_WIDCARD -> CEPH_NAMESPACE_WILDCARD ?

Yeah, sure :) My bad.

Quoted 2 lines

* The comment "name for "old" CephFS file systems," appears twice. Probably only necessary in the header.

Quoted 7 lines

Makes sense.

Quoted 3 lines

* You also need to update ceph_mds_auth_match to call namespace_equals.

Do you mean this code [1]?

Yes, that's it.

Quoted 7 lines
Quoted 3 lines

Suggest documenting (in the man page) that
mds_namespace mntopt can be "*" now.

Agreed. Which man page do you mean? Because 'man mount' contains no info about Ceph. And it is my worry that we have nothing there. We should do something about it. Do I miss something here?

https://github.com/ceph/ceph/blob/2e87714b94a9e16c764ef6f97de50aecf1b0c41e/doc/man/8/mount.ceph.rst

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

^ that file. (There may be others but I think that's the main one users look at.)

So, should we consider to add CephFS mount options' details into man page for generic mount command?

For the generic mount command? No, only in mount.ceph(8).

I meant that, currently, we have no information about CephFS mount options in man page for generic mount command. From my point of view, it makes sense to have some explanation of CephFS mount options there. So, I see the point to send a patch for adding the explanation of CephFS mount options into man page of generic mount command. As a result, we will have brief information in man page for generic mount command and detailed explanation in mount.ceph(8). How do you feel about it?

Thanks,
Slava.

#13 lore raw
Quoted 50 lines · Viacheslav Dubeyko
Quoted 39 lines · Patrick Donnelly
Quoted 37 lines · Viacheslav Dubeyko
Quoted 35 lines · Patrick Donnelly
Quoted 13 lines · Viacheslav Dubeyko
Quoted 5 lines · Patrick Donnelly

Hi Slava,

A few things:

* CEPH_NAMESPACE_WIDCARD -> CEPH_NAMESPACE_WILDCARD ?

Yeah, sure :) My bad.

Quoted 2 lines

* The comment "name for "old" CephFS file systems," appears twice. Probably only necessary in the header.

Quoted 7 lines

Makes sense.

Quoted 3 lines

* You also need to update ceph_mds_auth_match to call namespace_equals.

Do you mean this code [1]?

Yes, that's it.

Quoted 7 lines
Quoted 3 lines

Suggest documenting (in the man page) that
mds_namespace mntopt can be "*" now.

Agreed. Which man page do you mean? Because 'man mount' contains no info about Ceph. And it is my worry that we have nothing there. We should do something about it. Do I miss something here?

https://github.com/ceph/ceph/blob/2e87714b94a9e16c764ef6f97de50aecf1b0c41e/doc/man/8/mount.ceph.rst

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

^ that file. (There may be others but I think that's the main one users look at.)

So, should we consider to add CephFS mount options' details into man page for generic mount command?

For the generic mount command? No, only in mount.ceph(8).

Quoted 7 lines

I meant that, currently, we have no information about CephFS mount options in man page for generic mount command. From my point of view, it makes sense to have some explanation of CephFS mount options there. So, I see the point to send a patch for adding the explanation of CephFS mount options into man page of generic mount command. As a result, we will have brief information in man page for generic mount command and detailed explanation in mount.ceph(8). How do you feel about it?

I didn't realize that the mount(8) manpage had FS specific options. That would be good to add, certainly. I would also recommend pointing out in that same man page that mount.ceph has some user-friendly helpers (like pulling information out of the ceph.conf) so we recommend using it routinely.

Signature · 5 lines
Patrick Donnelly, Ph.D.
He / Him / His
Red Hat Partner Engineer
IBM, Inc.
GPG: 19F28A586F808C2402351B93C3301A3E258DD79D
#14 lore raw
Quoted 60 lines · Patrick Donnelly
Quoted 50 lines · Viacheslav Dubeyko
Quoted 39 lines · Patrick Donnelly
Quoted 37 lines · Viacheslav Dubeyko
Quoted 35 lines · Patrick Donnelly
Quoted 13 lines · Viacheslav Dubeyko
Quoted 5 lines · Patrick Donnelly

Hi Slava,

A few things:

* CEPH_NAMESPACE_WIDCARD -> CEPH_NAMESPACE_WILDCARD ?

Yeah, sure :) My bad.

Quoted 2 lines

* The comment "name for "old" CephFS file systems," appears twice. Probably only necessary in the header.

Quoted 7 lines

Makes sense.

Quoted 3 lines

* You also need to update ceph_mds_auth_match to call namespace_equals.

Do you mean this code [1]?

Yes, that's it.

Quoted 7 lines
Quoted 3 lines

Suggest documenting (in the man page) that
mds_namespace mntopt can be "*" now.

Agreed. Which man page do you mean? Because 'man mount' contains no info about Ceph. And it is my worry that we have nothing there. We should do something about it. Do I miss something here?

https://github.com/ceph/ceph/blob/2e87714b94a9e16c764ef6f97de50aecf1b0c41e/doc/man/8/mount.ceph.rst

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

^ that file. (There may be others but I think that's the main one users look at.)

So, should we consider to add CephFS mount options' details into man page for generic mount command?

For the generic mount command? No, only in mount.ceph(8).

Quoted 7 lines

I meant that, currently, we have no information about CephFS mount options in man page for generic mount command. From my point of view, it makes sense to have some explanation of CephFS mount options there. So, I see the point to send a patch for adding the explanation of CephFS mount options into man page of generic mount command. As a result, we will have brief information in man page for generic mount command and detailed explanation in mount.ceph(8). How do you feel about it?

Quoted 5 lines

I didn't realize that the mount(8) manpage had FS specific options. That would be good to add, certainly. I would also recommend pointing out in that same man page that mount.ceph has some user-friendly helpers (like pulling information out of the ceph.conf) so we recommend using it routinely.

OK. Sounds good. Let me create a ticket in https://tracker.ceph.com for this task.

Thanks,
Slava.

#15 lore raw
In reply to Patrick Donnelly
Quoted 1 line · Patrick Donnelly

<skipped>

Quoted 10 lines
Quoted 6 lines
Quoted 4 lines

* You also need to update ceph_mds_auth_match to call namespace_equals.

Do you mean this code [1]?

Yes, that's it.

Quoted 1 line

Just to double check that we are on the same page. Currently, in ceph_mds_auth_match() we have [1]:

	if (auth->match.fs_name && strcmp(auth->match.fs_name, fs_name)) {
		/* fsname mismatch, try next one */
		return 0;
	}

We are comparing auth->match.fs_name and fs_name (which now is mdsc->mdsmap-

Quoted 1 line

m_fs_name) as two strings. However, namespace_equals() expects slightly

different input [2]:

static inline int namespace_equals(struct ceph_mount_options *fsopt,
const char *namespace, size_t len)

So, do you mean of using mdsc->fsc->mount_options instead of auth-

Quoted 1 line

match.fs_name? Or, do you mean of using namespace_equals() logic for comparing

of auth->match.fs_name and fs_name?

Thanks,
Slava.

[1] https://elixir.bootlin.com/linux/v6.19-rc1/source/fs/ceph/mds_client.c#L5682
[2] https://elixir.bootlin.com/linux/v6.19-rc1/source/fs/ceph/super.h#L113

#16 lore raw
Quoted 2 lines · Viacheslav Dubeyko

Or, do you mean of using namespace_equals() logic for comparing of auth->match.fs_name and fs_name?

This one. (But after discussion with Ilya, you probably should just make a new procedure for the matching logic which implements "*" only for this change.)

Signature · 5 lines
Patrick Donnelly, Ph.D.
He / Him / His
Red Hat Partner Engineer
IBM, Inc.
GPG: 19F28A586F808C2402351B93C3301A3E258DD79D
#17 lore raw
Quoted 8 lines · Patrick Donnelly
Quoted 2 lines · Viacheslav Dubeyko

Or, do you mean of using namespace_equals() logic for comparing of auth->match.fs_name and fs_name?

This one. (But after discussion with Ilya, you probably should just make a new procedure for the matching logic which implements "*" only for this change.)

I am not sure that I am completely follow to your point. But, let me prepare a new version of the patch and we can continue discussion there. :)

Thanks,
Slava.