]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commit
client: Fix symlink open with O_PATH and O_NOFOLLOW
authorAnoop C S <anoopcs@cryptolab.net>
Thu, 29 Aug 2024 06:23:44 +0000 (11:53 +0530)
committerAnoop C S <anoopcs@cryptolab.net>
Tue, 17 Dec 2024 11:44:43 +0000 (17:14 +0530)
commit83cd73ad8fc4cab2472f7d0986f6d6e4cccd7ae8
tree8d1631e3a7963928cd41c21cefcc4aebf7e5e276
parenta1b54e03f5fc2ff00aee793b5fcc21e1125cc1be
client: Fix symlink open with O_PATH and O_NOFOLLOW

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 8443821073b23946a32009106c45581db0d51e8f)
src/client/Client.cc
src/test/libcephfs/test.cc