dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
From: Ilya Maximets <i.maximets@samsung.com>
To: dev@dpdk.org, Maxime Coquelin <maxime.coquelin@redhat.com>
Cc: Heetae Ahn <heetae82.ahn@samsung.com>,
	Yuanhan Liu <yliu@fridaylinux.org>,
	Bruce Richardson <bruce.richardson@intel.com>,
	Ilya Maximets <i.maximets@samsung.com>
Subject: [PATCH] vhost: add note about sockets in server mode
Date: Mon, 26 Feb 2018 11:39:01 +0300	[thread overview]
Message-ID: <1519634341-12305-1-git-send-email-i.maximets@samsung.com> (raw)
In-Reply-To: CGME20180226083909eucas1p1dbb604def497d348d0eaac45db09f11a@eucas1p1.samsung.com

>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.maximets@samsung.com>
---

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,
-- 
2.7.4

       reply	other threads:[~2018-02-26  8:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180226083909eucas1p1dbb604def497d348d0eaac45db09f11a@eucas1p1.samsung.com>
2018-02-26  8:39 ` Ilya Maximets [this message]
2018-03-06  9:06   ` [PATCH] vhost: add note about sockets in server mode Maxime Coquelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1519634341-12305-1-git-send-email-i.maximets@samsung.com \
    --to=i.maximets@samsung.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=heetae82.ahn@samsung.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=yliu@fridaylinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).