mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-31 12:10:52 -04:00
inet: fix possible panic in reqsk_queue_unlink()
[ 3897.923145] BUG: unable to handle kernel NULL pointer dereference at 0000000000000080 [ 3897.931025] IP: [<ffffffffa9f27686>] reqsk_timer_handler+0x1a6/0x243 There is a race when reqsk_timer_handler() and tcp_check_req() call inet_csk_reqsk_queue_unlink() on the same req at the same time. Before commitfa76ce7328("inet: get rid of central tcp/dccp listener timer"), listener spinlock was held and race could not happen. To solve this bug, we change reqsk_queue_unlink() to not assume req must be found, and we return a status, to conditionally release a refcount on the request sock. This also means tcp_check_req() in non fastopen case might or not consume req refcount, so tcp_v6_hnd_req() & tcp_v4_hnd_req() have to properly handle this. (Same remark for dccp_check_req() and its callers) inet_csk_reqsk_queue_drop() is now too big to be inlined, as it is called 4 times in tcp and 3 times in dccp. Fixes:fa76ce7328("inet: get rid of central tcp/dccp listener timer") Signed-off-by: Eric Dumazet <[email protected]> Reported-by: Yuchung Cheng <[email protected]> Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
1d8dc3d3c8
commit
b357a364c5
9 changed files with 48 additions and 46 deletions
|
|
@ -453,7 +453,8 @@ static struct sock *dccp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
|
|||
iph->saddr, iph->daddr);
|
||||
if (req) {
|
||||
nsk = dccp_check_req(sk, skb, req);
|
||||
reqsk_put(req);
|
||||
if (!nsk)
|
||||
reqsk_put(req);
|
||||
return nsk;
|
||||
}
|
||||
nsk = inet_lookup_established(sock_net(sk), &dccp_hashinfo,
|
||||
|
|
|
|||
|
|
@ -301,7 +301,8 @@ static struct sock *dccp_v6_hnd_req(struct sock *sk,struct sk_buff *skb)
|
|||
&iph->daddr, inet6_iif(skb));
|
||||
if (req) {
|
||||
nsk = dccp_check_req(sk, skb, req);
|
||||
reqsk_put(req);
|
||||
if (!nsk)
|
||||
reqsk_put(req);
|
||||
return nsk;
|
||||
}
|
||||
nsk = __inet6_lookup_established(sock_net(sk), &dccp_hashinfo,
|
||||
|
|
|
|||
|
|
@ -186,8 +186,7 @@ struct sock *dccp_check_req(struct sock *sk, struct sk_buff *skb,
|
|||
if (child == NULL)
|
||||
goto listen_overflow;
|
||||
|
||||
inet_csk_reqsk_queue_unlink(sk, req);
|
||||
inet_csk_reqsk_queue_removed(sk, req);
|
||||
inet_csk_reqsk_queue_drop(sk, req);
|
||||
inet_csk_reqsk_queue_add(sk, req, child);
|
||||
out:
|
||||
return child;
|
||||
|
|
|
|||
Loading…
Reference in a new issue