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: <Y9AEVhNyllqmn0ZH@casper.infradead.org>
Date:   Tue, 24 Jan 2023 16:16:22 +0000
From:   Matthew Wilcox <willy@...radead.org>
To:     George Prekas <george@...abrica.net>
Cc:     linux-kernel@...r.kernel.org, linux-mm@...ck.org,
        Catalin Marinas <catalin.marinas@....com>,
        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>,
        Hyeonggon Yoo <42.hyeyoo@...il.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        "Eric W. Biederman" <ebiederm@...ssion.com>,
        Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
        Andy Lutomirski <luto@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        "Liam R. Howlett" <Liam.Howlett@...cle.com>,
        Fenghua Yu <fenghua.yu@...el.com>,
        Andrei Vagin <avagin@...il.com>
Subject: Re: [PATCH 9/9] mm: kmemleak: fix undetected leaks for page aligned
 objects

On Mon, Jan 23, 2023 at 11:04:19AM -0600, George Prekas wrote:
> If kmalloc returns a page aligned object, then the object has 2
> references: the pointer returned by kmalloc and page->s_mem of the first
> page of the object. Account for this extra reference, so that kmemleak
> can correctly detect leaks for page aligned objects.

Is this true for multi-page slabs?  Imagine if you allocate objects of
size 4kB.  Slab/Slub will allocate slabs of size 32kB and try to
allocate 8 objects from each slab.  Only the first one will have an
s_mem pointing into it.  No?

> -		kmemleak_alloc_recursive(p[i], s->object_size, 1,
> +		min_count = 1;
> +		/* If p[i] is page aligned, then a page->s_mem refers to it. */

Also this comment should read 'slab->s_mem'.  Individual pages within
the slab do not have s_mem pointers, only the slab.

> +		if (((uintptr_t)p[i] & ~PAGE_MASK) == 0)
> +			min_count++;
> +		kmemleak_alloc_recursive(p[i], s->object_size, min_count,
>  					 s->flags, flags);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ