[PATCH RFC POC 17/50] um: commit fds on syscall exit

From: Christian Brauner

Date: Tue Sep 15 2026 - 07:55:25 EST


Add TIF_FD_SLOTS. handle_syscall() calls syscall_trace_leave() after
every system call, so test the flag there and commit the reservations
before audit and the ptrace exit stop.

Signed-off-by: Christian Brauner (Amutable) <brauner@xxxxxxxxxx>
---
arch/um/include/asm/thread_info.h | 2 ++
arch/um/kernel/ptrace.c | 4 ++++
2 files changed, 6 insertions(+)

diff --git a/arch/um/include/asm/thread_info.h b/arch/um/include/asm/thread_info.h
index 7a6f4dc99fa1..7140516ee0b6 100644
--- a/arch/um/include/asm/thread_info.h
+++ b/arch/um/include/asm/thread_info.h
@@ -44,6 +44,7 @@ struct thread_info {
#define TIF_SECCOMP 9 /* secure computing */
#define TIF_SINGLESTEP 10 /* single stepping userspace */
#define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
+#define TIF_FD_SLOTS 12 /* syscall prepared descriptors */


#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
@@ -55,6 +56,7 @@ struct thread_info {
#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
#define _TIF_SECCOMP (1 << TIF_SECCOMP)
#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
+#define _TIF_FD_SLOTS (1 << TIF_FD_SLOTS)

#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL | \
_TIF_NOTIFY_RESUME)
diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c
index 7da0a5223aa6..f1f89181fb7e 100644
--- a/arch/um/kernel/ptrace.c
+++ b/arch/um/kernel/ptrace.c
@@ -4,6 +4,7 @@
*/

#include <linux/audit.h>
+#include <linux/file.h>
#include <linux/ptrace.h>
#include <linux/sched.h>
#include <linux/uaccess.h>
@@ -142,6 +143,9 @@ void syscall_trace_leave(struct pt_regs *regs)
{
int ptraced = current->ptrace;

+ if (test_thread_flag(TIF_FD_SLOTS))
+ fd_slots_commit(regs);
+
audit_syscall_exit(regs);

/* Fake a debug trap */

--
2.53.0