client: Fix opening and reading of symlinks#59503
Conversation
|
batrick
left a comment
There was a problem hiding this comment.
Please create a tracker issue so that this issue can be tracked for backporting.
Then, please annotate the commit which fixes/resolves a Ceph tracker issue with:
Fixes: http://tracker.ceph.com/issues/...
This is essential when examining the history of the repository (this commit fixes what) and helps merge scripts identify issues that have been resolved by a merge. See this article on GitHub on how to amend commits and update your pull request.
2fe4a91 to
3d326b6
Compare
Done, thanks. |
|
jenkins test make check arm64 |
|
@anoopcs9 this looks to be easily reproducible, a test case can be added in |
anoopcs9
left a comment
There was a problem hiding this comment.
@anoopcs9 this looks to be easily reproducible, a test case can be added in
src/test/libcephfs/test.cc.
I've added the bare minimum to handle the cases addressed by the changes in the pull request. Let me know if something more is required.
3d326b6 to
58c6cfa
Compare
|
jenkins retest this please |
58c6cfa to
1db772b
Compare
1db772b to
9e29f49
Compare
|
This PR is under test in https://tracker.ceph.com/issues/68382. |
* refs/pull/59503/head: client: Resolve symlink from dirfd for empty pathname client: Fix symlink open with O_PATH and O_NOFOLLOW Reviewed-by: Venky Shankar <[email protected]> Reviewed-by: Dhairya Parmar <[email protected]>
|
jenkins retest this please |
|
These jenkins test aren't running to completion. @anoopcs9 mind pushing a rebase please? |
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 <[email protected]>
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 <[email protected]>
9e29f49 to
24f453d
Compare
All set. |
Following are the two misbehaviours observed:
O_PATHandO_NOFOLLOWresults in ELOOP.O_PATHin may_open().O_PATHexplanation.Fixes: https://tracker.ceph.com/issues/67833