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 3/3] coredump: hand a pidfd to the usermode coredump helper
Date: Mon, 14 Apr 2025 14:48:44 +0200 [thread overview]
Message-ID: <20250414124843.GB28345@redhat.com> (raw)
In-Reply-To: <20250414-work-coredump-v1-3-6caebc807ff4@kernel.org>
On 04/14, Christian Brauner wrote:
>
> + case 'F': {
> + struct file *pidfs_file __free(fput) = NULL;
> +
> + /*
> + * Install a pidfd only makes sense if
> + * we actually spawn a usermode helper.
> + */
> + if (!ispipe)
> + break;
> +
> + /*
> + * We already created a pidfs_file but the user
> + * specified F multiple times. Just print the
> + * number multiple times.
> + */
> + if (!cprm->pidfs_file) {
> + /*
> + * Create a pidfs file for the
> + * coredumping thread that we can
> + * install into the usermode helper's
> + * file descriptor table later.
> + *
> + * Note that we'll install a pidfd for
> + * the thread-group leader. We know that
> + * task linkage hasn't been removed yet
> + * and even if this @current isn't the
> + * actual thread-group leader we know
> + * that the thread-group leader cannot
> + * be reaped until @current has exited.
> + */
> + pidfs_file = pidfs_alloc_file(task_tgid(current), 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. Thus, we should
> + * always be able to use file descriptor
> + * number 3.
> + */
> + err = cn_printf(cn, "%d", COREDUMP_PIDFD_NUMBER);
> + if (err)
> + return err;
> +
> + cprm->pidfs_file = no_free_ptr(pidfs_file);
> + break;
> + }
So the new case 'F' differs from other case's in that it doesn't do
"break" but returns the error... this is a bit inconsistent.
Note also that if you do cn_printf() before pidfs_alloc_file(), then you
can avoid __free(fput) and no_free_ptr().
But this is minor. Can't we simplify this patch?
Rather than add the new pidfs_file member into coredump_params, we can
add "struct pid *pid". format_corename() will simply do
case 'F':
if (ispipe) {
// no need to do get_pid()
cprm->pid = task_tgid(current);
err = cn_printf(...);
}
break;
and umh_pipe_setup() can itself do pidfs_alloc_file(cp->pid) if it is
not NULL.
This way do_coredump() doesn't need any changes.
No?
Oleg.
next prev parent reply other threads:[~2025-04-14 12:49 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
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 [this message]
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=20250414124843.GB28345@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