Unverified Commit 708c04a5 authored by Thomas Weißschuh's avatar Thomas Weißschuh Committed by Christian Brauner
Browse files

fs: always return zero on success from replace_fd()



replace_fd() returns the number of the new file descriptor through the
return value of do_dup2(). However its callers never care about the
specific returned number. In fact the caller in receive_fd_replace() treats
any non-zero return value as an error and therefore never calls
__receive_sock() for most file descriptors, which is a bug.

To fix the bug in receive_fd_replace() and to avoid the same issue
happening in future callers, signal success through a plain zero.

Suggested-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Link: https://lore.kernel.org/lkml/20250801220215.GS222315@ZenIV/


Fixes: 17381715 ("fs: Expand __receive_fd() to accept existing fd")
Fixes: 42eb0d54 ("fs: split receive_fd_replace from __receive_fd")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarThomas Weißschuh <thomas.weissschuh@linutronix.de>
Link: https://lore.kernel.org/20250805-fix-receive_fd_replace-v3-1-b72ba8b34bac@linutronix.de


Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent f7d81235
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment