From owner-svn-src-all@freebsd.org Sun May 19 17:05:22 2019 Return-Path: Delivered-To: svn-src-all@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 DDC5115B2F88; Sun, 19 May 2019 17:05:21 +0000 (UTC) (envelope-from tijl@freebsd.org) Received: from mailrelay103.isp.belgacom.be (mailrelay103.isp.belgacom.be [195.238.20.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "relay.skynet.be", Issuer "GlobalSign Organization Validation CA - SHA256 - G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E92416CAA4; Sun, 19 May 2019 17:05:20 +0000 (UTC) (envelope-from tijl@freebsd.org) X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2DnAAAhjOFc/1H1sVtkHAEBAQQBAQc?= =?us-ascii?q?EAQGBUQcBAQsBAYIPWBFRASASFBSMLl+KDQEBggw1AYdngh6OGoF7CQEBAgE?= =?us-ascii?q?BAQEBKwwBAYRAAoIzJDQJDgEDAQEFAQEBAQRtHAxCAQwBhHsBBScTHCMQCw4?= =?us-ascii?q?GBAklD0gGE4Mjgg4LqkUzhDMBCwGEWoEKBoE0AYtngX+BEYMSPoREhWIEiwy?= =?us-ascii?q?INZRXCYIPhi6EQYgBJ5YfLYNPj0OQRTiBV00wCIMnghsXiGCFQT0DMINfi3g?= =?us-ascii?q?BAQ?= X-IPAS-Result: =?us-ascii?q?A2DnAAAhjOFc/1H1sVtkHAEBAQQBAQcEAQGBUQcBAQsBA?= =?us-ascii?q?YIPWBFRASASFBSMLl+KDQEBggw1AYdngh6OGoF7CQEBAgEBAQEBKwwBAYRAA?= =?us-ascii?q?oIzJDQJDgEDAQEFAQEBAQRtHAxCAQwBhHsBBScTHCMQCw4GBAklD0gGE4Mjg?= =?us-ascii?q?g4LqkUzhDMBCwGEWoEKBoE0AYtngX+BEYMSPoREhWIEiwyINZRXCYIPhi6EQ?= =?us-ascii?q?YgBJ5YfLYNPj0OQRTiBV00wCIMnghsXiGCFQT0DMINfi3gBAQ?= Received: from 81.245-177-91.adsl-dyn.isp.belgacom.be (HELO kalimero.tijl.coosemans.org) ([91.177.245.81]) by relay.skynet.be with ESMTP; 19 May 2019 19:05:12 +0200 Received: from kalimero.tijl.coosemans.org (kalimero.tijl.coosemans.org [127.0.0.1]) by kalimero.tijl.coosemans.org (8.15.2/8.15.2) with ESMTP id x4JH5Che001814; Sun, 19 May 2019 19:05:12 +0200 (CEST) (envelope-from tijl@FreeBSD.org) Date: Sun, 19 May 2019 19:05:11 +0200 From: =?UTF-8?B?VMSzbA==?= Coosemans To: Dmitry Chagin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r347533 - in head/sys: compat/linux modules/linux_common Message-ID: <20190519190511.6e8f436c@kalimero.tijl.coosemans.org> In-Reply-To: <201905131748.x4DHmGaH020444@repo.freebsd.org> References: <201905131748.x4DHmGaH020444@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: E92416CAA4 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.94)[-0.940,0]; ASN(0.00)[asn:5432, ipnet:195.238.0.0/19, country:BE] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 May 2019 17:05:22 -0000 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 load > 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 leave > 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_common 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 > ============================================================================== > --- 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 = 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 = linux_to_bsd_sockaddr((struct sockaddr *)msg->msg_name, > - msg->msg_namelen); > - if (error != 0) > - goto bad; > + sa = malloc(msg->msg_namelen, M_SONAME, M_WAITOK); > + msg->msg_name = sa; > } > > uiov = msg->msg_iov; > msg->msg_iov = iov; > controlp = (msg->msg_control != NULL) ? &control : NULL; > - error = kern_recvit(td, s, msg, UIO_USERSPACE, controlp); > + error = kern_recvit(td, s, msg, UIO_SYSSPACE, controlp); > msg->msg_iov = uiov; > if (error != 0) > goto bad; > > - error = bsd_to_linux_msghdr(msg, &linux_msg); > - if (error != 0) > - goto bad; > - > - if (linux_msg.msg_name) { > - error = bsd_to_linux_sockaddr((struct sockaddr *) > - PTRIN(linux_msg.msg_name)); > + if (sa) { sa may be uninitialised here.