reef: client: Fix opening and reading of symlinks#60373
Merged
Conversation
|
This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days. |
man open(2)[1] says the following for O_PATH: . . . If pathname is a symbolic link and the O_NOFOLLOW flag is also specified, then the call returns a file descriptor referring to the symbolic link. This file descriptor can be used as the dirfd argument in calls to fchownat(2), fstatat(2), linkat(2), and readlinkat(2) with an empty pathname to have the calls operate on the symbolic link. . . . symlink check within may_open() failed to consider the O_PATH flag resulting in a ELOOP error to the client. In order to return a valid file descriptor we introduce a check for the presence of O_PATH in the client provided flags. Fixes: https://tracker.ceph.com/issues/67833 [1] https://www.man7.org/linux/man-pages/man2/open.2.html Signed-off-by: Anoop C S <anoopcs@cryptolab.net> (cherry picked from commit 8443821)
man readlinkat(2)[1] points at a special case for readlinkat() syscall as follows: . . . Since Linux 2.6.39, pathname can be an empty string, in which case the call operates on the symbolic link referred to by dirfd (which should have been obtained using open(2) with the O_PATH and O_NOFOLLOW flags). . . . man open(2)[2] further explains the need for such a special case when a symlink is opened with O_PATH and O_NOFOLLOW: . . . If pathname is a symbolic link and the O_NOFOLLOW flag is also specified, then the call returns a file descriptor referring to the symbolic link. This file descriptor can be used as the dirfd argument in calls to fchownat(2), fstatat(2), linkat(2), and readlinkat(2) with an empty pathname to have the calls operate on the symbolic link. . . . Accordingly have a check to resolve symlinks out of dirfd when empty pathnames are encountered within readlinkat(). In addition to that match the standard file system behavior to return ENOENT instead of EINVAL when the inode pointed to by dirfd is not a symbolic link with empty pathnames. Fixes: https://tracker.ceph.com/issues/67833 [1] https://www.man7.org/linux/man-pages/man2/readlinkat.2.html [2] https://www.man7.org/linux/man-pages/man2/open.2.html Signed-off-by: Anoop C S <anoopcs@cryptolab.net> (cherry picked from commit 24f453d)
c55c9a3 to
f2338eb
Compare
Contributor
Author
|
jenkins test api |
Contributor
Author
|
jenkins test make check |
1 similar comment
Contributor
|
jenkins test make check |
Contributor
|
This PR is under test in https://tracker.ceph.com/issues/69503. |
Collaborator
|
Can one of the admins verify this patch? |
vshankar
added a commit
to vshankar/ceph
that referenced
this pull request
Jan 13, 2025
* refs/pull/60373/head: client: Resolve symlink from dirfd for empty pathname client: Fix symlink open with O_PATH and O_NOFOLLOW
Contributor
|
jenkins test make check |
mchangir
approved these changes
Feb 4, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
backport tracker: https://tracker.ceph.com/issues/68574
backport of #59503
parent tracker: https://tracker.ceph.com/issues/67833
this backport was staged using ceph-backport.sh version 16.0.0.6848
find the latest version at https://github.com/ceph/ceph/blob/main/src/script/ceph-backport.sh