From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by dpdk.org (Postfix) with ESMTP id F0FD29E4 for ; Tue, 6 Mar 2018 10:06:56 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7429684221; Tue, 6 Mar 2018 09:06:56 +0000 (UTC) Received: from [10.36.112.61] (ovpn-112-61.ams2.redhat.com [10.36.112.61]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 26F4710E60D7; Tue, 6 Mar 2018 09:06:54 +0000 (UTC) To: Ilya Maximets , dev@dpdk.org Cc: Heetae Ahn , Yuanhan Liu , Bruce Richardson References: <1519634341-12305-1-git-send-email-i.maximets@samsung.com> From: Maxime Coquelin Message-ID: Date: Tue, 6 Mar 2018 10:06:53 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <1519634341-12305-1-git-send-email-i.maximets@samsung.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 06 Mar 2018 09:06:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 06 Mar 2018 09:06:56 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'maxime.coquelin@redhat.com' RCPT:'' Subject: Re: [dpdk-dev] [PATCH] vhost: add note about sockets in server mode X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Mar 2018 09:06:57 -0000 Hi Ilya, On 02/26/2018 09:39 AM, Ilya Maximets wrote: > From time to time, someone sends patches about unlinking existing > sockets when registering a vhost user in server mode. > > A recent example: > http://dpdk.org/ml/archives/dev/2018-February/090025.html > > This problem has been discussed many times, and it was made clear that > the library should not unlink files given by the application in order > to avoid possible security problems, such as removing random files > used by other programs. > > One of the first discussions: > http://dpdk.org/ml/archives/dev/2015-December/030326.html > > To avoid such patches in the future, it was decided to add a comment > that explains what is happening and tries to describe the reasoning. > > Signed-off-by: Ilya Maximets > --- > > I'm open for suggestions. Wording/grammar fixes are also welcome. > > lib/librte_vhost/socket.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c > index 83befdc..e8584f3 100644 > --- a/lib/librte_vhost/socket.c > +++ b/lib/librte_vhost/socket.c > @@ -318,6 +318,16 @@ vhost_user_start_server(struct vhost_user_socket *vsocket) > int fd = vsocket->socket_fd; > const char *path = vsocket->path; > > + /* > + * bind () may fail if the socket file with the same name already > + * exists. But the library obviously should not delete the file > + * provided by the user, since we can not be sure that it is not > + * being used by other applications. Moreover, many applications form > + * socket names based on user input, which is prone to errors. > + * > + * The user must ensure that the socket does not exist before > + * registering the vhost driver in server mode. > + */ > ret = bind(fd, (struct sockaddr *)&vsocket->un, sizeof(vsocket->un)); > if (ret < 0) { > RTE_LOG(ERR, VHOST_CONFIG, > Reviewed-by: Maxime Coquelin Thanks! Maxime