From owner-p4-projects@FreeBSD.ORG Thu Jan 25 14:48:08 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9EC2F16A407; Thu, 25 Jan 2007 14:48:08 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6152D16A405 for ; Thu, 25 Jan 2007 14:48:08 +0000 (UTC) (envelope-from rdivacky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 5184D13C45E for ; Thu, 25 Jan 2007 14:48:08 +0000 (UTC) (envelope-from rdivacky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id l0PEm8ZN046523 for ; Thu, 25 Jan 2007 14:48:08 GMT (envelope-from rdivacky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id l0PEm8kw046505 for perforce@freebsd.org; Thu, 25 Jan 2007 14:48:08 GMT (envelope-from rdivacky@FreeBSD.org) Date: Thu, 25 Jan 2007 14:48:08 GMT Message-Id: <200701251448.l0PEm8kw046505@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to rdivacky@FreeBSD.org using -f From: Roman Divacky To: Perforce Change Reviews Cc: Subject: PERFORCE change 113503 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Jan 2007 14:48:08 -0000 http://perforce.freebsd.org/chv.cgi?CH=113503 Change 113503 by rdivacky@rdivacky_witten on 2007/01/25 14:47:39 linux_sendmsg - if userspace passes us msg.msg_control && msg.msg_controllen == 0 set the controllen to 1 linux_recvmsg - we use msg but never load anything into it. I wonder how this could ever work. copyin the msg from userspace before doing anything with msg. Both this needs some checking as I dont understand the networking code but I didnt notice any obvious ill effects and this enables (+previous commit) ping to work from within linux chroot. Affected files ... .. //depot/projects/linuxolator/src/sys/compat/linux/linux_socket.c#12 edit Differences ... ==== //depot/projects/linuxolator/src/sys/compat/linux/linux_socket.c#12 (text+ko) ==== @@ -1027,6 +1027,15 @@ if (error) return (error); error = copyin(PTRIN(linux_args.msg), &msg, sizeof(msg)); + + /* + * Ping on linux does pass 0 in controllen which is forbidden + * by FreeBSD but seems to be ok on Linux. This needs some + * checking but now it lets ping work. + */ + if (msg.msg_control && msg.msg_controllen == 0) + msg.msg_controllen = sizeof(struct cmsghdr); + if (error) return (error); error = copyiniov(msg.msg_iov, msg.msg_iovlen, &iov, EMSGSIZE); @@ -1064,6 +1073,9 @@ if ((error = copyin(args, &linux_args, sizeof(linux_args)))) return (error); + if ((error = copyin(PTRIN(args->msg), &msg, sizeof (msg)))) + return (error); + bsd_args.s = linux_args.s; bsd_args.msg = PTRIN(linux_args.msg); bsd_args.flags = linux_to_bsd_msg_flags(linux_args.flags);