Re: [PATCH RFC POC 00/50] file: handle files on syscall exit
From: Linus Torvalds
Date: Tue Sep 15 2026 - 15:14:44 EST
On Tue, 15 Sept 2026 at 10:52, Jann Horn <jannh@xxxxxxxxxx> wrote:
>
> 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.
We've done that before, where we just ignore put_user() errors and the
user gets whatever the user gets.
It is maybe not optimal, but it's fine. You can find quite a lot of
unchecked put_user() calls with a pattern like
git grep '^[[:space:]]*put_user(.*);'
and some of them are in core code - see the two in kernel/fork.c, for example.
One of them says "if userspace has not set up a proper pointer then
tough luck". The other one doesn't even bother with a comment.
The scheduler has two cases too, although one of them is admittedly
for another error case.
So yes, saying "if you pass bogus arguments, you get what you get" is
a valid model. It's perhaps not the *preferred* model, but it's not
wrong.
It *would* be wrong to take code that already has error handling and
remove the error handling, though.
Linus