]> git.baikalelectronics.ru Git - kernel.git/commit
tcp: fix sock skb accounting in tcp_read_skb()
authorCong Wang <cong.wang@bytedance.com>
Wed, 17 Aug 2022 19:54:42 +0000 (12:54 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 18 Aug 2022 18:04:55 +0000 (11:04 -0700)
commitd08708cd2babb1f0c89c144ec4db19f303dc1eeb
tree3ca11d4513d0bd6b36983e8e9c389ba564ee0099
parent956b1b448bda29a9485c09563231f3e9a1d44799
tcp: fix sock skb accounting in tcp_read_skb()

Before commit dd3111be4a6a ("net: Introduce a new proto_ops
->read_skb()"), skb was not dequeued from receive queue hence
when we close TCP socket skb can be just flushed synchronously.

After this commit, we have to uncharge skb immediately after being
dequeued, otherwise it is still charged in the original sock. And we
still need to retain skb->sk, as eBPF programs may extract sock
information from skb->sk. Therefore, we have to call
skb_set_owner_sk_safe() here.

Fixes: dd3111be4a6a ("net: Introduce a new proto_ops ->read_skb()")
Reported-and-tested-by: syzbot+a0e6f8738b58f7654417@syzkaller.appspotmail.com
Tested-by: Stanislav Fomichev <sdf@google.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: Jakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv4/tcp.c