lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-ID: <20201031153824.7ae83b90@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net> Date: Sat, 31 Oct 2020 15:38:24 -0700 From: Jakub Kicinski <kuba@...nel.org> To: Yunsheng Lin <linyunsheng@...wei.com> Cc: <davem@...emloft.net>, <linmiaohe@...wei.com>, <martin.varghese@...ia.com>, <pabeni@...hat.com>, <pshelar@....org>, <fw@...len.de>, <gnault@...hat.com>, <steffen.klassert@...unet.com>, <kyk.segfault@...il.com>, <viro@...iv.linux.org.uk>, <vladimir.oltean@....com>, <edumazet@...gle.com>, <saeed@...nel.org>, <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>, <linuxarm@...wei.com> Subject: Re: [PATCH net-next] net: add in_softirq() debug checking in napi_consume_skb() On Thu, 29 Oct 2020 19:34:48 +0800 Yunsheng Lin wrote: > The current semantic for napi_consume_skb() is that caller need > to provide non-zero budget when calling from NAPI context, and > breaking this semantic will cause hard to debug problem, because > _kfree_skb_defer() need to run in atomic context in order to push > the skb to the particular cpu' napi_alloc_cache atomically. > > So add a in_softirq() debug checking in napi_consume_skb() to catch > this kind of error. > > Suggested-by: Eric Dumazet <edumazet@...gle.com> > Signed-off-by: Yunsheng Lin <linyunsheng@...wei.com> > diff --git a/net/core/skbuff.c b/net/core/skbuff.c > index 1ba8f01..1834007 100644 > --- a/net/core/skbuff.c > +++ b/net/core/skbuff.c > @@ -897,6 +897,10 @@ void napi_consume_skb(struct sk_buff *skb, int budget) > return; > } > > + DEBUG_NET_WARN(!in_softirq(), > + "%s is called with non-zero budget outside softirq context.\n", > + __func__); Can't we use lockdep instead of defining our own knobs? Like this maybe? diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index f5594879175a..5253a167d00c 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -594,6 +594,14 @@ do { \ this_cpu_read(hardirqs_enabled))); \ } while (0) +#define lockdep_assert_in_softirq() \ +do { \ + WARN_ON_ONCE(__lockdep_enabled && \ + (softirq_count() == 0 || \ + this_cpu_read(hardirq_context))); \ +} while (0) > if (!skb_unref(skb)) > return; >
Powered by blists - more mailing lists