NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

misc/54946: O_SEARCH tests: expect revoke +x failure on NFS

>Number:         54946
>Category:       misc
>Synopsis:       O_SEARCH tests: expect revoke +x failure on NFS
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    misc-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Feb 07 22:50:00 +0000 2020
>Originator:     Kyle Evans
O_SEARCH semantics are very clear, here: faccessat() should not be checking for the executable bit on the atfd if it was opened with O_SEARCH. We've since realized that NFS cannot possibly honor these semantics, because it will re-check at lookup time every time and there is no way to indicate in a safe or portable fashion that it should avoid doing so -- the NFS server typically won't know that this specific fd was initially opened with O_SEARCH, and it certainly won't know that the directory did have the executable bit set at the time of open(, O_SEARCH).

There's still some value in attempting the test, though- this is a newly created file as of this test, so any kind of success would be due to bogus caching.

This is completely untested on NetBSD, but the statvfs use looks to be correct based on the documentation I looked at...

Index: tests/lib/libc/c063/t_o_search.c
RCS file: /cvsroot/src/tests/lib/libc/c063/t_o_search.c,v
retrieving revision 1.9
diff -u -r1.9 t_o_search.c
--- tests/lib/libc/c063/t_o_search.c    6 Feb 2020 12:18:06 -0000       1.9
+++ tests/lib/libc/c063/t_o_search.c    7 Feb 2020 22:40:57 -0000
@@ -34,6 +34,11 @@
 #include <atf-c.h>

 #include <sys/types.h>
+#ifdef __FreeBSD__
+#include <sys/mount.h>
+#include <sys/statvfs.h>
 #include <sys/stat.h>

 #include <dirent.h>
@@ -322,6 +327,23 @@

        /* Drop permissions. The kernel must still not check the exec bit. */
        ATF_REQUIRE(chmod(DIR, 0000) == 0);
+       {
+               const char *fstypename;
+#ifdef __FreeBSD__
+               struct statfs st;
+               fstatfs(dfd, &st);
+               fstypename = st.f_fstypename;
+               struct statvfs vst;
+               fstatvfs(dfd, &vst);
+               fstypename = vst.f_fstypename;
+               if (strcmp(fstypename, "nfs") == 0)
+                       atf_tc_expect_fail(
+                           "NFS protocol cannot observe O_SEARCH semantics");
+       }
        ATF_REQUIRE(fstatat(dfd, BASEFILE, &sb, 0) == 0);

        ATF_REQUIRE(close(dfd) == 0);

Home | Main Index | Thread Index | Old Index