Re: [PATCH RFC 2/4] net, pidfs: prepare for handing out pidfds for reaped sk->sk_peer_pid

From: Christian Brauner
Date: Fri Apr 25 2025 - 03:58:55 EST


On Thu, Apr 24, 2025 at 06:57:19PM -0700, Kuniyuki Iwashima wrote:
> From: Christian Brauner <brauner@xxxxxxxxxx>
> 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_.

Done.

>
>
> > + 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

Done.

>
> Otherwise looks good to me.

Thanks!