mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <brauner@kernel.org>
Cc: <alexander@mihalicyn.com>, <bluca@debian.org>,
	<daan.j.demeyer@gmail.com>, <davem@davemloft.net>,
	<david@readahead.eu>, <edumazet@google.com>, <horms@kernel.org>,
	<jack@suse.cz>, <kuba@kernel.org>, <kuniyu@amazon.com>,
	<lennart@poettering.net>, <linux-fsdevel@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <me@yhndnzj.com>,
	<netdev@vger.kernel.org>, <oleg@redhat.com>, <pabeni@redhat.com>
Subject: Re: [PATCH RFC 2/4] net, pidfs: prepare for handing out pidfds for reaped sk->sk_peer_pid
Date: Thu, 24 Apr 2025 18:57:19 -0700	[thread overview]
Message-ID: <20250425015911.93197-1-kuniyu@amazon.com> (raw)
In-Reply-To: <20250424-work-pidfs-net-v1-2-0dc97227d854@kernel.org>

From: Christian Brauner <brauner@kernel.org>
Date: Thu, 24 Apr 2025 14:24:35 +0200
> @@ -734,13 +743,48 @@ static void unix_release_sock(struct sock *sk, int embrion)
>  		unix_gc();		/* Garbage collect fds */
>  }
>  
> -static void init_peercred(struct sock *sk)
> +struct af_unix_peercred {

nit: conventional naming for AF_UNIX is without af_, all structs
(and most functions) start with unix_.


> +	struct pid *peer_pid;
> +	const struct cred *peer_cred;
> +};
> +
> +static inline int prepare_peercred(struct af_unix_peercred *peercred)
> +{
> +	struct pid *pid;
> +	int err;
> +
> +	pid = task_tgid(current);
> +	err = pidfs_register_pid(pid);
> +	if (likely(!err)) {
> +		peercred->peer_pid = get_pid(pid);
> +		peercred->peer_cred = get_current_cred();
> +	}
> +	return err;
> +}
> +
> +static void drop_peercred(struct af_unix_peercred *peercred)
> +{
> +	struct pid *pid = NULL;
> +	const struct cred *cred = NULL;

another nit: please keep variables in reverse xmas tree order.
https://docs.kernel.org/process/maintainer-netdev.html#local-variable-ordering-reverse-xmas-tree-rcs

Otherwise looks good to me.

  parent reply	other threads:[~2025-04-25  1:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-24 12:24 [PATCH RFC 0/4] net, pidfs: enable " Christian Brauner
2025-04-24 12:24 ` [PATCH RFC 1/4] pidfs: register pid in pidfs Christian Brauner
2025-04-24 13:24   ` Oleg Nesterov
2025-04-24 15:19     ` Christian Brauner
2025-04-24 12:24 ` [PATCH RFC 2/4] net, pidfs: prepare for handing out pidfds for reaped sk->sk_peer_pid Christian Brauner
2025-04-24 12:44   ` David Rheinsberg
2025-04-24 15:19     ` Christian Brauner
2025-04-25  1:08       ` Kuniyuki Iwashima
2025-04-25  8:02         ` Christian Brauner
2025-04-25  1:57   ` Kuniyuki Iwashima [this message]
2025-04-25  7:58     ` Christian Brauner
2025-04-24 12:24 ` [PATCH RFC 3/4] pidfs: get rid of __pidfd_prepare() Christian Brauner
2025-04-24 12:24 ` [PATCH RFC 4/4] net, pidfs: enable handing out pidfds for reaped sk->sk_peer_pid 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=20250425015911.93197-1-kuniyu@amazon.com \
    --to=kuniyu@amazon.com \
    --cc=alexander@mihalicyn.com \
    --cc=bluca@debian.org \
    --cc=brauner@kernel.org \
    --cc=daan.j.demeyer@gmail.com \
    --cc=davem@davemloft.net \
    --cc=david@readahead.eu \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jack@suse.cz \
    --cc=kuba@kernel.org \
    --cc=lennart@poettering.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@yhndnzj.com \
    --cc=netdev@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=pabeni@redhat.com \
    /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

all inboxes | Powered by JetHome®