From: Jakub Sitnicki <jakub@cloudflare.com>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org,
Cong Wang <cong.wang@bytedance.com>,
syzbot+a0e6f8738b58f7654417@syzkaller.appspotmail.com,
Stanislav Fomichev <sdf@google.com>,
Eric Dumazet <edumazet@google.com>,
John Fastabend <john.fastabend@gmail.com>
Subject: Re: [Patch net v3 1/4] tcp: fix sock skb accounting in tcp_read_skb()
Date: Wed, 24 Aug 2022 10:17:33 +0200 [thread overview]
Message-ID: <87r1169hs2.fsf@cloudflare.com> (raw)
In-Reply-To: <20220817195445.151609-2-xiyou.wangcong@gmail.com>
On Wed, Aug 17, 2022 at 12:54 PM -07, Cong Wang wrote:
> From: Cong Wang <cong.wang@bytedance.com>
>
> Before commit 965b57b469a5 ("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: 965b57b469a5 ("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>
> ---
> net/ipv4/tcp.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index 970e9a2cca4a..05da5cac080b 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -1760,6 +1760,7 @@ int tcp_read_skb(struct sock *sk, skb_read_actor_t recv_actor)
> int used;
>
> __skb_unlink(skb, &sk->sk_receive_queue);
> + WARN_ON(!skb_set_owner_sk_safe(skb, sk));
> used = recv_actor(sk, skb);
> if (used <= 0) {
> if (!copied)
That is a frequent operation.
Don't we want WARN_ON_ONCE like in tcp_read_sock?
next prev parent reply other threads:[~2022-08-24 8:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-17 19:54 [Patch net v3 0/4] tcp: some bug fixes for tcp_read_skb() Cong Wang
2022-08-17 19:54 ` [Patch net v3 1/4] tcp: fix sock skb accounting in tcp_read_skb() Cong Wang
2022-08-24 8:17 ` Jakub Sitnicki [this message]
2022-09-08 23:15 ` [PATCH net] tcp: Use WARN_ON_ONCE() " Peilin Ye
2022-09-13 18:40 ` [PATCH net v2] net: Use WARN_ON_ONCE() in {tcp,udp}_read_skb() Peilin Ye
2022-09-13 19:30 ` Peilin Ye
2022-09-14 7:51 ` Peilin Ye
2022-09-16 14:40 ` [PATCH net] tcp: Use WARN_ON_ONCE() in tcp_read_skb() patchwork-bot+netdevbpf
2022-08-17 19:54 ` [Patch net v3 2/4] tcp: fix tcp_cleanup_rbuf() for tcp_read_skb() Cong Wang
2022-08-25 8:31 ` Jakub Sitnicki
2022-08-17 19:54 ` [Patch net v3 3/4] tcp: refactor tcp_read_skb() a bit Cong Wang
2022-08-17 19:54 ` [Patch net v3 4/4] tcp: handle pure FIN case correctly Cong Wang
2022-08-18 18:30 ` [Patch net v3 0/4] tcp: some bug fixes for tcp_read_skb() patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r1169hs2.fsf@cloudflare.com \
--to=jakub@cloudflare.com \
--cc=bpf@vger.kernel.org \
--cc=cong.wang@bytedance.com \
--cc=edumazet@google.com \
--cc=john.fastabend@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=sdf@google.com \
--cc=syzbot+a0e6f8738b58f7654417@syzkaller.appspotmail.com \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).