From: Christian Brauner <brauner@kernel.org>
To: linux-fsdevel@vger.kernel.org
Cc: "Oleg Nesterov" <oleg@redhat.com>,
"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,
"Christian Brauner" <brauner@kernel.org>
Subject: [PATCH 1/3] pidfs: move O_RDWR into pidfs_alloc_file()
Date: Mon, 14 Apr 2025 11:53:36 +0200 [thread overview]
Message-ID: <20250414-work-coredump-v1-1-6caebc807ff4@kernel.org> (raw)
In-Reply-To: <20250414-work-coredump-v1-0-6caebc807ff4@kernel.org>
Since all pidfds must be O_RDWR currently enfore that directly in the
file allocation function itself instead of letting callers specify it.
Tested-by: Luca Boccassi <luca.boccassi@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
---
fs/pidfs.c | 1 +
kernel/fork.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/pidfs.c b/fs/pidfs.c
index d64a4cbeb0da..50e69a9e104a 100644
--- a/fs/pidfs.c
+++ b/fs/pidfs.c
@@ -888,6 +888,7 @@ struct file *pidfs_alloc_file(struct pid *pid, unsigned int flags)
return ERR_PTR(-ESRCH);
flags &= ~PIDFD_CLONE;
+ flags |= O_RDWR;
pidfd_file = dentry_open(&path, flags, current_cred());
/* Raise PIDFD_THREAD explicitly as do_dentry_open() strips it. */
if (!IS_ERR(pidfd_file))
diff --git a/kernel/fork.c b/kernel/fork.c
index c4b26cd8998b..d184e51196a2 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -2071,7 +2071,7 @@ static int __pidfd_prepare(struct pid *pid, unsigned int flags, struct file **re
if (pidfd < 0)
return pidfd;
- pidfd_file = pidfs_alloc_file(pid, flags | O_RDWR);
+ pidfd_file = pidfs_alloc_file(pid, flags);
if (IS_ERR(pidfd_file))
return PTR_ERR(pidfd_file);
--
2.47.2
next prev parent reply other threads:[~2025-04-14 9:54 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 ` Christian Brauner [this message]
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
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=20250414-work-coredump-v1-1-6caebc807ff4@kernel.org \
--to=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=oleg@redhat.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