af_unix: Fix msg_controllen test in scm_pidfd_recv() for MSG_CMSG_COMPAT.
authorKuniyuki Iwashima <kuniyu@amazon.com>
Fri, 1 Sep 2023 23:46:04 +0000 (16:46 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 4 Sep 2023 10:00:17 +0000 (11:00 +0100)
commit718e6b51298e0f254baca0d40ab52a00e004e014
treea1dbc411e29d32fcbeaad32fa41cd000181fb16c
parent5245008738029135af52a2048d9fe9c4dd9be698
af_unix: Fix msg_controllen test in scm_pidfd_recv() for MSG_CMSG_COMPAT.

Heiko Carstens reported that SCM_PIDFD does not work with MSG_CMSG_COMPAT
because scm_pidfd_recv() always checks msg_controllen against sizeof(struct
cmsghdr).

We need to use sizeof(struct compat_cmsghdr) for the compat case.

Fixes: 5e2ff6704a27 ("scm: add SO_PASSPIDFD and SCM_PIDFD")
Reported-by: Heiko Carstens <hca@linux.ibm.com>
Closes: https://lore.kernel.org/netdev/20230901200517.8742-A-hca@linux.ibm.com/
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Tested-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Acked-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/scm.h