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: <CALCETrVaFPjQrVAiOad6GhFvK=AQphF0Kx5zDsCcAt4bPfQbnw@mail.gmail.com>
Date:   Mon, 22 May 2017 11:19:08 -0700
From:   Andy Lutomirski <luto@...capital.net>
To:     Catalin Marinas <catalin.marinas@....com>
Cc:     "linux-mm@...ck.org" <linux-mm@...ck.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Michal Hocko <mhocko@...nel.org>,
        "Luis R. Rodriguez" <mcgrof@...nel.org>
Subject: Re: [PATCH] mm: kmemleak: Treat vm_struct as alternative reference to
 vmalloc'ed objects

On Mon, May 22, 2017 at 10:35 AM, Catalin Marinas
<catalin.marinas@....com> wrote:
> Kmemleak requires that vmalloc'ed objects have a minimum reference count
> of 2: one in the corresponding vm_struct object and the other owned by
> the vmalloc() caller. There are cases, however, where the original
> vmalloc() returned pointer is lost and, instead, a pointer to vm_struct
> is stored (see free_thread_stack()). Kmemleak currently reports such
> objects as leaks.
>
> This patch adds support for treating any surplus references to an object
> as additional references to a specified object. It introduces the
> kmemleak_vmalloc() API function which takes a vm_struct pointer and sets
> its surplus reference passing to the actual vmalloc() returned pointer.
> The __vmalloc_node_range() calling site has been modified accordingly.
>
> An unrelated minor change is included in this patch to change the type
> of kmemleak_object.flags to unsigned int (previously unsigned long).
>
> Reported-by: "Luis R. Rodriguez" <mcgrof@...nel.org>
> Cc: Michal Hocko <mhocko@...nel.org>
> Cc: Andy Lutomirski <luto@...capital.net>
> Signed-off-by: Catalin Marinas <catalin.marinas@....com>
> ---
>
> Hi,
>
> As per [1], I added support to use pointers to vm_struct as an
> alternative way to avoid false positives when the original vmalloc()
> pointer has been lost. This is slightly harder to reason about but it
> seems to work for this use-case. I'm not aware of other cases (than
> free_thread_stack()) where the original vmalloc() pointer is removed in
> favour of a vm_struct one.
>
> An alternative implementation (simpler to understand), if preferred, is
> to annotate alloc_thread_stack_node() and free_thread_stack() with
> kmemleak_unignore()/kmemleak_ignore() calls and proper comments.
>

I personally prefer the option in this patch.  It keeps the special
case in kmemleak and the allocation code rather than putting it in the
consumer code.

Also, I want to add an API at some point that vmallocs some memory and
returns the vm_struct directly.  That won't work with explicit
annotations in the caller because kmemleak might think it's leaked
before the caller can execute the annotations.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ