Skip to contentSkip to conversation

RDS: Invoke ->laddr_check() in rds_bind() for explicitly bound transports.

PATCH Applied Sowmini Varadhan 3 participants 3 messages Oct 11, 2015 – Oct 13, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDS: Invoke ->laddr_check() in rds_bind() for explicitly bound transports.

The IP address passed to rds_bind() should be vetted by the transport's ->laddr_check() for a previously bound transport. This needs to be done to avoid cases where, for example, the application has asked for an IB transport,
but the IP address passed to bind is only usable on ethernet interfaces.

---
 net/rds/bind.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
net/rds/bind.c +8 -1
index bc6b93e..6192566 100644
@@ -196,7 +196,14 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 		goto out;
 
 	if (rs->rs_transport) { /* previously bound */
-		ret = 0;
+		trans = rs->rs_transport;
+		if (trans->laddr_check(sock_net(sock->sk),
+				       sin->sin_addr.s_addr) != 0) {
+			ret = -ENOPROTOOPT;
+			rds_remove_bound(rs);
+		} else {
+			ret = 0;
+		}
 		goto out;
 	}
 	trans = rds_trans_get_preferred(sock_net(sock->sk),
Signature · 1 line
1.7.1
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Sowmini Varadhan

The IP address passed to rds_bind() should be vetted by the transport's ->laddr_check() for a previously bound transport. This needs to be done to avoid cases where, for example, the application has asked for an IB transport,
but the IP address passed to bind is only usable on ethernet interfaces.

Right. Probably it should go into stable as well.

Quoted 10 lines
---
  net/rds/bind.c |    9 ++++++++-
  1 files changed, 8 insertions(+), 1 deletions(-)
net/rds/bind.c +0 -0
index bc6b93e..6192566 100644

net/rds/bind.c int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) · line 199

Quoted 4 lines
net/rds/bind.c +0 -1
@@ -196,7 +196,14 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
  		goto out;
 
  	if (rs->rs_transport) { /* previously bound */
-		ret = 0;

Minor comment. If you retain above line you can drop the below else.

net/rds/bind.c int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) · line 206

Quoted 8 lines
net/rds/bind.c +8 -0
+		trans = rs->rs_transport;
+		if (trans->laddr_check(sock_net(sock->sk),
+				       sin->sin_addr.s_addr) != 0) {
+			ret = -ENOPROTOOPT;
+			rds_remove_bound(rs);
+		} else {
+			ret = 0;
+		}
maintainer Applied
#2 lore raw
In reply to Sowmini Varadhan

From: Sowmini Varadhan <[email protected]>
Date: Sun, 11 Oct 2015 16:46:03 -0400

Quoted 8 lines

The IP address passed to rds_bind() should be vetted by the transport's ->laddr_check() for a previously bound transport. This needs to be done to avoid cases where, for example, the application has asked for an IB transport,
but the IP address passed to bind is only usable on ethernet interfaces.

Applied.