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:   Fri, 1 Jul 2022 19:13:22 +0800
From:   Feng Tang <feng.tang@...el.com>
To:     Hyeonggon Yoo <42.hyeyoo@...il.com>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Christoph Lameter <cl@...ux.com>,
        Pekka Enberg <penberg@...nel.org>,
        David Rientjes <rientjes@...gle.com>,
        Joonsoo Kim <iamjoonsoo.kim@....com>,
        Vlastimil Babka <vbabka@...e.cz>,
        Roman Gushchin <roman.gushchin@...ux.dev>, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org, dave.hansen@...el.com
Subject: Re: [RFC PATCH] mm/slub: enable debugging memory wasting of kmalloc

On Fri, Jul 01, 2022 at 06:29:20PM +0900, Hyeonggon Yoo wrote:
> On Fri, Jul 01, 2022 at 10:23:30AM +0800, Feng Tang wrote:
[snip]

> > 
> > > And then it has overhead of 'waste' field for every non-kmalloc objects
> > > because track is saved per object. Also the field is not used at free.
> > > (Maybe that would be okay as it's only for debugging, just noting.)
> >  
> > Yes, the field itself is a 'waste' for non-kmalloc objects :) I do
> > have another patch to add an option for this
> > 
> > 	+config SLUB_DEBUG_KMALLOC_WASTE
> > 	+	bool "Enable kmalloc memory waste debug"
> > 	+	depends on SLUB_DEBUG && DEBUG_FS
> > 	...	
> > 
> > And didn't post it due to the same debugging thought as you. And I can
> > add it back if it's really necessary.
> 
> Let's see how others think :)
> I'm okay with current patch.

Okay.

> > > >  mm/slub.c | 45 ++++++++++++++++++++++++++++++---------------
> > > >  1 file changed, 30 insertions(+), 15 deletions(-)
[snip]

> > > > 
> > > >  	l->min_pid = track->pid;
> > > >  	l->max_pid = track->pid;
> > > >  	l->handle = handle;
> > > > +	l->waste = track->waste;
> > > 
> > > I think this may be fooled when there are different wastes values
> > > from same caller (i.e. when a kmalloc_track_caller() is used.)
> > 
> > Yes, with the patch, we found quite some cases that the same caller
> > requests different sizes.
> > 
> > > because the array is sorted by caller address, but not sorted by waste.
> > 
> > In the patch we have in add_location():
> > 
> > +		if ((track->addr == caddr) && (handle == chandle) &&
> > +			(track->waste == l->waste)) {
> > 
> > Do you mean the following is missed? 
> > 
> > --- a/mm/slub.c
> > +++ b/mm/slub.c
> > @@ -5176,6 +5176,8 @@ static int add_location(struct loc_track *t, struct kmem_cache *s,
> >  			end = pos;
> >  		else if (track->addr == caddr && handle < chandle)
> >  			end = pos;
> > +		else if (track->addr == caddr && handle == chandle && track->waste < l->waste)
> > +			end = pos;
> >  		else
> >  			start = pos;
> >
> 
> Yes. Exactly. :)
 
Great, will add it in the next version. Thanks for cathing the errors!

- Feng

> Thanks,
> Hyeonggon

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ