udp: fix jump label misuse
The commit60fb9567bf
("udp: implement complete book-keeping for encap_needed") introduced a severe misuse of jump label APIs, which syzbot, as reported by Eric, was able to exploit. When multiple sockets/process can concurrently request (and than disable) the udp encap, we need to track the activation counter with *_inc()/*_dec() jump label variants, or we can experience bad things at disable time. Fixes:60fb9567bf
("udp: implement complete book-keeping for encap_needed") Reported-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
37342bdaf5
commit
9c48060141
@@ -587,7 +587,7 @@ static inline bool __udp_is_mcast_sock(struct net *net, struct sock *sk,
|
||||
DEFINE_STATIC_KEY_FALSE(udp_encap_needed_key);
|
||||
void udp_encap_enable(void)
|
||||
{
|
||||
static_branch_enable(&udp_encap_needed_key);
|
||||
static_branch_inc(&udp_encap_needed_key);
|
||||
}
|
||||
EXPORT_SYMBOL(udp_encap_enable);
|
||||
|
||||
@@ -2524,7 +2524,7 @@ void udp_destroy_sock(struct sock *sk)
|
||||
encap_destroy(sk);
|
||||
}
|
||||
if (up->encap_enabled)
|
||||
static_branch_disable(&udp_encap_needed_key);
|
||||
static_branch_dec(&udp_encap_needed_key);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user