Re: [PATCH v2] net/unix: pass pidfd flags via SCM_PIDFD cmsg

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

 



16.11.2024 04:10, Kuniyuki Iwashima пишет:
Now this allows sending pidfd without SO_PASSPIDFD, so you need to
add a validation for "if (!msg->msg_control)" in __scm_recv_common().
Will do, thanks.
Btw don't we need MSG_CTRUNC in
such case even if "msg_control"exists?
Or the established practice is to just drop cmsg silently?
I mean, something like the below:

--- a/include/net/scm.h
+++ b/include/net/scm.h
@@ -176,12 +176,19 @@ static inline bool __scm_recv_common(struct socket *sock, struct msghdr *msg,
        if (!msg->msg_control) {
                if (test_bit(SOCK_PASSCRED, &sock->flags) ||
                    test_bit(SOCK_PASSPIDFD, &sock->flags) ||
-                   scm->fp || scm_has_secdata(sock))
+                   scm->fp || scm_has_secdata(sock) ||
+                   scm->pidfd_flags)
                        msg->msg_flags |= MSG_CTRUNC;
                scm_destroy(scm);
                return false;
        }

+       if (!test_bit(SOCK_PASSPIDFD, &sock->flags) && scm->pidfd_flags) {
+               msg->msg_flags |= MSG_CTRUNC;
+               scm_destroy(scm);
+               return false;
+       }
+
        if (test_bit(SOCK_PASSCRED, &sock->flags)) {
                struct user_namespace *current_ns = current_user_ns();
                struct ucred ucreds = {




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux