public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Christian Brauner <brauner@kernel.org>
Cc: linux-fsdevel@vger.kernel.org,
	"Luca Boccassi" <luca.boccassi@gmail.com>,
	"Lennart Poettering" <lennart@poettering.net>,
	"Daan De Meyer" <daan.j.demeyer@gmail.com>,
	"Mike Yuan" <me@yhndnzj.com>,
	"Zbigniew Jędrzejewski-Szmek" <zbyszek@in.waw.pl>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] coredump: fix error handling for replace_fd()
Date: Mon, 14 Apr 2025 14:11:56 +0200	[thread overview]
Message-ID: <20250414121156.GA28345@redhat.com> (raw)
In-Reply-To: <20250414-work-coredump-v1-2-6caebc807ff4@kernel.org>

On 04/14, Christian Brauner wrote:
>
> The replace_fd() helper returns the file descriptor number on success
> and a negative error code on failure. The current error handling in
> umh_pipe_setup() only works because the file descriptor that is replaced
> is zero but that's pretty volatile. Explicitly check for a negative
> error code.

...

> @@ -515,6 +517,9 @@ static int umh_pipe_setup(struct subprocess_info *info, struct cred *new)
>  
>  	err = replace_fd(0, files[0], 0);
>  	fput(files[0]);
> +	if (err < 0)
> +		return err;
> +
>  	/* and disallow core files too */
>  	current->signal->rlim[RLIMIT_CORE] = (struct rlimit){1, 1};

The patch looks trivial and correct, but if we do not want to rely on
the fact that replace_fd(fd => 0) return 0 on sucess, then this patch
should also do

	-	return err;
	+	return 0;

?

otherwise this cleanup looks "incomplete" to me.

Oleg.


  reply	other threads:[~2025-04-14 12:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-14  9:53 [PATCH 0/3] coredump: hand a pidfd to the usermode coredump helper Christian Brauner
2025-04-14  9:53 ` [PATCH 1/3] pidfs: move O_RDWR into pidfs_alloc_file() Christian Brauner
2025-04-14  9:53 ` [PATCH 2/3] coredump: fix error handling for replace_fd() Christian Brauner
2025-04-14 12:11   ` Oleg Nesterov [this message]
2025-04-14 13:04     ` Christian Brauner
2025-04-14  9:53 ` [PATCH 3/3] coredump: hand a pidfd to the usermode coredump helper Christian Brauner
2025-04-14 12:48   ` Oleg Nesterov
2025-04-14 13:09     ` Christian Brauner

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=20250414121156.GA28345@redhat.com \
    --to=oleg@redhat.com \
    --cc=brauner@kernel.org \
    --cc=daan.j.demeyer@gmail.com \
    --cc=lennart@poettering.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luca.boccassi@gmail.com \
    --cc=me@yhndnzj.com \
    --cc=zbyszek@in.waw.pl \
    /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