linux/fs/ceph
Viacheslav Dubeyko 7987cce375 ceph: fix NULL pointer dereference in ceph_mds_auth_match()
The CephFS kernel client has regression starting from 6.18-rc1.
We have issue in ceph_mds_auth_match() 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;
    }

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 `-o mds_namespace=foo` 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.

[ idryomov: replace redundant %*pE with %s in ceph_mdsmap_decode(),
  get rid of a series of strlen() calls in ceph_namespace_match(),
  drop changes to namespace_equals() body to avoid treating empty
  mds_namespace as equal, drop changes to ceph_mdsc_handle_fsmap()
  as namespace_equals() isn't an equivalent substitution there ]

Cc: stable@vger.kernel.org
Fixes: 22c73d52a6 ("ceph: fix multifs mds auth caps issue")
Link: https://tracker.ceph.com/issues/73886
Signed-off-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
Reviewed-by: Patrick Donnelly <pdonnell@ibm.com>
Tested-by: Patrick Donnelly <pdonnell@ibm.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2026-02-04 22:00:42 +01:00
..
Kconfig ceph: stop selecting CRC32, CRYPTO, and CRYPTO_AES 2025-12-10 11:50:54 +01:00
Makefile ceph: fscrypt_auth handling for ceph 2023-08-22 09:01:48 +02:00
acl.c ceph: allow idmapped set_acl inode op 2023-11-03 23:28:34 +01:00
addr.c fs: Make wbc_to_tag() inline and use it in fs. 2025-10-29 23:33:48 +01:00
cache.c ceph: use the new ->i_state accessors 2025-10-20 20:22:27 +02:00
cache.h netfs: Provide invalidate_folio and release_folio calls 2023-12-24 15:08:51 +00:00
caps.c ceph: add trace points to the MDS client 2025-12-10 11:50:54 +01:00
ceph_frag.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
crypto.c ceph: fix oops due to invalid pointer for kfree() in parse_longname() 2026-02-03 21:02:24 +01:00
crypto.h ceph: replace local base64 helpers with lib/base64 2025-11-20 14:03:44 -08:00
debugfs.c ceph: fix race condition validating r_parent before applying state 2025-09-09 12:57:02 +02:00
dir.c ceph: don't allow delegations to be set on directories 2026-01-12 10:54:47 +01:00
export.c ceph: cleanup hardcoded constants of file handle size 2025-06-01 17:53:16 +02:00
file.c ceph: use the new ->i_state accessors 2025-10-20 20:22:27 +02:00
inode.c Significant patch series in this pull request: 2025-12-06 14:01:20 -08:00
io.c ceph: fix potential race condition on operations with CEPH_I_ODIRECT flag 2025-10-08 23:30:46 +02:00
io.h ceph: make ceph_start_io_*() killable 2025-10-08 23:30:46 +02:00
ioctl.c ceph: fix potential race condition in ceph_ioctl_lazyio() 2025-10-08 23:30:46 +02:00
ioctl.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
locks.c ceph: add checking of wait_for_completion_killable() return value 2025-10-08 23:30:46 +02:00
mds_client.c ceph: fix NULL pointer dereference in ceph_mds_auth_match() 2026-02-04 22:00:42 +01:00
mds_client.h ceph: fix race condition validating r_parent before applying state 2025-09-09 12:57:02 +02:00
mdsmap.c ceph: fix NULL pointer dereference in ceph_mds_auth_match() 2026-02-04 22:00:42 +01:00
mdsmap.h ceph: fix NULL pointer dereference in ceph_mds_auth_match() 2026-02-04 22:00:42 +01:00
metric.c ceph: print cluster fsid and client global_id in all debug logs 2023-11-03 23:28:33 +01:00
metric.h ceph: include average/stdev r/w/m latency in mds metrics 2022-03-21 13:35:16 +01:00
quota.c ceph: convert timeouts to secs_to_jiffies() 2025-01-12 20:21:04 -08:00
snap.c ceph: Amend checking to fix `make W=1` build breakage 2025-12-10 11:50:54 +01:00
strings.c ceph: add getvxattr op 2022-03-01 18:26:37 +01:00
super.c ceph: add trace points to the MDS client 2025-12-10 11:50:54 +01:00
super.h ceph: fix NULL pointer dereference in ceph_mds_auth_match() 2026-02-04 22:00:42 +01:00
util.c ceph: move net/ceph/ceph_fs.c to fs/ceph/util.c 2020-01-27 16:53:40 +01:00
xattr.c ceph: Switch to use %ptSp 2025-11-19 10:24:13 +01:00