summaryrefslogtreecommitdiffstats
path: root/net/core/skbuff.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2022-06-08 09:04:37 -0700
committerJakub Kicinski <kuba@kernel.org>2022-06-09 21:53:56 -0700
commitee2640df2393141a2975af726802b349d51713be (patch)
treeee1ded184dbb821ea3159db968a2eea9803a01d1 /net/core/skbuff.c
parent7890e2f09d437f79e67cd37bf3e820fa0cddf2be (diff)
downloadlinux-stable-ee2640df2393141a2975af726802b349d51713be.tar.gz
linux-stable-ee2640df2393141a2975af726802b349d51713be.tar.bz2
linux-stable-ee2640df2393141a2975af726802b349d51713be.zip
net: add debug checks in napi_consume_skb and __napi_alloc_skb()
Commit 6454eca81eae ("net: Use lockdep_assert_in_softirq() in napi_consume_skb()") added a check in napi_consume_skb() which is a bit weak. napi_consume_skb() and __napi_alloc_skb() should only be used from BH context, not from hard irq or nmi context, otherwise we could have races. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/core/skbuff.c')
-rw-r--r--net/core/skbuff.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index cf83d9b8f41d..fec75f8bf1f4 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -560,6 +560,7 @@ struct sk_buff *__napi_alloc_skb(struct napi_struct *napi, unsigned int len,
struct sk_buff *skb;
void *data;
+ DEBUG_NET_WARN_ON_ONCE(!in_softirq());
len += NET_SKB_PAD + NET_IP_ALIGN;
/* If requested length is either too small or too big,
@@ -981,7 +982,7 @@ void napi_consume_skb(struct sk_buff *skb, int budget)
return;
}
- lockdep_assert_in_softirq();
+ DEBUG_NET_WARN_ON_ONCE(!in_softirq());
if (!skb_unref(skb))
return;