@@ -399,9 +399,9 @@ class Function:
# Emulate EFAULT when path is null
"if (%s == NULL) {\n"
"\t\t\terrno = EFAULT;\n"
- "\t\t\trc = -1;\n"
- "\t\t\t%s\n"
- "\t\t}\n" % (path, self.rc_return()))
+ "\t\t\t%s -1;\n"
+ "\t\t\tgoto quick_exit;\n"
+ "\t\t}\n" % (path, self.rc_assign()))
fix_paths.append(
"%s = pseudo_root_path(__func__, __LINE__, %s%s, %s, %s);" %
(path, prefix, self.dirfd, path, self.flags))
@@ -71,6 +71,8 @@ ${maybe_async_skip}
}
}
${variadic_end}
+quick_exit:
+ __attribute__((unused));
save_errno = errno;
pseudo_droplock();
sigprocmask(SIG_SETMASK, &saved, NULL);
@@ -8,13 +8,30 @@
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
+#include <errno.h>
// Passing a null pointer is the test scenario
#pragma GCC diagnostic ignored "-Wnonnull"
-int main(void) {
+int statx_test() {
if (statx(0, NULL, 0, 0, NULL) != -1) {
return 1;
}
+ if (errno != EFAULT) {
+ return 2;
+ }
+ return 0;
+}
+
+/* We run this multiple times to ensure that pseudo does not deadlock */
+int main(void) {
+ int rc = 0;
+
+ for (int i = 0 ; i < 5 ; i++) {
+ rc = statx_test();
+ if (rc != 0)
+ return rc;
+ }
+
return 0;
}