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:   Fri, 17 Jun 2022 18:05:07 +0800
From:   menglong8.dong@...il.com
To:     edumazet@...gle.com
Cc:     rostedt@...dmis.org, mingo@...hat.com, davem@...emloft.net,
        yoshfuji@...ux-ipv6.org, dsahern@...nel.org, kuba@...nel.org,
        pabeni@...hat.com, imagedong@...cent.com, kafai@...com,
        talalahmad@...gle.com, keescook@...omium.org,
        dongli.zhang@...cle.com, linux-kernel@...r.kernel.org,
        netdev@...r.kernel.org
Subject: [PATCH net-next v4 1/8] net: skb: use SKB_NOT_DROPPED in kfree_skb_reason() as consume_skb()

From: Menglong Dong <imagedong@...cent.com>

Inorder to simply the code, allow SKB_NOT_DROPPED to be passed to
kfree_skb_reason(), suggested by Eric. Therefore, consume_skb(skb) can
be replaced with kfree_skb_reason(skb, SKB_NOT_DROPPED).

Not sure if it is suitable to make consume_skb() a simple call to
kfree_skb_reason(skb, SKB_NOT_DROPPED), as this can increase the
function call chain.

Signed-off-by: Menglong Dong <imagedong@...cent.com>
---
 net/core/skbuff.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index b661040c100e..92f01b59ae40 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -769,15 +769,22 @@ EXPORT_SYMBOL(__kfree_skb);
  *	Drop a reference to the buffer and free it if the usage count has
  *	hit zero. Meanwhile, pass the drop reason to 'kfree_skb'
  *	tracepoint.
+ *
+ *	When the reason is SKB_NOT_DROPPED, it means that the packet is
+ *	freed normally, and the event 'consume_skb' will be triggered.
  */
 void kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason)
 {
 	if (!skb_unref(skb))
 		return;
 
-	DEBUG_NET_WARN_ON_ONCE(reason <= 0 || reason >= SKB_DROP_REASON_MAX);
+	DEBUG_NET_WARN_ON_ONCE(reason < 0 || reason >= SKB_DROP_REASON_MAX);
+
+	if (reason)
+		trace_kfree_skb(skb, __builtin_return_address(0), reason);
+	else
+		trace_consume_skb(skb);
 
-	trace_kfree_skb(skb, __builtin_return_address(0), reason);
 	__kfree_skb(skb);
 }
 EXPORT_SYMBOL(kfree_skb_reason);
-- 
2.36.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ