Martin Schwenke has uploaded this change for review.

View Change

FSAL_VFS: Don't attempt to get ACLs from FDs opened with O_PATH

Fixes: https://github.com/nfs-ganesha/nfs-ganesha/issues/1000

Commit 3a395315f27e19d64eab3e89c464008191ac3e02 improved the situation
but didn't catch all of the problems.

Linux open(2) documentation for O_PATH says:

Obtain a file descriptor that can be used for two purposes: to
indicate a location in the filesystem tree and to perform operations
that act purely at the file descriptor level. The file itself is
not opened, and other file operations (e.g., read(2), write(2),
fchmod(2), fchown(2), fgetxattr(2), ioctl(2), mmap(2)) fail with the
error EBADF.

So, the real problem looks to be FSAL_VFS incorrectly calling libacl's
acl_get_fd(3), which then calls fgetxattr(2) on a file descriptor that
was opened with O_PATH. FSAL_VFS also opens sockets and device files
with O_PATH in find_fd(), so attempting to get ACLs for those will
also fail.

The fix is to exclude all file types opened with O_PATH from the
FSAL_VFS ACL code.

This avoids 8 test failures for socket-related tests in
pynfs/nfs4.0/testserver.py all:

@@ -41,31 +41,23 @@
VF5r st_verify.testWriteOnlyFile : PASS
VF5f st_verify.testWriteOnlyFifo : PASS
VF5d st_verify.testWriteOnlyDir : PASS
-VF7s st_verify.testUnsupportedSocket : FAILURE
- nfs4lib.BadCompoundRes: operation OP_GETATTR should
- return NFS4_OK, instead got NFS4ERR_IO
+VF7s st_verify.testUnsupportedSocket : PASS
VF7a st_verify.testUnsupportedLink : PASS
VF7r st_verify.testUnsupportedFile : PASS
VF7f st_verify.testUnsupportedFifo : PASS
VF7d st_verify.testUnsupportedDir : PASS
-VF2s st_verify.testTypeSocket : FAILURE
- Verifying type of /b'srv/nfs/tree/socket' should
- return NFS4_OK, instead got NFS4ERR_IO
+VF2s st_verify.testTypeSocket : PASS
VF2a st_verify.testTypeLink : PASS
VF2r st_verify.testTypeFile : PASS
VF2f st_verify.testTypeFifo : PASS
VF2d st_verify.testTypeDir : PASS
VF4 st_verify.testNoFh : PASS
-VF1s st_verify.testMandSocket : FAILURE
- nfs4lib.BadCompoundRes: operation OP_GETATTR should
- return NFS4_OK, instead got NFS4ERR_IO
+VF1s st_verify.testMandSocket : PASS
VF1a st_verify.testMandLink : PASS
VF1r st_verify.testMandFile : PASS
VF1f st_verify.testMandFifo : PASS
VF1d st_verify.testMandDir : PASS
-VF3s st_verify.testBadSizeSocket : FAILURE
- nfs4lib.BadCompoundRes: operation OP_GETATTR should
- return NFS4_OK, instead got NFS4ERR_IO
+VF3s st_verify.testBadSizeSocket : PASS
VF3a st_verify.testBadSizeLink : PASS
VF3r st_verify.testBadSizeFile : PASS
VF3f st_verify.testBadSizeFifo : PASS
@@ -395,9 +387,7 @@
LOCKRNG st_lock.test32bitRange : PASS
LINK6 st_link.testZeroLenName : PASS
LINKS st_link.testSupported : PASS
-LINK1s st_link.testSocket : FAILURE
- nfs4lib.BadCompoundRes: operation OP_GETATTR should
- return NFS4_OK, instead got NFS4ERR_IO
+LINK1s st_link.testSocket : PASS
LINK2 st_link.testNoSfh : PASS
LINK3 st_link.testNoCfh : PASS
LINK7 st_link.testLongName : PASS
@@ -440,9 +430,7 @@
GATT1f st_getattr.testMandFifo : PASS
GATT1d st_getattr.testMandDir : PASS
GATT9 st_getattr.testLotsofGetattrsFile : PASS
-GATT7s st_getattr.testLongSocket : FAILURE
- Asking for all legal attributes should return NFS4_OK,
- instead got NFS4ERR_IO
+GATT7s st_getattr.testLongSocket : PASS
GATT7a st_getattr.testLongLink : PASS
GATT7r st_getattr.testLongFile : PASS
GATT7f st_getattr.testLongFifo : PASS
@@ -506,9 +494,7 @@
ACL10 st_acl.testLargeACL : PASS
ACL0 st_acl.testACLsupport : PASS
ACL5 st_acl.testACL : PASS
-ACC1s st_access.testReadSocket : FAILURE
- OP_ACCESS should return NFS4_OK, instead got
- NFS4ERR_IO
+ACC1s st_access.testReadSocket : PASS
ACC1a st_access.testReadLink : PASS
ACC1r st_access.testReadFile : PASS
ACC1f st_access.testReadFifo : PASS
@@ -519,13 +505,11 @@
ACC4r st_access.testInvalidsFile : PASS
ACC4f st_access.testInvalidsFifo : PASS
ACC4d st_access.testInvalidsDir : PASS
-ACC2s st_access.testAllSocket : FAILURE
- OP_ACCESS should return NFS4_OK, instead got
- NFS4ERR_IO
+ACC2s st_access.testAllSocket : PASS
ACC2a st_access.testAllLink : PASS
ACC2r st_access.testAllFile : PASS
ACC2f st_access.testAllFifo : PASS
ACC2d st_access.testAllDir : PASS
**************************************************
Command line asked for 591 of 679 tests
-Of those: 94 Skipped, 13 Failed, 3 Warned, 481 Passed
+Of those: 94 Skipped, 5 Failed, 3 Warned, 489 Passed

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Change-Id: I650eefba72209ef0cbccab3f458f9f635c0dc85f
---
M src/FSAL/FSAL_VFS/vfs/attrs.c
1 file changed, 12 insertions(+), 1 deletion(-)

git pull ssh://review.gerrithub.io:29418/ffilz/nfs-ganesha refs/changes/52/1168852/1

To view, visit change 1168852. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: ffilz/nfs-ganesha
Gerrit-Branch: next
Gerrit-Change-Id: I650eefba72209ef0cbccab3f458f9f635c0dc85f
Gerrit-Change-Number: 1168852
Gerrit-PatchSet: 1
Gerrit-Owner: Martin Schwenke <martin@meltin.net>
Gerrit-MessageType: newchange