]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net/rds: Check laddr_check before calling it
authorKa-Cheong Poon <ka-cheong.poon@oracle.com>
Tue, 24 Sep 2019 15:51:16 +0000 (08:51 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 27 Sep 2019 10:10:55 +0000 (12:10 +0200)
In rds_bind(), laddr_check is called without checking if it is NULL or
not.  And rs_transport should be reset if rds_add_bound() fails.

Fixes: d6b20a05f2ee ("net/rds: An rds_sock is added too early to the hash table")
Reported-by: syzbot+fae39afd2101a17ec624@syzkaller.appspotmail.com
Signed-off-by: Ka-Cheong Poon <ka-cheong.poon@oracle.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/rds/bind.c

index 20c156a73e73fa47eaa77de770a7fd9d2318072f..5b5fb4ca8d3e5523336aee389acd7ad160b28d2f 100644 (file)
@@ -244,7 +244,8 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
         */
        if (rs->rs_transport) {
                trans = rs->rs_transport;
-               if (trans->laddr_check(sock_net(sock->sk),
+               if (!trans->laddr_check ||
+                   trans->laddr_check(sock_net(sock->sk),
                                       binding_addr, scope_id) != 0) {
                        ret = -ENOPROTOOPT;
                        goto out;
@@ -263,6 +264,8 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 
        sock_set_flag(sk, SOCK_RCU_FREE);
        ret = rds_add_bound(rs, binding_addr, &port, scope_id);
+       if (ret)
+               rs->rs_transport = NULL;
 
 out:
        release_sock(sk);