diff mbox series

[net,v2] net: Use WARN_ON_ONCE() in {tcp,udp}_read_skb()

Message ID 20220913184016.16095-1-yepeilin.cs@gmail.com (mailing list archive)
State Accepted
Delegated to: Netdev Maintainers
Headers show
Series [net,v2] net: Use WARN_ON_ONCE() in {tcp,udp}_read_skb() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present fail Series targets non-next tree, but doesn't contain any Fixes tags
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 5 this patch: 5
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Peilin Ye Sept. 13, 2022, 6:40 p.m. UTC
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(-)

Comments

Peilin Ye Sept. 13, 2022, 7:30 p.m. UTC | #1
On Tue, Sep 13, 2022 at 11:40:16AM -0700, Peilin Ye wrote:
> Suggested-by: Jakub Sitnicki <jakub@cloudflare.com>
> Signed-off-by: Peilin Ye <peilin.ye@bytedance.com>

Sorry, I forgot to add Fixes: tag.

Those WARN_ON() come from different commits.  I will split this into two
in v3 to make it easier.

Thanks,
Peilin Ye
Peilin Ye Sept. 14, 2022, 7:51 a.m. UTC | #2
On Tue, Sep 13, 2022 at 12:30:50PM -0700, Peilin Ye wrote:
> On Tue, Sep 13, 2022 at 11:40:16AM -0700, Peilin Ye wrote:
> > Suggested-by: Jakub Sitnicki <jakub@cloudflare.com>
> > Signed-off-by: Peilin Ye <peilin.ye@bytedance.com>
> 
> Sorry, I forgot to add Fixes: tag.
> 
> Those WARN_ON() come from different commits.  I will split this into two
> in v3 to make it easier.

Cong suggested not sending v3 since this is not fixing a bug, and thus
no need to add Fixes: tags.
diff mbox series

Patch

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)