Re: [PATCH] net/unix: pass pidfd flags via SCM_PIDFD cmsg
From: Kuniyuki Iwashima
Date: Wed Nov 13 2024 - 21:50:59 EST
From: Stas Sergeev <stsp2@xxxxxxxxx>
Date: Thu, 14 Nov 2024 00:02:05 +0300
> @@ -154,7 +157,12 @@ static __inline__ void scm_pidfd_recv(struct msghdr *msg, struct scm_cookie *scm
> if (!scm->pid)
> return;
>
> - pidfd = pidfd_prepare(scm->pid, 0, &pidfd_file);
> + err = pidfd_validate_flags(scm->pidfd_flags);
No neede to double check here, it's already checked in __scm_send().
> + if (err) {
> + msg->msg_flags |= MSG_CTRUNC;
> + return;
> + }
> + pidfd = pidfd_prepare(scm->pid, scm->pidfd_flags, &pidfd_file);
>
> if (put_cmsg(msg, SOL_SOCKET, SCM_PIDFD, sizeof(int), &pidfd)) {
> if (pidfd_file) {