From owner-svn-src-head@freebsd.org Mon May 20 08:31:03 2019 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 DF86B15A6099; Mon, 20 May 2019 08:31:02 +0000 (UTC) (envelope-from chagin.dmitry@gmail.com) Received: from mail-it1-f195.google.com (mail-it1-f195.google.com [209.85.166.195]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7D6B26B387; Mon, 20 May 2019 08:31:02 +0000 (UTC) (envelope-from chagin.dmitry@gmail.com) Received: by mail-it1-f195.google.com with SMTP id i63so21767897ita.3; Mon, 20 May 2019 01:31:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NKwbCtJ0CaA/2XXTuIweSGc5ULCtFAG12osamN7X7S4=; b=JPg1Pui0oib8xkvk8pESlSAFVY6W0JPe7CNMbVQT1ArLUsfK5b/4VZFoP0+GdaaRbO Pu7y9j3P1gMmOruhZ4g/MdfgAgXRAqSn0kFgiViWk7Cd1CYqULLRLWC53PZGGbt4hz/2 v70OVf0eThYej4Sjx1Q55HCCF51kpBRbYdNg39eipivSwJG+7h9VBG1wGZ+X7fDoBUo9 s2hFH8KYKFblq/y6NLo4sJ0HLroPD1dErI8qD4GFGc1EwTwp9Ovk0cX0uJtLcsEDbsVy Uk4oN+BJ5NqStGndu4ch7Aj5p2BePaDScV3RitepFiK/sguL6bfzUMiyniEPJu0aTZ4v 1rMA== X-Gm-Message-State: APjAAAUezxA38NlFk3YdM8FSW8egkeK+6hib/seNY0+gtFN9PsOfUxjl ZvxHa/xt4mN6x1lw8yCWFDJxo5JWKIeLx+g/EVpT5qMG X-Google-Smtp-Source: APXvYqz+EcwOGDa9zkB1HfeYWb8qRstbkAVrwRIXZKE7IvT7k0oaVCM2UZzWR9iUM4tZeMbX1PPLvPEVoZxmtY2g8Ng= X-Received: by 2002:a24:9987:: with SMTP id a129mr12716032ite.53.1558341055702; Mon, 20 May 2019 01:30:55 -0700 (PDT) MIME-Version: 1.0 References: <201905131748.x4DHmGaH020444@repo.freebsd.org> <20190519190511.6e8f436c@kalimero.tijl.coosemans.org> In-Reply-To: <20190519190511.6e8f436c@kalimero.tijl.coosemans.org> From: Dmitry Chagin Date: Mon, 20 May 2019 11:30:43 +0300 Message-ID: Subject: Re: svn commit: r347533 - in head/sys: compat/linux modules/linux_common To: =?UTF-8?Q?T=C4=B3l_Coosemans?= Cc: Dmitry Chagin , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org X-Rspamd-Queue-Id: 7D6B26B387 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.93 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.93)[-0.935,0]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 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: Mon, 20 May 2019 08:31:03 -0000 =D0=B2=D1=81, 19 =D0=BC=D0=B0=D1=8F 2019 =D0=B3. =D0=B2 20:05, T=C4=B3l Coo= semans : > On Mon, 13 May 2019 17:48:16 +0000 (UTC) Dmitry Chagin > wrote: > > Author: dchagin > > Date: Mon May 13 17:48:16 2019 > > New Revision: 347533 > > URL: https://svnweb.freebsd.org/changeset/base/347533 > > > > Log: > > Our bsd_to_linux_sockaddr() and linux_to_bsd_sockaddr() functions > > alter the userspace sockaddr to convert the format between linux and > BSD versions. > > That's the minimum 3 of copyin/copyout operations for one syscall. > > > > Also some syscall uses linux_sa_put() and linux_getsockaddr() when lo= ad > > sockaddr to userspace or from userspace accordingly. > > > > To avoid this chaos, especially converting sockaddr in the userspace, > > rewrite these 4 functions to convert sockaddr only in kernel and leav= e > > only 2 of this functions. > > > > Also in order to reduce duplication between MD parts of the > Linuxulator put > > struct sockaddr conversion functions that are MI out into linux_commo= n > module. > > > > PR: 232920 > > MFC after: 2 weeks > > Differential Revision: https://reviews.freebsd.org/D20157 > > > > Modified: > > head/sys/compat/linux/linux.c > > head/sys/compat/linux/linux.h > > head/sys/compat/linux/linux_common.h > > head/sys/compat/linux/linux_socket.c > > head/sys/compat/linux/linux_socket.h > > head/sys/modules/linux_common/Makefile > > > > Modified: head/sys/compat/linux/linux_socket.c > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > > --- head/sys/compat/linux/linux_socket.c Mon May 13 16:38:48 2019 > (r347532) > > +++ head/sys/compat/linux/linux_socket.c Mon May 13 17:48:16 2019 > (r347533) > > @@ -1282,6 +1110,8 @@ linux_recvmsg_common(struct thread *td, l_int s, > struc > > struct mbuf *control =3D NULL; > > struct mbuf **controlp; > > struct timeval *ftmvl; > > + struct l_sockaddr *lsa; > > + struct sockaddr *sa; > > l_timeval ltmvl; > > caddr_t outbuf; > > void *data; > > @@ -1305,36 +1135,34 @@ linux_recvmsg_common(struct thread *td, l_int s= , > struc > > return (error); > > > > if (msg->msg_name) { > > - error =3D linux_to_bsd_sockaddr((struct sockaddr > *)msg->msg_name, > > - msg->msg_namelen); > > - if (error !=3D 0) > > - goto bad; > > + sa =3D malloc(msg->msg_namelen, M_SONAME, M_WAITOK); > > + msg->msg_name =3D sa; > > } > > > > uiov =3D msg->msg_iov; > > msg->msg_iov =3D iov; > > controlp =3D (msg->msg_control !=3D NULL) ? &control : NULL; > > - error =3D kern_recvit(td, s, msg, UIO_USERSPACE, controlp); > > + error =3D kern_recvit(td, s, msg, UIO_SYSSPACE, controlp); > > msg->msg_iov =3D uiov; > > if (error !=3D 0) > > goto bad; > > > > - error =3D bsd_to_linux_msghdr(msg, &linux_msg); > > - if (error !=3D 0) > > - goto bad; > > - > > - if (linux_msg.msg_name) { > > - error =3D bsd_to_linux_sockaddr((struct sockaddr *) > > - PTRIN(linux_msg.msg_name)); > > + if (sa) { > > sa may be uninitialised here. > yes, I see. thank you. also sa leaks if kern_recvit() returns error. will fix