From owner-svn-src-head@freebsd.org Thu Jun 14 23:49:18 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2989D101A90D; Thu, 14 Jun 2018 23:49:18 +0000 (UTC) (envelope-from mmacy@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D0D936BBEB; Thu, 14 Jun 2018 23:49:17 +0000 (UTC) (envelope-from mmacy@freebsd.org) Received: from mail-it0-f48.google.com (mail-it0-f48.google.com [209.85.214.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) (Authenticated sender: mmacy) by smtp.freebsd.org (Postfix) with ESMTPSA id 9853412E1A; Thu, 14 Jun 2018 23:49:17 +0000 (UTC) (envelope-from mmacy@freebsd.org) Received: by mail-it0-f48.google.com with SMTP id 188-v6so597491ita.5; Thu, 14 Jun 2018 16:49:17 -0700 (PDT) X-Gm-Message-State: APt69E3hYDp0zCfMM43J8m8ZFZ5QhqD5dAEgpP7KSrHYjl06YKvVNzn0 dVnxhKBYRngNxtjULYfflT3qb6WRbYfJbRZ8oBA= X-Google-Smtp-Source: ADUXVKJpLjMKvTkheGBupJ7QfvVKOaX5RF+1bng6i4Vh+0aUUr1D1see3pEyDOI2Q9oRLPtpH7+4l1Ty9R2gB987BsU= X-Received: by 2002:a24:459f:: with SMTP id c31-v6mr4177943itd.132.1529020157074; Thu, 14 Jun 2018 16:49:17 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a02:8cd:0:0:0:0:0 with HTTP; Thu, 14 Jun 2018 16:49:16 -0700 (PDT) In-Reply-To: <20180614230713.GV1005@FreeBSD.org> References: <201806111631.w5BGVh2M051386@repo.freebsd.org> <20180614230713.GV1005@FreeBSD.org> From: Matthew Macy Date: Thu, 14 Jun 2018 16:49:16 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r334960 - head/sys/kern To: Gleb Smirnoff Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2018 23:49:18 -0000 diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 2d6dc845938..35bcad41a59 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -2175,6 +2175,7 @@ soreceive_stream(struct socket *so, struct sockaddr **psa, struct uio *uio, struct sockbuf *sb; struct mbuf *m, *n = NULL; + MPASS(controlp == NULL); /* We only do stream sockets. */ if (so->so_type != SOCK_STREAM) return (EINVAL); mmacy@VogonPoetry [~|16:38|56] ssh -Y 192.168.1.40 Edit /etc/motd to change this login announcement. mmacy@entropy [~|16:40|1] xterm & #14 0xffffffff80bcf580 in soreceive_stream (so=0xfffff800441fb790, psa=0xfffffe09b09b7758, uio=0xfffffe09b09b7790, mp0=0x0, controlp=0xfffffe09b09b7778, flagsp=0xfffffe09b09b78f4) at /usr/home/mmacy/devel/freebsd/sys/kern/uipc_socket.c:2178 #15 0xffffffff80bd0ba2 in soreceive (so=0xfffff800441fb790, psa=0xfffffe09b09b7758, uio=0xfffffe09b09b7790, mp0=0x0, controlp=0xfffffe09b09b7778, flagsp=0xfffffe09b09b78f4) at /usr/home/mmacy/devel/freebsd/sys/kern/uipc_socket.c:2567 #16 0xffffffff80bd8e06 in kern_recvit (td=0xfffff8000c8ee000, s=3, mp=0xfffffe09b09b78c8, fromseg=UIO_USERSPACE, controlp=0x0) at /usr/home/mmacy/devel/freebsd/sys/kern/uipc_syscalls.c:945 #17 0xffffffff80bd93c7 in recvit (td=0xfffff8000c8ee000, s=3, mp=0xfffffe09b09b78c8, namelenp=0x0) at /usr/home/mmacy/devel/freebsd/sys/kern/uipc_syscalls.c:1053 #18 0xffffffff80bd9515 in sys_recvmsg (td=0xfffff8000c8ee000, uap=0xfffff8000c8ee3c0) at /usr/home/mmacy/devel/freebsd/sys/kern/uipc_syscalls.c:1169 #19 0xffffffff810cde03 in syscallenter (td=0xfffff8000c8ee000) at /usr/home/mmacy/devel/freebsd/sys/amd64/amd64/../../kern/subr_syscall.c:135 #20 0xffffffff810cd64d in amd64_syscall (td=0xfffff8000c8ee000, traced=0) at /usr/home/mmacy/devel/freebsd/sys/amd64/amd64/trap.c:1007 #16 0xffffffff80bd8e06 in kern_recvit (td=0xfffff8000c8ee000, s=3, mp=0xfffffe09b09b78c8, fromseg=UIO_USERSPACE, controlp=0x0) at /usr/home/mmacy/devel/freebsd/sys/kern/uipc_syscalls.c:945 945 error = soreceive(so, &fromsa, &auio, NULL, (kgdb) list 940 #ifdef KTRACE 941 if (KTRPOINT(td, KTR_GENIO)) 942 ktruio = cloneuio(&auio); 943 #endif 944 len = auio.uio_resid; 945 error = soreceive(so, &fromsa, &auio, NULL, 946 (mp->msg_control || controlp) ? &control : NULL, 947 &mp->msg_flags); 948 if (error != 0) { 949 if (auio.uio_resid != len && (error == ERESTART || (kgdb) p mp->msg_control $1 = (void *) 0x7fffffffe2e0 int sys_recvmsg(struct thread *td, struct recvmsg_args *uap) { struct msghdr msg; struct iovec *uiov, *iov; int error; error = copyin(uap->msg, &msg, sizeof (msg)); if (error != 0) return (error); .... TL;DR X is passing in a msghdr with a control pointer. It isn't used for anything but returning EINVAL for it is a bug. -M On Thu, Jun 14, 2018 at 4:07 PM, Gleb Smirnoff wrote: > Hi, > > On Mon, Jun 11, 2018 at 04:31:43PM +0000, Matt Macy wrote: > M> Author: mmacy > M> Date: Mon Jun 11 16:31:42 2018 > M> New Revision: 334960 > M> URL: https://svnweb.freebsd.org/changeset/base/334960 > M> > M> Log: > M> soreceive_stream: correctly handle edge cases > M> > M> - non NULL controlp is not an error, returning EINVAL > M> would cause X forwarding to fail > > Can you please provide reference for a code that uses > control messages with a stream socket? > > The removed return was in action since FreeBSD 7.0 and > everything with X forwarding was working, AFAIK. > > -- > Gleb Smirnoff