Date: Tue, 8 Mar 2016 16:55:26 +0100 From: Mateusz Guzik <mjguzik@gmail.com> To: Dmitry Chagin <dchagin@FreeBSD.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r296503 - head/sys/compat/linux Message-ID: <20160308155526.GB7447@dft-labs.eu> In-Reply-To: <201603081515.u28FFYhu008909@repo.freebsd.org> References: <201603081515.u28FFYhu008909@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Mar 08, 2016 at 03:15:34PM +0000, Dmitry Chagin wrote: > Author: dchagin > Date: Tue Mar 8 15:15:34 2016 > New Revision: 296503 > URL: https://svnweb.freebsd.org/changeset/base/296503 > > Log: > Linux accept() system call return EOPNOTSUPP errno instead of EINVAL > for UDP sockets. > > MFC after: 1 week > > Modified: > head/sys/compat/linux/linux_socket.c > > Modified: head/sys/compat/linux/linux_socket.c > ============================================================================== > --- head/sys/compat/linux/linux_socket.c Tue Mar 8 15:12:49 2016 (r296502) > +++ head/sys/compat/linux/linux_socket.c Tue Mar 8 15:15:34 2016 (r296503) > @@ -781,7 +781,10 @@ linux_accept_common(struct thread *td, i > 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: */ > @@ -796,6 +799,14 @@ linux_accept_common(struct thread *td, i > if (error) { > if (error == EFAULT && namelen != sizeof(struct sockaddr_in)) > return (EINVAL); > + if (error == EINVAL) { > + error1 = getsock_cap(td, s, &rights, &fp, NULL); > + if (error1 != 0) > + return (error1); > + so = (struct socket *)fp->f_data; > + if (so->so_type == SOCK_DGRAM) > + return (EOPNOTSUPP); > + } > return (error); > } > if (addr) What drops the reference obtained from getsock_cap? Also the race due to double fd lookup, while fine enough for this purpose, should be documented as accepted. -- Mateusz Guzik <mjguzik gmail.com>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160308155526.GB7447>