Re: [PATCH RFC POC 00/50] file: handle files on syscall exit
From: Jann Horn
Date: Tue Sep 15 2026 - 15:21:00 EST
On Tue, Sep 15, 2026 at 1:31 PM Christian Brauner <brauner@xxxxxxxxxx> wrote:
> TL;DR, this lets arch code handle fd install and cleanup. fd_prepare()
> allocates a descriptor like get_unused_fd_flags() does and records it in
> a slot on the task. fd_stage() attaches the file to that slot and
> returns the number.
I'm not really a fan but I feel like if you want to do this, you
should be using task_work so you don't have to touch the entry/exit
paths directly? (And if task_work is too inefficient somehow, you
could tinker with the task_work implementation.)
> When the syscall returns success the exit path installs every staged
> file. When it returns an error it drops the descriptors and the files.
Is this mainly about stuff like "we installed a file descriptor and
then the following put_user() failed"? Because if so, I think a nicer
fix would be to have a policy of "if userspace provides unwritable
memory to a syscall, just keep going and pretend the access worked",
and maybe have a sysctl that kills the process when this happens to
emphasize that userspace should not be doing this.