diff mbox series

[pseudo,1/3] ports/linux/pseudo_wrappers: Report io_uring as unsupported in syscall()

Message ID 20261116185400.2205466-2-mark.hatle@amd.com
State New
Headers show
Series Implement io_uring wrapping | expand

Commit Message

Mark Hatle Nov. 16, 2026, 6:53 p.m. UTC
Operations submitted through an io_uring are carried out by the kernel
without passing through libpseudo, so files they create or change are
not tracked, and end up with the build user's ownership.  libuv, used by
nodejs, and the meta-selftest reproducer set up a ring with syscall().

Refuse io_uring_setup(), io_uring_enter() and io_uring_register() with
ENOSYS, as a kernel without io_uring does, so callers fall back to the
ordinary calls pseudo can see.  This doesn't cover callers that make the
system call themselves, such as liburing.

test-io-uring-syscall checks that all three fail with ENOSYS under
pseudo.

[YOCTO #15244]

Reported-by: Martin Jansa <Martin.Jansa@gmail.com>
AI-Generated: Uses GitHub Copilot
Signed-off-by: Mark Hatle <mark.hatle@amd.com>
---
 ports/linux/pseudo_wrappers.c | 20 +++++++++++++++
 test/test-io-uring-syscall.c  | 47 +++++++++++++++++++++++++++++++++++
 test/test-io-uring-syscall.sh |  7 ++++++
 3 files changed, 74 insertions(+)
 create mode 100644 test/test-io-uring-syscall.c
 create mode 100755 test/test-io-uring-syscall.sh
diff mbox series

Patch

diff --git a/ports/linux/pseudo_wrappers.c b/ports/linux/pseudo_wrappers.c
index a573abb..f24bb3a 100644
--- a/ports/linux/pseudo_wrappers.c
+++ b/ports/linux/pseudo_wrappers.c
@@ -196,6 +196,11 @@  syscall(long number, ...) {
 	    && number != SYS_landlock_create_ruleset
 	    && number != SYS_landlock_add_rule
 	    && number != SYS_landlock_restrict_self
+#endif
+#ifdef SYS_io_uring_setup
+	    && number != SYS_io_uring_setup
+	    && number != SYS_io_uring_enter
+	    && number != SYS_io_uring_register
 #endif
 	    ) {
 		if (!real_syscall)
@@ -242,6 +247,21 @@  syscall(long number, ...) {
 	}
 #endif
 
+#ifdef SYS_io_uring_setup
+	/* Operations submitted through an io_uring never pass through
+	 * libpseudo, so files they create or change aren't tracked
+	 * (YOCTO #15244).  Report io_uring as unsupported, as a kernel
+	 * without it does, so callers fall back to ordinary calls.
+	 */
+	if (number == SYS_io_uring_setup ||
+	    number == SYS_io_uring_enter ||
+	    number == SYS_io_uring_register) {
+		pseudo_debug(PDBGF_SYSCALL, "syscall, refusing io_uring.\n");
+		errno = ENOSYS;
+		return -1;
+	}
+#endif
+
 #ifdef SYS_openat2
 	/* There is a CVE patch (CVE-2025-45582) to tar 1.34 in Centos Stream which
 	 * uses syscall to access openat2() and breaks builds if we don't redirect.
diff --git a/test/test-io-uring-syscall.c b/test/test-io-uring-syscall.c
new file mode 100644
index 0000000..bff9765
--- /dev/null
+++ b/test/test-io-uring-syscall.c
@@ -0,0 +1,47 @@ 
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Operations submitted through an io_uring bypass libpseudo, so pseudo
+ * reports io_uring as unsupported to callers using syscall(), such as
+ * libuv, which then fall back to ordinary calls.
+ */
+#define _GNU_SOURCE
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+
+/* The numbers are the same on every architecture using the common table. */
+#ifndef __NR_io_uring_setup
+#define __NR_io_uring_setup 425
+#endif
+#ifndef __NR_io_uring_enter
+#define __NR_io_uring_enter 426
+#endif
+#ifndef __NR_io_uring_register
+#define __NR_io_uring_register 427
+#endif
+
+static int
+check(const char *name, long rc) {
+	if (rc != -1 || errno != ENOSYS) {
+		printf("%s: expected ENOSYS, got %ld (%s)\n", name, rc, strerror(errno));
+		if (rc >= 0)
+			close(rc);
+		return 1;
+	}
+	return 0;
+}
+
+int
+main(void) {
+	char params[120] = { 0 };	/* struct io_uring_params */
+	int rc = 0;
+
+	rc |= check("io_uring_setup", syscall(__NR_io_uring_setup, 1, params));
+	rc |= check("io_uring_enter", syscall(__NR_io_uring_enter, -1, 0, 0, 0, NULL, 0));
+	rc |= check("io_uring_register", syscall(__NR_io_uring_register, -1, 0, NULL, 0));
+	return rc;
+}
diff --git a/test/test-io-uring-syscall.sh b/test/test-io-uring-syscall.sh
new file mode 100755
index 0000000..74a06d9
--- /dev/null
+++ b/test/test-io-uring-syscall.sh
@@ -0,0 +1,7 @@ 
+#!/bin/sh
+#
+# SPDX-License-Identifier: LGPL-2.1-only
+#
+# io_uring through syscall() is reported as unsupported under pseudo.
+
+./test/test-io-uring-syscall