All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sargun Dhillon <sargun@sargun.me>
To: linux-kernel@vger.kernel.org,
	containers@lists.linux-foundation.org, linux-api@vger.kernel.org,
	linux-fsdevel@vger.kernel.org
Cc: Sargun Dhillon <sargun@sargun.me>,
	tycho@tycho.ws, christian.brauner@ubuntu.com
Subject: [PATCH 2/4] fork: Use newly created pidfd_create_file helper
Date: Fri, 24 Jan 2020 01:17:41 -0800	[thread overview]
Message-ID: <20200124091743.3357-3-sargun@sargun.me> (raw)
In-Reply-To: <20200124091743.3357-1-sargun@sargun.me>

Rather than duplicating the code to create a pidfd_file in kernel/fork.c,
use the helper in kernel/pid.c.

Signed-off-by: Sargun Dhillon <sargun@sargun.me>
---
 kernel/fork.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/fork.c b/kernel/fork.c
index 080809560072..181ab2958cad 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -2106,14 +2106,12 @@ static __latent_entropy struct task_struct *copy_process(
 
 		pidfd = retval;
 
-		pidfile = anon_inode_getfile("[pidfd]", &pidfd_fops, pid,
-					      O_RDWR | O_CLOEXEC);
+		pidfile = pidfd_create_file(pid);
 		if (IS_ERR(pidfile)) {
 			put_unused_fd(pidfd);
 			retval = PTR_ERR(pidfile);
 			goto bad_fork_free_pid;
 		}
-		get_pid(pid);	/* held by pidfile now */
 
 		retval = put_user(pidfd, args->pidfd);
 		if (retval)
-- 
2.20.1


  parent reply	other threads:[~2020-01-24  9:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-24  9:17 [PATCH 0/4] Add the ability to get a pidfd on seccomp user notifications Sargun Dhillon
2020-01-24  9:17 ` Sargun Dhillon
2020-01-24  9:17 ` [PATCH 1/4] pid: Add pidfd_create_file helper Sargun Dhillon
2020-01-24  9:17 ` Sargun Dhillon [this message]
2020-01-24  9:17 ` [PATCH 3/4] seccomp: Add SECCOMP_USER_NOTIF_FLAG_PIDFD to get pidfd on listener trap Sargun Dhillon
2020-01-24 18:03   ` Tycho Andersen
2020-01-24 20:09     ` Sargun Dhillon
2020-01-24 20:09       ` Sargun Dhillon
2020-01-26  4:10       ` Aleksa Sarai
2020-01-26  5:42       ` Tycho Andersen
2020-01-26  5:42         ` Tycho Andersen
     [not found]         ` <CAMp4zn_Xv2iicmH2Nc4-EZceD7T8AFe9PQRNX4bNEiAuoKs+vA@mail.gmail.com>
2020-05-15 11:58           ` Christian Brauner
2020-01-26  4:03   ` Aleksa Sarai
2020-01-26  4:14     ` Aleksa Sarai
2020-01-27  5:06       ` Sargun Dhillon
2020-01-24  9:17 ` [PATCH 4/4] selftests/seccomp: test SECCOMP_USER_NOTIF_FLAG_PIDFD Sargun Dhillon
2020-01-24  9:17   ` Sargun Dhillon

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=20200124091743.3357-3-sargun@sargun.me \
    --to=sargun@sargun.me \
    --cc=christian.brauner@ubuntu.com \
    --cc=containers@lists.linux-foundation.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tycho@tycho.ws \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.