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:   Wed, 15 Jun 2022 17:35:25 +0200
From:   Alexander Lobakin <alexandr.lobakin@...el.com>
To:     Sieng Piaw Liew <liew.s.piaw@...il.com>
Cc:     Alexander Lobakin <alexandr.lobakin@...el.com>,
        davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
        netdev@...r.kernel.org
Subject: Re: [PATCH] net: don't check skb_count twice

From: Sieng Piaw Liew <liew.s.piaw@...il.com>
Date: Wed, 15 Jun 2022 11:24:26 +0800

> NAPI cache skb_count is being checked twice without condition. Change to
> checking the second time only if the first check is run.
> 
> Signed-off-by: Sieng Piaw Liew <liew.s.piaw@...il.com>
> ---
>  net/core/skbuff.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 5b3559cb1d82..c426adff6d96 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -172,13 +172,14 @@ static struct sk_buff *napi_skb_cache_get(void)
>  	struct napi_alloc_cache *nc = this_cpu_ptr(&napi_alloc_cache);
>  	struct sk_buff *skb;
>  
> -	if (unlikely(!nc->skb_count))
> +	if (unlikely(!nc->skb_count)) {
>  		nc->skb_count = kmem_cache_alloc_bulk(skbuff_head_cache,
>  						      GFP_ATOMIC,
>  						      NAPI_SKB_CACHE_BULK,
>  						      nc->skb_cache);
> -	if (unlikely(!nc->skb_count))
> -		return NULL;
> +		if (unlikely(!nc->skb_count))
> +			return NULL;
> +	}

I was sure the compilers are able to see that if the condition is
false first time, it will be the second as well. Just curious, have
you consulted objdump/objdiff to look whether anything changed?

Also, please use scripts/get_maintainers.pl or at least git blame
and add the original authors to Ccs next time, so that they won't
miss your changes and will be able to review them in time. E.g. I
noticed this patch only when it did hit the net-next tree already,
as I don't monitor LKML 24/7 (but I do that with my mailbox).

>  
>  	skb = nc->skb_cache[--nc->skb_count];
>  	kasan_unpoison_object_data(skbuff_head_cache, skb);
> -- 
> 2.17.1

Thanks,
Olek

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ