Skip to content

Commit 673d116

Browse files
kcp-gitgregkh
authored andcommitted
net/rds: Check laddr_check before calling it
[ Upstream commit 0573343 ] 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: c5c1a03 ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent fc5b597 commit 673d116

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎net/rds/bind.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
244244
*/
245245
if (rs->rs_transport) {
246246
trans = rs->rs_transport;
247-
if (trans->laddr_check(sock_net(sock->sk),
247+
if (!trans->laddr_check ||
248+
trans->laddr_check(sock_net(sock->sk),
248249
binding_addr, scope_id) != 0) {
249250
ret = -ENOPROTOOPT;
250251
goto out;
@@ -263,6 +264,8 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
263264

264265
sock_set_flag(sk, SOCK_RCU_FREE);
265266
ret = rds_add_bound(rs, binding_addr, &port, scope_id);
267+
if (ret)
268+
rs->rs_transport = NULL;
266269

267270
out:
268271
release_sock(sk);

0 commit comments

Comments
 (0)