Author: dchagin
Date: Sat Jul 15 17:44:29 2017
New Revision: 321022
URL: https://svnweb.freebsd.org/changeset/base/321022

Log:
  MFC r296503:
  
  Linux accept() system call return EOPNOTSUPP errno instead of EINVAL
  for UDP sockets.
  
  MFC r296504:
  
  Does not leak fp. While here remove bogus cast of fp->f_data.
  
  MFC r313913:
  
  Initialize cap_rights before use.

Modified:
  stable/10/sys/compat/linux/linux_socket.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/compat/linux/linux_socket.c
==============================================================================
--- stable/10/sys/compat/linux/linux_socket.c   Sat Jul 15 17:28:03 2017        
(r321021)
+++ stable/10/sys/compat/linux/linux_socket.c   Sat Jul 15 17:44:29 2017        
(r321022)
@@ -836,7 +836,10 @@ linux_accept_common(struct thread *td, int s, l_uintpt
                socklen_t * __restrict anamelen;
                int     flags;
        } */ bsd_args;
-       int error;
+       cap_rights_t rights;
+       struct socket *so;
+       struct file *fp;
+       int error, error1;
 
        bsd_args.s = s;
        /* XXX: */
@@ -851,6 +854,18 @@ linux_accept_common(struct thread *td, int s, l_uintpt
        if (error) {
                if (error == EFAULT && namelen != sizeof(struct sockaddr_in))
                        return (EINVAL);
+               if (error == EINVAL) {
+                       error1 = getsock_cap(td, s,
+                           cap_rights_init(&rights, CAP_ACCEPT), &fp, NULL);
+                       if (error1 != 0)
+                               return (error1);
+                       so = fp->f_data;
+                       if (so->so_type == SOCK_DGRAM) {
+                               fdrop(fp, td);
+                               return (EOPNOTSUPP);
+                       }
+                       fdrop(fp, td);
+               }
                return (error);
        }
        if (addr)
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "[email protected]"

Reply via email to