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>] [day] [month] [year] [list]
Message-ID: <9ad567f1-b2b1-5d2c-5b51-eca7d61c49f4@oracle.com>
Date:   Mon, 28 Feb 2022 08:23:09 -0800
From:   Dongli Zhang <dongli.zhang@...cle.com>
To:     netdev <netdev@...r.kernel.org>
Subject: Question on dev_kfree_skb(): why it is consume_skb()?

Hello,

While the dev_kfree_skb() is used to track the dropped sk_buff, is there any
reason that it is consume_skb() ...

1328 #define dev_kfree_skb(a)        consume_skb(a)

890 void consume_skb(struct sk_buff *skb)
891 {
892         if (!skb_unref(skb))
893                 return;
894
895         trace_consume_skb(skb);
896         __kfree_skb(skb);
897 }

... but not kfree_skb()?

752 void kfree_skb(struct sk_buff *skb)
753 {
754         if (!skb_unref(skb))
755                 return;
756
757         trace_kfree_skb(skb, __builtin_return_address(0));
758         __kfree_skb(skb);
759 }
760 EXPORT_SYMBOL(kfree_skb);

I assume we may need kfree_skb() to track the dropped sk_buff.


In addition, there are places like __dev_kfree_skb_any() that may not capture
'SKB_REASON_DROPPED', if dev_kfree_skb() is equivalent to consume_skb().

3053 void __dev_kfree_skb_any(struct sk_buff *skb, enum skb_free_reason reason)
3054 {
3055         if (in_hardirq() || irqs_disabled())
3056                 __dev_kfree_skb_irq(skb, reason);
3057         else
3058                 dev_kfree_skb(skb);
3059 }
3060 EXPORT_SYMBOL(__dev_kfree_skb_any);


We may change like below?

diff --git a/net/core/dev.c b/net/core/dev.c
index 2d6771075720..0800e1c4b514 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3054,8 +3054,10 @@ void __dev_kfree_skb_any(struct sk_buff *skb, enum
skb_free_reason reason)
 {
 	if (in_hardirq() || irqs_disabled())
 		__dev_kfree_skb_irq(skb, reason);
-	else
+	else if (reason == SKB_REASON_CONSUMED)
 		dev_kfree_skb(skb);
+	else if (reason == SKB_REASON_DROPPED)
+		kfree_skb(skb);
 }
 EXPORT_SYMBOL(__dev_kfree_skb_any);


Thank you very much!

Dongli Zhang

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ