fs: sort out fd allocation vs dup2 race commentary, take 2
authorMateusz Guzik <mjguzik@gmail.com>
Thu, 20 Mar 2025 10:26:37 +0000 (11:26 +0100)
committerChristian Brauner <brauner@kernel.org>
Thu, 20 Mar 2025 14:17:56 +0000 (15:17 +0100)
commit4dec4f91359c456a5eea26817ea151b42953432e
tree48bdebd75b06672be38b213be46cfabde08820d7
parentc918f15420e336a964f8f12d9c1134859a147d42
fs: sort out fd allocation vs dup2 race commentary, take 2

fd_install() has a questionable comment above it.

While it correctly points out a possible race against dup2(), it states:
> We need to detect this and fput() the struct file we are about to
> overwrite in this case.
>
> It should never happen - if we allow dup2() do it, _really_ bad things
> will follow.

I have difficulty parsing the above. The first sentence would suggest
fd_install() tries to detect and recover from the race (it does not),
the next one claims the race needs to be dealt with (it is, by dup2()).

Given that fd_install() does not suffer the burden, this patch removes
the above and instead expands on the race in dup2() commentary.

While here tidy up the docs around fd_install().

Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Link: https://lore.kernel.org/r/20250320102637.1924183-1-mjguzik@gmail.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/file.c