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 v2 3/3] coredump: hand a pidfd to the usermode coredump helper
Date: Mon, 14 Apr 2025 16:28:07 +0200 [thread overview]
Message-ID: <20250414142807.GF28345@redhat.com> (raw)
In-Reply-To: <20250414141450.GE28345@redhat.com>
On 04/14, Oleg Nesterov wrote:
>
> On 04/14, Christian Brauner wrote:
> >
> > -static int umh_pipe_setup(struct subprocess_info *info, struct cred *new)
> > +static int umh_coredump_setup(struct subprocess_info *info, struct cred *new)
> > {
> > struct file *files[2];
> > struct coredump_params *cp = (struct coredump_params *)info->data;
> > int err;
> >
> > + if (cp->pid) {
> > + struct file *pidfs_file __free(fput) = NULL;
> > +
> > + pidfs_file = pidfs_alloc_file(cp->pid, 0);
> > + if (IS_ERR(pidfs_file))
> > + return PTR_ERR(pidfs_file);
> > +
> > + /*
> > + * Usermode helpers are childen of either
> > + * system_unbound_wq or of kthreadd. So we know that
> > + * we're starting off with a clean file descriptor
> > + * table. So we should always be able to use
> > + * COREDUMP_PIDFD_NUMBER as our file descriptor value.
> > + */
> > + VFS_WARN_ON_ONCE((pidfs_file = fget_raw(COREDUMP_PIDFD_NUMBER)) != NULL);
> > +
> > + err = replace_fd(COREDUMP_PIDFD_NUMBER, pidfs_file, 0);
> > + if (err < 0)
> > + return err;
>
> Yes, but if replace_fd() succeeds we need to nullify pidfs_file
> to avoid fput from __free(fput) ?
Aah, please ignore me ;) replace_fd/do_dup2 does get_file() .
For this series:
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
next prev parent reply other threads:[~2025-04-14 14:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-14 13:55 [PATCH v2 0/3] coredump: hand a pidfd to the usermode coredump helper Christian Brauner
2025-04-14 13:55 ` [PATCH v2 1/3] pidfs: move O_RDWR into pidfs_alloc_file() Christian Brauner
2025-04-14 13:55 ` [PATCH v2 2/3] coredump: fix error handling for replace_fd() Christian Brauner
2025-04-14 13:55 ` [PATCH v2 3/3] coredump: hand a pidfd to the usermode coredump helper Christian Brauner
2025-04-14 14:14 ` Oleg Nesterov
2025-04-14 14:26 ` Christian Brauner
2025-04-14 14:28 ` Oleg Nesterov [this message]
2025-04-14 14:41 ` Christian Brauner
2025-04-25 11:31 ` Benjamin Drung
2025-04-25 11:57 ` Christian Brauner
2025-04-25 12:03 ` Benjamin Drung
2025-04-25 16:49 ` Christian Brauner
2025-04-30 11:39 ` Benjamin Drung
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=20250414142807.GF28345@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;
as well as URLs for NNTP newsgroup(s).