smbd hits an assertion and disconnects the client when a snapshot (Previous Version) is accessed on a share whose "path = /" (mounted at the CephFS file system root). ceph_snap_gmt_convert_dir() builds the absolute .snap directory path by joining the share's connectpath, the request-relative name and the snapshot subdir with '/' separators. When the connectpath is a bare "/" (root-mounted share), or the request-relative name is itself absolute / contains '/' runs (e.g. when accessing a file inside a snapshot), the join produces a path with a run of consecutive '/', e.g. "//foo/.snap". This path is handed to OpenDir() -> fd_openat() -> filename_convert_dirfsp_rel(), which splits on '/', and openat_pathref_fsp_nosymlink() asserts that no component is empty: SMB_ASSERT(rel_fname.base_name[0] != '\0') source3/smbd/files.c:1212 The empty component from the '//' run trips the assert and panics smbd. Whether the malformed path reaches the assert also depends on the Ceph client accepting the non-canonical "//" path in the preceding stat(), so reproducibility is libcephfs-version dependent (reproduced with Ceph v20.2.1 / libcephfs). Reproducer ---------- smb.conf: [share] path = / vfs objects = ceph_snapshots ceph_new ceph_new:config_file = /etc/ceph/ceph.conf ceph_new:user_id = admin read only = no Create a snapshot from a kernel mount at the CephFS root: touch testfile mkdir .snap/testsnapshot Then via smbclient, enumerating previous versions of the file (or "allinfo testfile") disconnects with NT_STATUS_CONNECTION_DISCONNECTED, and the smbd log shows the SMB_ASSERT panic. With "log level = 10" the malformed path is visible, e.g.: ceph_snap_gmt_convert_dir: enumerating shadow copy dir at //foo/.snap The same happens for files within a subdirectory of a snapshot.
This bug was referenced in samba master: abb48aacbd994877006bf9156e633d3cf29a34bc
Created attachment 19134 [details] patch from master for v4-24-test
Created attachment 19135 [details] patch from master for v4-23-test
Re-assigning for inclusion in both 4.24 ad 4.23
This bug was referenced in samba v4-23-test: 1c1fe53f2fbe60292df6a33320a4ecb867ca5bb5
This bug was referenced in samba v4-23-stable (Release samba-4.23.11): 1c1fe53f2fbe60292df6a33320a4ecb867ca5bb5
This bug was referenced in samba v4-24-test: a2e0beedf76f6541e12c29788ab4bcdfc5004fed
This bug was referenced in samba v4-24-stable (Release samba-4.24.6): a2e0beedf76f6541e12c29788ab4bcdfc5004fed