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
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 12 Nov 2019 08:27:31 -0700
From:   David Ahern <dsahern@...il.com>
To:     Tony Lu <tonylu@...ux.alibaba.com>, davem@...emloft.net
Cc:     xiyou.wangcong@...il.com, eric.dumazet@...il.com,
        shemminger@...l.org, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/2] net: add trace events for net_device refcnt

On 11/12/19 6:05 AM, Tony Lu wrote:
> diff --git a/include/trace/events/net.h b/include/trace/events/net.h
> index 3b28843652d2..3bf6dd738882 100644
> --- a/include/trace/events/net.h
> +++ b/include/trace/events/net.h
> @@ -326,6 +326,47 @@ DEFINE_EVENT(net_dev_rx_exit_template, netif_receive_skb_list_exit,
>  	TP_ARGS(ret)
>  );
>  
> +DECLARE_EVENT_CLASS(net_dev_refcnt_template,
> +
> +	TP_PROTO(struct net_device *dev, void *location),
> +
> +	TP_ARGS(dev, location),
> +
> +	TP_STRUCT__entry(
> +		__string(	name,		dev->name	)
> +		__field(	int,		refcnt		)
> +		__field(	void *,		location	)
> +	),
> +
> +	TP_fast_assign(
> +		int i, refcnt = 0;
> +
> +		for_each_possible_cpu(i)
> +			refcnt += *per_cpu_ptr(dev->pcpu_refcnt, i);

Rather than copying the definition of netdev_refcnt_read here, so just
use it.

> +
> +		__assign_str(name, dev->name);
> +		__entry->refcnt = refcnt;
> +		__entry->location = location;
> +	),
> +
> +	TP_printk("dev=%s refcnt=%d location=%p",
> +		__get_str(name), __entry->refcnt, __entry->location)
> +);
> +
> +DEFINE_EVENT(net_dev_refcnt_template, net_dev_put,
> +
> +	TP_PROTO(struct net_device *dev, void *location),
> +
> +	TP_ARGS(dev, location)
> +);
> +
> +DEFINE_EVENT(net_dev_refcnt_template, net_dev_hold,
> +
> +	TP_PROTO(struct net_device *dev, void *location),
> +
> +	TP_ARGS(dev, location)
> +);
> +
>  #endif /* _TRACE_NET_H */
>  

The location alone does nothing for resolving reference count leaks; you
really have to use stack traces to pair up the hold and put and to give
context for what are repetitive locations for the hold and put.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ