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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux