mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 19:51:31 -04:00
dccp/tcp: Avoid negative sk_forward_alloc by ipv6_pinfo.pktoptions.
commit ca43ccf41224b023fc290073d5603a755fd12eed upstream. Eric Dumazet pointed out [0] that when we call skb_set_owner_r() for ipv6_pinfo.pktoptions, sk_rmem_schedule() has not been called, resulting in a negative sk_forward_alloc. We add a new helper which clones a skb and sets its owner only when sk_rmem_schedule() succeeds. Note that we move skb_set_owner_r() forward in (dccp|tcp)_v6_do_rcv() because tcp_send_synack() can make sk_forward_alloc negative before ipv6_opt_accepted() in the crossed SYN-ACK or self-connect() cases. [0]: https://lore.kernel.org/netdev/CANn89iK9oc20Jdi_41jb9URdF210r7d1Y-+uypbMSbOfY6jqrg@mail.gmail.com/ Fixes:323fbd0edf("net: dccp: Add handling of IPV6_PKTOPTIONS to dccp_v6_do_rcv()") Fixes:3df80d9320("[DCCP]: Introduce DCCPv6") Fixes:1da177e4c3("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
parent
a4e9411769
commit
0c2651c763
3 changed files with 18 additions and 12 deletions
|
|
@ -541,11 +541,9 @@ static struct sock *dccp_v6_request_recv_sock(const struct sock *sk,
|
|||
*own_req = inet_ehash_nolisten(newsk, req_to_sk(req_unhash), NULL);
|
||||
/* Clone pktoptions received with SYN, if we own the req */
|
||||
if (*own_req && ireq->pktopts) {
|
||||
newnp->pktoptions = skb_clone(ireq->pktopts, GFP_ATOMIC);
|
||||
newnp->pktoptions = skb_clone_and_charge_r(ireq->pktopts, newsk);
|
||||
consume_skb(ireq->pktopts);
|
||||
ireq->pktopts = NULL;
|
||||
if (newnp->pktoptions)
|
||||
skb_set_owner_r(newnp->pktoptions, newsk);
|
||||
}
|
||||
|
||||
return newsk;
|
||||
|
|
@ -605,7 +603,7 @@ static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
|
|||
--ANK (980728)
|
||||
*/
|
||||
if (np->rxopt.all)
|
||||
opt_skb = skb_clone(skb, GFP_ATOMIC);
|
||||
opt_skb = skb_clone_and_charge_r(skb, sk);
|
||||
|
||||
if (sk->sk_state == DCCP_OPEN) { /* Fast path */
|
||||
if (dccp_rcv_established(sk, skb, dccp_hdr(skb), skb->len))
|
||||
|
|
@ -669,7 +667,6 @@ ipv6_pktoptions:
|
|||
np->flow_label = ip6_flowlabel(ipv6_hdr(opt_skb));
|
||||
if (ipv6_opt_accepted(sk, opt_skb,
|
||||
&DCCP_SKB_CB(opt_skb)->header.h6)) {
|
||||
skb_set_owner_r(opt_skb, sk);
|
||||
memmove(IP6CB(opt_skb),
|
||||
&DCCP_SKB_CB(opt_skb)->header.h6,
|
||||
sizeof(struct inet6_skb_parm));
|
||||
|
|
|
|||
Loading…
Reference in a new issue