Re: [PATCH net-next v7 1/4] scm: add SO_PASSPIDFD and SCM_PIDFD

From: Heiko Carstens
Date: Fri Sep 01 2023 - 16:52:26 EST


On Fri, Sep 01, 2023 at 01:33:22PM -0700, Kuniyuki Iwashima wrote:
> From: Heiko Carstens <hca@xxxxxxxxxxxxx>
> Date: Fri, 1 Sep 2023 22:05:17 +0200
> > On Thu, Jun 08, 2023 at 10:26:25PM +0200, Alexander Mikhalitsyn wrote:
> > > + if ((msg->msg_controllen <= sizeof(struct cmsghdr)) ||
> > > + (msg->msg_controllen - sizeof(struct cmsghdr)) < sizeof(int)) {
> > > + msg->msg_flags |= MSG_CTRUNC;
> > > + return;
> > > + }
> >
> > This does not work for compat tasks since the size of struct cmsghdr (aka
> > struct compat_cmsghdr) is differently. If the check from put_cmsg() is
> > open-coded here, then also a different check for compat tasks needs to be
> > added.
> >
> > Discovered this because I was wondering why strace compat tests fail; it
> > seems because of this.
> >
> > See https://github.com/strace/strace/blob/master/tests/scm_pidfd.c
> >
> > For compat tasks recvmsg() returns with msg_flags=MSG_CTRUNC since the
> > above code expects a larger buffer than is necessary.
>
> Can you test this ?

Works for me.

Tested-by: Heiko Carstens <hca@xxxxxxxxxxxxx>