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