Date: Sat, 15 Jul 2017 17:44:29 +0000 (UTC) From: Dmitry Chagin <dchagin@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r321022 - stable/10/sys/compat/linux Message-ID: <201707151744.v6FHiTI9073496@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201707151744.v6FHiTI9073496>