linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steve Dickson <steved@redhat.com>
To: Linux NFS Mailing list <linux-nfs@vger.kernel.org>
Subject: [PATCH 1/1] rmtcalls: Don't use privileged ports for remote calls.
Date: Mon,  5 Feb 2018 11:36:47 -0500	[thread overview]
Message-ID: <20180205163647.15822-2-steved@redhat.com> (raw)
In-Reply-To: <20180205163647.15822-1-steved@redhat.com>

Sockets use for remote calls are preallocated which
mean the a port will be tied up for as long as
rpcbind runs. Make sure that port is not a privileged
port by binding the socket before calling svc_tli_create()

Signed-off-by: Steve Dickson <steved@redhat.com>
---
 src/rpcb_svc_com.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/rpcb_svc_com.c b/src/rpcb_svc_com.c
index 9c1c3af..b9aeaaf 100644
--- a/src/rpcb_svc_com.c
+++ b/src/rpcb_svc_com.c
@@ -501,9 +501,12 @@ static struct rmtcallfd_list *rmttail;
 int
 create_rmtcall_fd(struct netconfig *nconf)
 {
-	int fd;
+	int fd, cc;
 	struct rmtcallfd_list *rmt;
 	SVCXPRT *xprt;
+	struct __rpc_sockinfo si;
+	struct sockaddr_storage ss;
+	struct t_bind bindaddr;
 
 	if ((fd = __rpc_nconf2fd(nconf)) == -1) {
 		if (debugging)
@@ -512,6 +515,20 @@ create_rmtcall_fd(struct netconfig *nconf)
 			nconf->nc_device, errno);
 		return (-1);
 	}
+
+	if (!__rpc_nconf2sockinfo(nconf, &si)) {
+		xlog(LOG_ERR, "create_rmtcall_fd: cannot get information for %s",
+		    nconf->nc_netid);
+		return (-1);
+	}
+	memset(&ss, 0, sizeof ss);
+	ss.ss_family = si.si_af;
+	cc = bind(fd, (struct sockaddr *)(void *)&ss,
+		(socklen_t)si.si_alen);
+	if (cc < 0) {
+		xlog(LOG_ERR, "create_rmtcall_fd: could not bind to anonymous port");
+		return (-1);
+	}
 	xprt = svc_tli_create(fd, 0, (struct t_bind *) 0, 0, 0);
 	if (xprt == NULL) {
 		if (debugging)
-- 
2.14.3


  reply	other threads:[~2018-02-05 16:36 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-05 16:36 [PATCH 0/1] Remote calls don't need to use privilege ports Steve Dickson
2018-02-05 16:36 ` Steve Dickson [this message]
2018-02-05 17:02 ` Chuck Lever
2018-02-05 17:09   ` Tom Talpey
2018-02-05 17:11     ` Chuck Lever
2018-02-05 19:46     ` Steve Dickson
2018-02-07  4:35     ` NeilBrown
2018-02-07 16:09       ` Chuck Lever
2018-02-07 21:16         ` NeilBrown
2018-02-07 21:23           ` Chuck Lever
2018-02-07 23:16             ` NeilBrown
2018-02-08  0:13               ` Chuck Lever
2018-02-08  0:45                 ` NeilBrown
2018-02-08  0:46                   ` Chuck Lever
2018-02-05 19:21   ` Steve Dickson
2018-02-05 19:47     ` Chuck Lever
2018-02-06 16:37       ` Steve Dickson
2018-02-06 17:34         ` Chuck Lever
2018-02-06 18:22           ` Tom Talpey
2018-02-06 18:36             ` Chuck Lever
2018-02-07  0:15               ` Tom Talpey
2018-02-06 19:00         ` Chuck Lever

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=20180205163647.15822-2-steved@redhat.com \
    --to=steved@redhat.com \
    --cc=linux-nfs@vger.kernel.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).