From: Christian Brauner <brauner@kernel.org>
To: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>, Jan Kara <jack@suse.cz>,
Sargun Dhillon <sargun@sargun.me>, Kees Cook <kees@kernel.org>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] fs: correctly check for errors from replace_fd() in receive_fd_replace()
Date: Mon, 4 Aug 2025 10:38:35 +0200 [thread overview]
Message-ID: <20250804-fechten-glukose-1cb2e2b0413a@brauner> (raw)
In-Reply-To: <20250801-fix-receive_fd_replace-v1-1-d46d600c74d6@linutronix.de>
On Fri, Aug 01, 2025 at 09:38:38AM +0200, Thomas Weißschuh wrote:
> replace_fd() returns either a negative error number or the number of the
> new file descriptor. The current code misinterprets any positive file
> descriptor number as an error.
>
> Only check for negative error numbers, so that __receive_sock() is called
> correctly for valid file descriptors.
>
> Fixes: 173817151b15 ("fs: Expand __receive_fd() to accept existing fd")
> Fixes: 42eb0d54c08a ("fs: split receive_fd_replace from __receive_fd")
> Cc: stable@vger.kernel.org
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> ---
> Untested, it stuck out while reading the code.
> ---
> fs/file.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/file.c b/fs/file.c
> index 6d2275c3be9c6967d16c75d1b6521f9b58980926..56c3a045121d8f43a54cf05e6ce1962f896339ac 100644
> --- a/fs/file.c
> +++ b/fs/file.c
> @@ -1387,7 +1387,7 @@ int receive_fd_replace(int new_fd, struct file *file, unsigned int o_flags)
> if (error)
> return error;
> error = replace_fd(new_fd, file, o_flags);
> - if (error)
> + if (error < 0)
> return error;
What in the holy fsck? Why did the seccomp selftests not fail
horrendously explode because of that.
prev parent reply other threads:[~2025-08-04 8:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-01 7:38 [PATCH] fs: correctly check for errors from replace_fd() in receive_fd_replace() Thomas Weißschuh
2025-08-01 10:48 ` Jan Kara
2025-08-01 22:02 ` Al Viro
2025-08-04 8:38 ` Christian Brauner [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250804-fechten-glukose-1cb2e2b0413a@brauner \
--to=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=kees@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sargun@sargun.me \
--cc=stable@vger.kernel.org \
--cc=thomas.weissschuh@linutronix.de \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox