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 PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Sun, 21 Apr 2019 16:41:26 -0400 From: Stephen Suryaputra <ssuryaextr@...il.com> To: David Ahern <dsahern@...il.com> Cc: Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>, Julian Anastasov <ja@....bg>, Cong Wang <xiyou.wangcong@...il.com>, syzbot <syzbot+30209ea299c09d8785c9@...kaller.appspotmail.com>, ddstreet@...e.org, dvyukov@...gle.com, linux-kernel@...r.kernel.org, netdev@...r.kernel.org, syzkaller-bugs@...glegroups.com Subject: Re: unregister_netdevice: waiting for DEV to become free (2) Hi David, I looked at patchwork. This patch hasn't been accepted. Is there a plan to resubmit? It is very useful. I had to debug refcnt issues multiple times for my employer. Thanks, Stephen. On Mon, Apr 15, 2019 at 09:35:01AM -0600, David Ahern wrote: > On 4/15/19 7:36 AM, Tetsuo Handa wrote: > > I traced using debug printk() patch shown below. > > > > I find tracepoints (see attached patch) and perf are easier to use to > debug device refcnt problems. > > For example, limit the stack you have to deal with via sysctl -w > kernel.perf_event_max_stack=16, and add a filter (e.g., --filter 'name > == "lo"') to limit collection to a specific device. > From 068b1b8362ec5fd1b9dffdbd6e84474ada2eb829 Mon Sep 17 00:00:00 2001 > From: David Ahern <dsa@...ulusnetworks.com> > Date: Thu, 11 Feb 2016 02:40:12 -0800 > Subject: [PATCH] Add tracepoints to dev_hold and dev_put > > Signed-off-by: David Ahern <dsa@...ulusnetworks.com> > --- > include/linux/netdevice.h | 6 ++++++ > include/trace/events/net.h | 38 ++++++++++++++++++++++++++++++++++++++ > net/core/dev.c | 21 +++++++++++++++++++++ > 3 files changed, 65 insertions(+) > > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h > index 219f53c30cb3..7ef6fc672dfb 100644 > --- a/include/linux/netdevice.h > +++ b/include/linux/netdevice.h > @@ -3193,6 +3193,7 @@ extern int netdev_budget; > /* Called by rtnetlink.c:rtnl_unlock() */ > void netdev_run_todo(void); > > +#if 0 > /** > * dev_put - release reference to device > * @dev: network device > @@ -3214,6 +3215,11 @@ static inline void dev_hold(struct net_device *dev) > { > this_cpu_inc(*dev->pcpu_refcnt); > } > +#else > +void dev_put(struct net_device *dev); > +void dev_hold(struct net_device *dev); > + > +#endif > > /* Carrier loss detection, dial on demand. The functions netif_carrier_on > * and _off may be called from IRQ context, but it is caller > diff --git a/include/trace/events/net.h b/include/trace/events/net.h > index 49cc7c3de252..9ed73dfe9d09 100644 > --- a/include/trace/events/net.h > +++ b/include/trace/events/net.h > @@ -236,6 +236,44 @@ DEFINE_EVENT(net_dev_rx_verbose_template, netif_rx_ni_entry, > TP_ARGS(skb) > ); > > +TRACE_EVENT(dev_put, > + > + TP_PROTO(struct net_device *dev), > + > + TP_ARGS(dev), > + > + TP_STRUCT__entry( > + __string( name, dev->name ) > + __field( int, refcnt ) > + ), > + > + TP_fast_assign( > + __assign_str(name, dev->name); > + __entry->refcnt = netdev_refcnt_read(dev); > + ), > + > + TP_printk("dev=%s refcnt %d", __get_str(name), __entry->refcnt) > +); > + > +TRACE_EVENT(dev_hold, > + > + TP_PROTO(struct net_device *dev), > + > + TP_ARGS(dev), > + > + TP_STRUCT__entry( > + __string( name, dev->name ) > + __field( int, refcnt ) > + ), > + > + TP_fast_assign( > + __assign_str(name, dev->name); > + __entry->refcnt = netdev_refcnt_read(dev); > + ), > + > + TP_printk("dev=%s refcnt %d", __get_str(name), __entry->refcnt) > +); > + > #endif /* _TRACE_NET_H */ > > /* This part must be outside protection */ > diff --git a/net/core/dev.c b/net/core/dev.c > index f1284835b8c9..99ac067afd18 100644 > --- a/net/core/dev.c > +++ b/net/core/dev.c > @@ -8117,3 +8117,24 @@ static int __init net_dev_init(void) > } > > subsys_initcall(net_dev_init); > + > + > +void dev_put(struct net_device *dev) > +{ > + this_cpu_dec(*dev->pcpu_refcnt); > + trace_dev_put(dev); > +} > +EXPORT_SYMBOL(dev_put); > + > +/** > + * dev_hold - get reference to device > + * @dev: network device > + * > + * Hold reference to device to keep it from being freed. > + */ > +void dev_hold(struct net_device *dev) > +{ > + this_cpu_inc(*dev->pcpu_refcnt); > + trace_dev_hold(dev); > +} > +EXPORT_SYMBOL(dev_hold); > -- > 2.1.4 >
Powered by blists - more mailing lists