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]
Message-ID: <YhoDzPfUtorL8U8L@ip-172-31-19-208.ap-northeast-1.compute.internal>
Date:   Sat, 26 Feb 2022 10:41:16 +0000
From:   Hyeonggon Yoo <42.hyeyoo@...il.com>
To:     Vlastimil Babka <vbabka@...e.cz>
Cc:     David Rientjes <rientjes@...gle.com>,
        Christoph Lameter <cl@...ux.com>,
        Joonsoo Kim <iamjoonsoo.kim@....com>,
        Pekka Enberg <penberg@...nel.org>,
        Roman Gushchin <roman.gushchin@...ux.dev>,
        Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
        patches@...ts.linux.dev, linux-kernel@...r.kernel.org,
        Oliver Glitta <glittao@...il.com>,
        Faiyaz Mohammed <faiyazm@...eaurora.org>
Subject: Re: [PATCH 1/5] mm/slub: move struct track init out of set_track()

On Fri, Feb 25, 2022 at 07:03:14PM +0100, Vlastimil Babka wrote:
> set_track() either zeroes out the struct track or fills it, depending on
> the addr parameter. This is unnecessary as there's only one place that
> calls it for the initialization - init_tracking(). We can simply do the
> zeroing there, with a single memset() that covers both TRACK_ALLOC and
> TRACK_FREE as they are adjacent.
> 
> Signed-off-by: Vlastimil Babka <vbabka@...e.cz>
> ---
>  mm/slub.c | 32 +++++++++++++++-----------------
>  1 file changed, 15 insertions(+), 17 deletions(-)
> 
> diff --git a/mm/slub.c b/mm/slub.c
> index 261474092e43..1fc451f4fe62 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -729,34 +729,32 @@ static void set_track(struct kmem_cache *s, void *object,
>  {
>  	struct track *p = get_track(s, object, alloc);
>  
> -	if (addr) {
>  #ifdef CONFIG_STACKTRACE
> -		unsigned int nr_entries;
> +	unsigned int nr_entries;
>  
> -		metadata_access_enable();
> -		nr_entries = stack_trace_save(kasan_reset_tag(p->addrs),
> -					      TRACK_ADDRS_COUNT, 3);
> -		metadata_access_disable();
> +	metadata_access_enable();
> +	nr_entries = stack_trace_save(kasan_reset_tag(p->addrs),
> +				      TRACK_ADDRS_COUNT, 3);
> +	metadata_access_disable();
>  
> -		if (nr_entries < TRACK_ADDRS_COUNT)
> -			p->addrs[nr_entries] = 0;
> +	if (nr_entries < TRACK_ADDRS_COUNT)
> +		p->addrs[nr_entries] = 0;
>  #endif
> -		p->addr = addr;
> -		p->cpu = smp_processor_id();
> -		p->pid = current->pid;
> -		p->when = jiffies;
> -	} else {
> -		memset(p, 0, sizeof(struct track));
> -	}
> +	p->addr = addr;
> +	p->cpu = smp_processor_id();
> +	p->pid = current->pid;
> +	p->when = jiffies;
>  }
>  
>  static void init_tracking(struct kmem_cache *s, void *object)
>  {
> +	struct track *p;
> +
>  	if (!(s->flags & SLAB_STORE_USER))
>  		return;
>  
> -	set_track(s, object, TRACK_FREE, 0UL);
> -	set_track(s, object, TRACK_ALLOC, 0UL);
> +	p = get_track(s, object, TRACK_ALLOC);
> +	memset(p, 0, 2*sizeof(struct track));
>  }
>

Looks good.
Reviewed-by: Hyeonggon Yoo <42.hyeyoo@...il.com>

And works nicely.
Tested-by: Hyeonggon Yoo <42.hyeyoo@...il.com>

>  static void print_track(const char *s, struct track *t, unsigned long pr_time)
> -- 
> 2.35.1
> 
> 

-- 
Thank you, You are awesome!
Hyeonggon :-)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ