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] [day] [month] [year] [list]
Date:   Thu, 23 Feb 2023 17:18:31 +0800
From:   Yunsheng Lin <linyunsheng@...wei.com>
To:     Eric Dumazet <edumazet@...gle.com>
CC:     "David S . Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>, <netdev@...r.kernel.org>,
        <eric.dumazet@...il.com>
Subject: Re: [PATCH net] net: fix __dev_kfree_skb_any() vs drop monitor

On 2023/2/23 16:27, Eric Dumazet wrote:
> On Thu, Feb 23, 2023 at 1:48 AM Yunsheng Lin <linyunsheng@...wei.com> wrote:
>>
>> On 2023/2/23 8:07, Eric Dumazet wrote:
>>> dev_kfree_skb() is aliased to consume_skb().
>>>
>>> When a driver is dropping a packet by calling dev_kfree_skb_any()
>>> we should propagate the drop reason instead of pretending
>>> the packet was consumed.
>>>
>>> Note: Now we have enum skb_drop_reason we could remove
>>> enum skb_free_reason (for linux-6.4)
>>>
>>> Fixes: e6247027e517 ("net: introduce dev_consume_skb_any()")
>>> Signed-off-by: Eric Dumazet <edumazet@...gle.com>
>>> ---
>>>  net/core/dev.c | 4 +++-
>>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/net/core/dev.c b/net/core/dev.c
>>> index 18dc8d75ead9795163ace74e8e86fe35cb9b7552..2bf60afde1e2e4be4806070754ae7486705c5237 100644
>>> --- a/net/core/dev.c
>>> +++ b/net/core/dev.c
>>> @@ -3134,8 +3134,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 if (reason == SKB_REASON_DROPPED)
>>
>> Perhaps add the unlikely() for the SKB_REASON_DROPPED case
>> as it is uesed in data path.
> 
> Sure I can do this, I will send a v2.
> 
> Note that I plan to switch the whole thing when net-next opens with
> something like this
> (showing not complete patch of course)
> 
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 2bf60afde1e2e4be4806070754ae7486705c5237..67baed2c8c5ef6577a2256c02c300947b8a919b7
> 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -3130,16 +3130,14 @@ void __dev_kfree_skb_irq(struct sk_buff *skb,
> enum skb_free_reason reason)
>  }
>  EXPORT_SYMBOL(__dev_kfree_skb_irq);
> 
> -void __dev_kfree_skb_any(struct sk_buff *skb, enum skb_free_reason reason)
> +void dev_kfree_skb_any_reason(struct sk_buff *skb, enum skb_drop_reason reason)
>  {
>         if (in_hardirq() || irqs_disabled())
>                 __dev_kfree_skb_irq(skb, reason);
> -       else if (reason == SKB_REASON_DROPPED)
> -               kfree_skb(skb);
>         else
> -               consume_skb(skb);
> +               kfree_skb_reason(skb, reason);

Yes, it should remove one additional checking branch.

>  }
> -EXPORT_SYMBOL(__dev_kfree_skb_any);
> +EXPORT_SYMBOL(dev_kfree_skb_any_reason);
> 
> 
>  /**
> .
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ