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  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:   Tue, 14 May 2019 13:22:03 +0100
From:   Aaron Tomlin <atomlin@...hat.com>
To:     Yury Norov <yury.norov@...il.com>
Cc:     Christoph Lameter <cl@...ux.com>,
        Pekka Enberg <penberg@...nel.org>,
        David Rientjes <rientjes@...gle.com>,
        Joonsoo Kim <iamjoonsoo.kim@....com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Yury Norov <ynorov@...vell.com>, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm/slub: avoid double string traverse in
 kmem_cache_flags()

On Tue 2019-04-30 22:31 -0700, Yury Norov wrote:
> If ',' is not found, kmem_cache_flags() calls strlen() to find the end
> of line. We can do it in a single pass using strchrnul().
> 
> Signed-off-by: Yury Norov <ynorov@...vell.com>
> ---
>  mm/slub.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/mm/slub.c b/mm/slub.c
> index 4922a0394757..85f90370a293 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -1317,9 +1317,7 @@ slab_flags_t kmem_cache_flags(unsigned int object_size,
>  		char *end, *glob;
>  		size_t cmplen;
>  
> -		end = strchr(iter, ',');
> -		if (!end)
> -			end = iter + strlen(iter);
> +		end = strchrnul(iter, ',');
>  
>  		glob = strnchr(iter, end - iter, '*');
>  		if (glob)

Fair enough.

Acked-by: Aaron Tomlin <atomlin@...hat.com>

-- 
Aaron Tomlin

Powered by blists - more mailing lists