diff mbox

[net] netlink: Reset portid after netlink_insert failure

Message ID 20150516135028.GA1271@gondor.apana.org.au
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Herbert Xu May 16, 2015, 1:50 p.m. UTC
The commit c5adde9468b0714a051eac7f9666f23eb10b61f7 ("netlink:
eliminate nl_sk_hash_lock") breaks the autobind retry mechanism
because it doesn't reset portid after a failed netlink_insert.

This means that should autobind fail the first time around, then
the socket will be stuck in limbo as it can never be bound again
since it already has a non-zero portid.

Fixes: c5adde9468b0 ("netlink: eliminate nl_sk_hash_lock") 
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Comments

David Miller May 16, 2015, 9:09 p.m. UTC | #1
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Sat, 16 May 2015 21:50:28 +0800

> The commit c5adde9468b0714a051eac7f9666f23eb10b61f7 ("netlink:
> eliminate nl_sk_hash_lock") breaks the autobind retry mechanism
> because it doesn't reset portid after a failed netlink_insert.
> 
> This means that should autobind fail the first time around, then
> the socket will be stuck in limbo as it can never be bound again
> since it already has a non-zero portid.
> 
> Fixes: c5adde9468b0 ("netlink: eliminate nl_sk_hash_lock") 
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Looks good, applied and queued up for -stable.

Thanks!
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 6ffce5b..d2a4438 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1081,6 +1081,7 @@  static int netlink_insert(struct sock *sk, u32 portid)
 	if (err) {
 		if (err == -EEXIST)
 			err = -EADDRINUSE;
+		nlk_sk(sk)->portid = 0;
 		sock_put(sk);
 	}