diff mbox series

[37/39] lnet: use an unbound cred in kiblnd_resolve_addr()

Message ID 1611249422-556-38-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series lustre: update to latest OpenSFS version as of Jan 21 2021 | expand

Commit Message

James Simmons Jan. 21, 2021, 5:17 p.m. UTC
From: "John L. Hammond" <jhammond@whamcloud.com>

In kiblnd_resolve_addr() call prepare_kernel_cred(NULL) rather than
prepare_creds() to get a cred with unbound capabilities.

Fixes: 5fc342b471a ("lnet: o2ib: raise bind cap before resolving address")
WC-bug-id: https://jira.whamcloud.com/browse/LU-14296
Lustre-commit: 30b356a28b5094 ("LU-14296 lnet: use an unbound cred in kiblnd_resolve_addr()")
Signed-off-by: John L. Hammond <jhammond@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/41137
Reviewed-by: Amir Shehata <ashehata@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 net/lnet/klnds/o2iblnd/o2iblnd_cb.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/net/lnet/klnds/o2iblnd/o2iblnd_cb.c b/net/lnet/klnds/o2iblnd/o2iblnd_cb.c
index c799453..e29cb4b 100644
--- a/net/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/net/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -1207,8 +1207,6 @@  static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 	unsigned short port;
 	int rc;
 
-	LASSERT(capable(CAP_NET_BIND_SERVICE));
-
 	/* allow the port to be reused */
 	rc = rdma_set_reuseaddr(cmid, 1);
 	if (rc) {
@@ -1234,7 +1232,8 @@  static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 		}
 	}
 
-	CERROR("Failed to bind to a free privileged port\n");
+	CERROR("cannot bind to a free privileged port: rc = %d\n", rc);
+
 	return rc;
 }
 
@@ -1249,7 +1248,7 @@  static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx,
 	int rc;
 
 	if (!capable(CAP_NET_BIND_SERVICE)) {
-		new_creds = prepare_creds();
+		new_creds = prepare_kernel_cred(NULL);
 		if (!new_creds)
 			return -ENOMEM;