All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peilin Ye <yepeilin.cs@gmail.com>
To: Eric Dumazet <edumazet@google.com>,
	"David S. Miller" <davem@davemloft.net>,
	Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
	David Ahern <dsahern@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Peilin Ye <peilin.ye@bytedance.com>,
	Cong Wang <cong.wang@bytedance.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Peilin Ye <yepeilin.cs@gmail.com>
Subject: [PATCH net v2] net: Use WARN_ON_ONCE() in {tcp,udp}_read_skb()
Date: Tue, 13 Sep 2022 11:40:16 -0700	[thread overview]
Message-ID: <20220913184016.16095-1-yepeilin.cs@gmail.com> (raw)
In-Reply-To: <20220908231523.8977-1-yepeilin.cs@gmail.com>

From: Peilin Ye <peilin.ye@bytedance.com>

Prevent tcp_read_skb() and udp_read_skb() from flooding the syslog.

Suggested-by: Jakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: Peilin Ye <peilin.ye@bytedance.com>
---
change since v1:
  - do the same to udp_read_skb() (Cong Wang)

Cong's tcp_read_skb() fix [1] depends on this patch.

[1] https://lore.kernel.org/netdev/20220912173553.235838-1-xiyou.wangcong@gmail.com/

Thanks,
Peilin Ye

 net/ipv4/tcp.c | 2 +-
 net/ipv4/udp.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 8230be00ecca..9251c99d3cfd 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1766,7 +1766,7 @@ int tcp_read_skb(struct sock *sk, skb_read_actor_t recv_actor)
 		return 0;
 
 	__skb_unlink(skb, &sk->sk_receive_queue);
-	WARN_ON(!skb_set_owner_sk_safe(skb, sk));
+	WARN_ON_ONCE(!skb_set_owner_sk_safe(skb, sk));
 	copied = recv_actor(sk, skb);
 	if (copied >= 0) {
 		seq += copied;
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index cd72158e953a..560d9eadeaa5 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1821,7 +1821,7 @@ int udp_read_skb(struct sock *sk, skb_read_actor_t recv_actor)
 			continue;
 		}
 
-		WARN_ON(!skb_set_owner_sk_safe(skb, sk));
+		WARN_ON_ONCE(!skb_set_owner_sk_safe(skb, sk));
 		used = recv_actor(sk, skb);
 		if (used <= 0) {
 			if (!copied)
-- 
2.20.1


  reply	other threads:[~2022-09-13 18:55 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
2022-09-08 23:15     ` [PATCH net] tcp: Use WARN_ON_ONCE() " Peilin Ye
2022-09-13 18:40       ` Peilin Ye [this message]
2022-09-13 19:30         ` [PATCH net v2] net: Use WARN_ON_ONCE() in {tcp,udp}_read_skb() 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=20220913184016.16095-1-yepeilin.cs@gmail.com \
    --to=yepeilin.cs@gmail.com \
    --cc=cong.wang@bytedance.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=peilin.ye@bytedance.com \
    --cc=yoshfuji@linux-ipv6.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.