kern/26506: [patch] sendto() syscall returns EINVAL in jail environment

Vincent Tougait viny at scientiae.net
Fri Nov 26 10:40:27 PST 2004


The following reply was made to PR kern/26506; it has been noted by GNATS.

From: Vincent Tougait <viny at scientiae.net>
To: freebsd-gnats-submit at FreeBSD.org, venglin at freebsd.lublin.pl
Cc:  
Subject: Re: kern/26506: [patch] sendto() syscall returns EINVAL in jail
	environment
Date: Fri, 26 Nov 2004 16:03:37 +0100

 --=-JpRQDeCU6X8jdrA6D5HV
 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.
 
 --=-JpRQDeCU6X8jdrA6D5HV
 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);
 
 --=-JpRQDeCU6X8jdrA6D5HV--
 


More information about the freebsd-bugs mailing list