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  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]
Date:   Wed, 25 Aug 2021 12:01:42 +0200 (CEST)
From:   Christoph Lameter <>
To:     Daniel Micay <>
cc:     Christoph Hellwig <>,
        Kees Cook <>,
        kernel list <>,
        Andrew Morton <>,
        Miguel Ojeda <>,
        Nathan Chancellor <>,
        Nick Desaulniers <>,
        Pekka Enberg <>,
        David Rientjes <>,
        Joonsoo Kim <>,
        Vlastimil Babka <>,
        Dennis Zhou <>, Tejun Heo <>,
        Masahiro Yamada <>,
        Michal Marek <>,, Linux-MM <>,
        linux-kbuild <>,
Subject: Re: [PATCH 0/5] Add __alloc_size() for better bounds checking

On Thu, 19 Aug 2021, Daniel Micay wrote:

> For example, it will know that kmalloc(n) returns either NULL or an
> allocation of size n. A simple sample program with calloc in
> userspace:
>     #include <stdlib.h>
>     #include <stdio.h>
>     int main(void) {
>         char *p = calloc(64, 1);
>         if (!p) {
>             return 1;
>         }
>         printf("%zu\n", __builtin_object_size(p, 1));
>         return 0;
>     }
> It will also detect an out-of-bounds access via the allocation with
> -fsanitize=object-size including with a runtime value as the index.
> It's not as useful as it should be yet because __builtin_object_size
> must return a compile-time constant. Clang has a new
> __builtin_dynamic_object_size that's allowed to return a value that's
> not a compile-time constant so it can work for kmalloc(n) where n is a
> runtime value. It might not be quite ready for use yet but it should
> be able to make it a lot more useful. GCC also seems open to adding it
> too.

The other complication with kmalloc etc is that the slab allocators may
decided to allocate more bytes than needed because it does not support
that particular allocation size. Some functions check the allocated true
size and make use of that. See ksize().

Powered by blists - more mailing lists