From owner-freebsd-bugs@FreeBSD.ORG Fri Nov 26 18:40:16 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 158FA16A4CE for ; Fri, 26 Nov 2004 18:40:16 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id DAB6643D5C for ; Fri, 26 Nov 2004 18:40:15 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.1/8.13.1) with ESMTP id iAQIeFpf026281 for ; Fri, 26 Nov 2004 18:40:15 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.1/8.13.1/Submit) id iAQIeFIq026280; Fri, 26 Nov 2004 18:40:15 GMT (envelope-from gnats) Date: Fri, 26 Nov 2004 18:40:15 GMT Message-Id: <200411261840.iAQIeFIq026280@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Vincent Tougait Subject: Re: kern/26506: [patch] sendto() syscall returns EINVAL in jail environment X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Vincent Tougait List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Nov 2004 18:40:16 -0000 The following reply was made to PR kern/26506; it has been noted by GNATS. From: Vincent Tougait 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:08:58 +0100 --=-aS4TsxR2BDyHbb2JfPNf 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. --=-aS4TsxR2BDyHbb2JfPNf 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); --=-aS4TsxR2BDyHbb2JfPNf--