linux/fs/ceph
Daniel Vogelbacher 8c9af7339d ceph: fix oops due to invalid pointer for kfree() in parse_longname()
commit bc8dedae02 upstream.

This fixes a kernel oops when reading ceph snapshot directories (.snap),
for example by simply running `ls /mnt/my_ceph/.snap`.

The variable str is guarded by __free(kfree), but advanced by one for
skipping the initial '_' in snapshot names. Thus, kfree() is called
with an invalid pointer.  This patch removes the need for advancing the
pointer so kfree() is called with correct memory pointer.

Steps to reproduce:

1. Create snapshots on a cephfs volume (I've 63 snaps in my testcase)

2. Add cephfs mount to fstab
$ echo "samba-fileserver@.files=/volumes/datapool/stuff/3461082b-ecc9-4e82-8549-3fd2590d3fb6      /mnt/test/stuff   ceph     acl,noatime,_netdev    0       0" >> /etc/fstab

3. Reboot the system
$ systemctl reboot

4. Check if it's really mounted
$ mount | grep stuff

5. List snapshots (expected 63 snapshots on my system)
$ ls /mnt/test/stuff/.snap

Now ls hangs forever and the kernel log shows the oops.

Cc: stable@vger.kernel.org
Fixes: 101841c383 ("[ceph] parse_longname(): strrchr() expects NUL-terminated string")
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=220807
Suggested-by: Helge Deller <deller@gmx.de>
Signed-off-by: Daniel Vogelbacher <daniel@chaospixel.com>
Reviewed-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-02-11 13:40:17 +01:00
..
acl.c ceph: allow idmapped set_acl inode op 2023-11-03 23:28:34 +01:00
addr.c ceph: avoid kernel BUG for encrypted inode with unaligned file size 2025-06-27 11:11:19 +01:00
cache.c ceph: rename _to_client() to _to_fs_client() 2023-11-03 23:28:33 +01:00
cache.h netfs: Provide invalidate_folio and release_folio calls 2023-12-24 15:08:51 +00:00
caps.c ceph: Fix typo in the comment 2024-09-24 22:51:33 +02: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-11 13:40:17 +01:00
crypto.h ceph: add support for encrypted snapshot names 2023-08-24 11:24:36 +02:00
debugfs.c ceph: fix race condition validating r_parent before applying state 2025-09-19 16:35:47 +02:00
dir.c ceph: refactor wake_up_bit() pattern of calling 2025-11-13 15:34:35 -05:00
export.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
file.c ceph: refactor wake_up_bit() pattern of calling 2025-11-13 15:34:35 -05:00
inode.c ceph: fix race condition where r_parent becomes stale before sending message 2025-09-19 16:35:47 +02:00
io.c ceph: fix kerneldoc copypasta over ceph_start_io_direct 2021-04-27 23:52:23 +02:00
io.h ceph: add buffered/direct exclusionary locking for reads and writes 2019-09-16 12:06:25 +02:00
ioctl.c ceph: fix potential race condition in ceph_ioctl_lazyio() 2025-11-13 15:34:35 -05: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
Kconfig ceph: select FS_ENCRYPTION_ALGS if FS_ENCRYPTION 2024-01-15 15:40:50 +01:00
locks.c ceph: add checking of wait_for_completion_killable() return value 2025-11-13 15:34:35 -05:00
Makefile ceph: fscrypt_auth handling for ceph 2023-08-22 09:01:48 +02:00
mds_client.c ceph: fix NULL pointer dereference in ceph_mds_auth_match() 2026-02-11 13:40:16 +01:00
mds_client.h ceph: fix race condition validating r_parent before applying state 2025-09-19 16:35:47 +02:00
mdsmap.c ceph: fix NULL pointer dereference in ceph_mds_auth_match() 2026-02-11 13:40:16 +01:00
mdsmap.h ceph: fix NULL pointer dereference in ceph_mds_auth_match() 2026-02-11 13:40:16 +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: fix invalid pointer access if get_quota_realm return ERR_PTR 2024-01-15 15:40:51 +01:00
snap.c Two items: 2023-11-10 09:52:56 -08:00
strings.c ceph: add getvxattr op 2022-03-01 18:26:37 +01:00
super.c ceph: fix multifs mds auth caps issue 2025-11-13 15:34:35 -05:00
super.h ceph: fix NULL pointer dereference in ceph_mds_auth_match() 2026-02-11 13:40:16 +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 Two items: 2023-11-10 09:52:56 -08:00