Date: Thu, 25 Jan 2007 14:48:08 GMT From: Roman Divacky <rdivacky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 113503 for review Message-ID: <200701251448.l0PEm8kw046505@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200701251448.l0PEm8kw046505>