RDS: Invoke ->laddr_check() in rds_bind() for explicitly bound transports.
authorSowmini Varadhan <sowmini.varadhan@oracle.com>
Sun, 11 Oct 2015 20:46:03 +0000 (16:46 -0400)
committerDavid S. Miller <davem@davemloft.net>
Tue, 13 Oct 2015 11:22:40 +0000 (04:22 -0700)
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.

Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/rds/bind.c

index bc6b93ecedb512bdcd75a9e765b2bd31cf2f0e81..61925667b7a43ca33fd2d2b692a741ee059c6e18 100644 (file)
@@ -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),