From 47004036420a13c4a6a476f05b33ca4df579ddc8 Mon Sep 17 00:00:00 2001 From: Shachar Sharon Date: Tue, 20 Aug 2024 12:06:40 +0300 Subject: [PATCH 1/2] vfs_ceph_new: add missing newline in debug-logging Commit d00f20f3 ("vfs_ceph_new: debug-log upon libcephfs low-level calls") introduced debug-logging before each call to libcephfs low-level APIs. Unfortunately, one of the logging messages missed the terminating newline ('\n') character. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15686 Signed-off-by: Shachar Sharon Reviewed-by: John Mulligan Reviewed-by: Anoop C S Autobuild-User(master): Anoop C S Autobuild-Date(master): Wed Aug 21 14:18:07 UTC 2024 on atb-devel-224 (cherry picked from commit cbba4008a7fb9e6e91d0568f25ac481b60fda96f) --- source3/modules/vfs_ceph_new.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/modules/vfs_ceph_new.c b/source3/modules/vfs_ceph_new.c index 25e78444fb5..9c36f762aa6 100644 --- a/source3/modules/vfs_ceph_new.c +++ b/source3/modules/vfs_ceph_new.c @@ -730,7 +730,7 @@ static int vfs_ceph_ll_lookup(const struct vfs_handle_struct *handle, struct UserPerm *uperm = NULL; int ret = -1; - DBG_DEBUG("[ceph] ceph_ll_lookup: parent-ino=%" PRIu64 " name=%s", + DBG_DEBUG("[ceph] ceph_ll_lookup: parent-ino=%" PRIu64 " name=%s\n", parent->ino, name); uperm = vfs_ceph_userperm_new(handle); -- 2.46.0 From 7875c6e93e784f6e6aa7ccc3ec79277e97a6b115 Mon Sep 17 00:00:00 2001 From: Shachar Sharon Date: Tue, 20 Aug 2024 12:45:07 +0300 Subject: [PATCH 2/2] vfs_ceph_new: handle case of readlinkat with empty name string Commit 53c9269b (vfs_ceph_new: use low-level APIs for symlink/readlink) introduced readlinkat using libcephfs low-level APIs. However, it does not handle properly the case where readlinkat operates on empty name string (see man readlinkat(2)), such as: fd = openat(dirfd, symname, O_PATH | O_NOFOLLOW, 0); readlinkat(fd, "", buf, bufsiz); Handle this special case of readlinkat with empty name string by using a reference to the symlink inode itself. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15686 Signed-off-by: Shachar Sharon Reviewed-by: Anoop C S Reviewed-by: Guenther Deschner Autobuild-User(master): Anoop C S Autobuild-Date(master): Fri Aug 30 10:42:27 UTC 2024 on atb-devel-224 (cherry picked from commit 22182f90e8e7876a9895f77e736d2b96b18b174f) --- source3/modules/vfs_ceph_new.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/source3/modules/vfs_ceph_new.c b/source3/modules/vfs_ceph_new.c index 9c36f762aa6..8d4866e054b 100644 --- a/source3/modules/vfs_ceph_new.c +++ b/source3/modules/vfs_ceph_new.c @@ -2455,7 +2455,6 @@ static int vfs_ceph_readlinkat(struct vfs_handle_struct *handle, size_t bufsiz) { int result = -1; - struct vfs_ceph_iref iref = {0}; struct vfs_ceph_fh *dircfh = NULL; DBG_DEBUG("[CEPH] readlinkat(%p, %s, %p, %llu)\n", @@ -2468,17 +2467,29 @@ static int vfs_ceph_readlinkat(struct vfs_handle_struct *handle, if (result != 0) { goto out; } - result = vfs_ceph_ll_lookupat(handle, - dircfh, - smb_fname->base_name, - &iref); - if (result != 0) { - goto out; - } - - result = vfs_ceph_ll_readlinkat(handle, dircfh, &iref, buf, bufsiz); + if (strcmp(smb_fname->base_name, "") != 0) { + struct vfs_ceph_iref iref = {0}; - vfs_ceph_iput(handle, &iref); + result = vfs_ceph_ll_lookupat(handle, + dircfh, + smb_fname->base_name, + &iref); + if (result != 0) { + goto out; + } + result = vfs_ceph_ll_readlinkat(handle, + dircfh, + &iref, + buf, + bufsiz); + vfs_ceph_iput(handle, &iref); + } else { + result = vfs_ceph_ll_readlinkat(handle, + dircfh, + &dircfh->iref, + buf, + bufsiz); + } out: DBG_DEBUG("[CEPH] readlinkat(...) = %d\n", result); return status_code(result); -- 2.46.0