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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YfZWcxX/3eDM+x/5@shredder>
Date:   Sun, 30 Jan 2022 11:12:19 +0200
From:   Ido Schimmel <idosch@...sch.org>
To:     menglong8.dong@...il.com
Cc:     kuba@...nel.org, rostedt@...dmis.org, nhorman@...driver.com,
        davem@...emloft.net, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org, dsahern@...nel.org,
        Menglong Dong <imagedong@...cent.com>
Subject: Re: [PATCH v4 net-next] net: drop_monitor: support drop reason

On Fri, Jan 28, 2022 at 12:57:27PM +0800, menglong8.dong@...il.com wrote:
>  #define NET_DM_SKB_CB(__skb) ((struct net_dm_skb_cb *)&((__skb)->cb[0]))
> @@ -498,6 +509,7 @@ static void net_dm_packet_trace_kfree_skb_hit(void *ignore,
>  {
>  	ktime_t tstamp = ktime_get_real();
>  	struct per_cpu_dm_data *data;
> +	struct net_dm_skb_cb *cb;
>  	struct sk_buff *nskb;
>  	unsigned long flags;
>  
> @@ -508,7 +520,9 @@ static void net_dm_packet_trace_kfree_skb_hit(void *ignore,
>  	if (!nskb)
>  		return;
>  
> -	NET_DM_SKB_CB(nskb)->pc = location;
> +	cb = NET_DM_SKB_CB(nskb);
> +	cb->reason = reason;
> +	cb->pc = location;
>  	/* Override the timestamp because we care about the time when the
>  	 * packet was dropped.
>  	 */
> @@ -606,7 +620,7 @@ static int net_dm_packet_report_in_port_put(struct sk_buff *msg, int ifindex,
>  static int net_dm_packet_report_fill(struct sk_buff *msg, struct sk_buff *skb,
>  				     size_t payload_len)
>  {
> -	u64 pc = (u64)(uintptr_t) NET_DM_SKB_CB(skb)->pc;
> +	struct net_dm_skb_cb *cb = NET_DM_SKB_CB(skb);
>  	char buf[NET_DM_MAX_SYMBOL_LEN];
>  	struct nlattr *attr;
>  	void *hdr;
> @@ -620,10 +634,15 @@ static int net_dm_packet_report_fill(struct sk_buff *msg, struct sk_buff *skb,
>  	if (nla_put_u16(msg, NET_DM_ATTR_ORIGIN, NET_DM_ORIGIN_SW))
>  		goto nla_put_failure;
>  
> -	if (nla_put_u64_64bit(msg, NET_DM_ATTR_PC, pc, NET_DM_ATTR_PAD))
> +	if (nla_put_u64_64bit(msg, NET_DM_ATTR_PC, (u64)(uintptr_t)cb->pc,
> +			      NET_DM_ATTR_PAD))
> +		goto nla_put_failure;
> +
> +	if (nla_put_string(msg, NET_DM_ATTR_REASON,
> +			   drop_reasons[cb->reason]))
>  		goto nla_put_failure;

Need to take the size into account when performing the allocation in
net_dm_packet_report_size()

>  
> -	snprintf(buf, sizeof(buf), "%pS", NET_DM_SKB_CB(skb)->pc);
> +	snprintf(buf, sizeof(buf), "%pS", cb->pc);
>  	if (nla_put_string(msg, NET_DM_ATTR_SYMBOL, buf))
>  		goto nla_put_failure;
>  
> -- 
> 2.27.0
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ