Author: dchagin
Date: Thu May 30 14:21:51 2019
New Revision: 348418
URL: https://svnweb.freebsd.org/changeset/base/348418

Log:
  Linux does not support MSG_OOB for unix(4) or non-stream oriented socket,
  return EOPNOTSUPP as a Linux does.
  
  Reviewed by:  tijl
  MFC after:    1 week
  Differential Revision:        https://reviews.freebsd.org/D20409

Modified:
  head/sys/compat/linux/linux_socket.c

Modified: head/sys/compat/linux/linux_socket.c
==============================================================================
--- head/sys/compat/linux/linux_socket.c        Thu May 30 14:13:09 2019        
(r348417)
+++ head/sys/compat/linux/linux_socket.c        Thu May 30 14:21:51 2019        
(r348418)
@@ -939,11 +939,13 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
        struct iovec *iov;
        socklen_t datalen;
        struct sockaddr *sa;
+       struct socket *so;
        sa_family_t sa_family;
+       struct file *fp;
        void *data;
        l_size_t len;
        l_size_t clen;
-       int error;
+       int error, fflag;
 
        error = copyin(msghdr, &linux_msg, sizeof(linux_msg));
        if (error != 0)
@@ -974,12 +976,30 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
 
        control = NULL;
 
-       if (linux_msg.msg_controllen >= sizeof(struct l_cmsghdr)) {
-               error = kern_getsockname(td, s, &sa, &datalen);
+       error = kern_getsockname(td, s, &sa, &datalen);
+       if (error != 0)
+               goto bad;
+       sa_family = sa->sa_family;
+       free(sa, M_SONAME);
+
+       if (flags & LINUX_MSG_OOB) {
+               error = EOPNOTSUPP;
+               if (sa_family == AF_UNIX)
+                       goto bad;
+
+               error = getsock_cap(td, s, &cap_send_rights, &fp,
+                   &fflag, NULL);
                if (error != 0)
                        goto bad;
-               sa_family = sa->sa_family;
-               free(sa, M_SONAME);
+               so = fp->f_data;
+               if (so->so_type != SOCK_STREAM)
+                       error = EOPNOTSUPP;
+               fdrop(fp, td);
+               if (error != 0)
+                       goto bad;
+       }
+
+       if (linux_msg.msg_controllen >= sizeof(struct l_cmsghdr)) {
 
                error = ENOBUFS;
                control = m_get(M_WAITOK, MT_CONTROL);
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to