Date: Fri, 26 Nov 2004 15:20:29 GMT From: Vincent Tougait <viny@scientiae.net> To: freebsd-bugs@FreeBSD.org Subject: Re: kern/26506: [patch] sendto() syscall returns EINVAL in jail environment Message-ID: <200411261520.iAQFKTRV003581@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/26506; it has been noted by GNATS. From: Vincent Tougait <viny@scientiae.net> To: freebsd-gnats-submit@FreeBSD.org Cc: Subject: Re: kern/26506: [patch] sendto() syscall returns EINVAL in jail environment Date: Fri, 26 Nov 2004 16:19:07 +0100 --=-2uyUitBh9ScHvfaIOLS/ Content-Type: text/plain Content-Transfer-Encoding: 7bit I had the same problem on a FreeBSD 5.3-BETA4. An ircd wouldn't resolve IPs as DNS requests would fail, sendto() returning EINVAL. As available patches didn't apply to 5.X, I did some search and I eventually found that it came from a test in src/sys/netinet/in_pcb.c, in function in_pcbbind_setup(inp, nam, laddrp, lportp, cred) : if (sin->sin_port != *lportp) { /* Don't allow the port to change. */ if (*lportp != 0) return (EINVAL); lport = sin->sin_port; } /* NB: lport is left as 0 if the port isn't being changed. */ For some reason, *lportp isn't null. By looking a little further, it seems that in_pcbbind_setup() is called by udp_output(inp, m, addr, control, td) in src/sys/netinet/udp_usrreq.c. if (lport == 0) { error = EINVAL; goto release; } error = in_pcbbind_setup(inp, (struct sockaddr *)&src, &laddr.s_addr, &lport, td->td_ucred); So just before the call, there is a test which returns EINVAL if lport is null. Then in_pcbbind_setup() is called with lport as value, which is not null (else it would return EINVAL there). As nothing seems to affect *lportp in in_pcbbind_setup(), *lportp is still not null when the second test occurs and it returns EINVAL. By commenting the test in in_pcbbind_setup (diff attached), I was able to make my ircd work. I didn't see any problems since, but I'm not really sure I did the best thing. --=-2uyUitBh9ScHvfaIOLS/ Content-Disposition: attachment; filename=patch-in_pcb.c Content-Type: text/x-patch; name=patch-in_pcb.c; charset=iso8859-1 Content-Transfer-Encoding: 7bit Index: src/sys/netinet/in_pcb.c =================================================================== RCS file: /home/ncvs/src/sys/netinet/in_pcb.c,v retrieving revision 1.156 diff -r1.156 in_pcb.c 296,298d295 < /* Don't allow the port to change. */ < if (*lportp != 0) < return (EINVAL); --=-2uyUitBh9ScHvfaIOLS/--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200411261520.iAQFKTRV003581>