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:   Thu, 30 Sep 2021 15:27:04 -0700
From:   Kees Cook <>
To:     Andrew Morton <>
Cc:     Kees Cook <>, Dennis Zhou <>,
        Tejun Heo <>, Christoph Lameter <>,
        Andy Whitcroft <>,
        David Rientjes <>,
        Dwaipayan Ray <>,
        Joe Perches <>,
        Joonsoo Kim <>,
        Lukas Bulwahn <>,
        Miguel Ojeda <>,
        Nathan Chancellor <>,
        Nick Desaulniers <>,
        Pekka Enberg <>,
        Vlastimil Babka <>,
        Daniel Micay <>,
        Masahiro Yamada <>,
        Michal Marek <>,,,,,
Subject: [PATCH v3 8/8] percpu: Add __alloc_size attributes for better bounds checking

As already done in GrapheneOS, add the __alloc_size attribute for
appropriate percpu allocator interfaces, to provide additional hinting for
better bounds checking, assisting CONFIG_FORTIFY_SOURCE and other compiler

Note that due to the implementation of the percpu API, this is unlikely
to ever actually provide compile-time checking beyond very simple non-SMP
builds. But, since they are technically allocators, mark them as such.

Cc: Dennis Zhou <>
Cc: Tejun Heo <>
Cc: Christoph Lameter <>
Cc: Andy Whitcroft <>
Cc: David Rientjes <>
Cc: Dwaipayan Ray <>
Cc: Joe Perches <>
Cc: Joonsoo Kim <>
Cc: Lukas Bulwahn <>
Cc: Miguel Ojeda <>
Cc: Nathan Chancellor <>
Cc: Nick Desaulniers <>
Cc: Pekka Enberg <>
Cc: Vlastimil Babka <>
Co-developed-by: Daniel Micay <>
Signed-off-by: Daniel Micay <>
Signed-off-by: Kees Cook <>
 include/linux/percpu.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index 5e76af742c80..98a9371133f8 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -123,7 +123,7 @@ extern int __init pcpu_page_first_chunk(size_t reserved_size,
 				pcpu_fc_populate_pte_fn_t populate_pte_fn);
-extern void __percpu *__alloc_reserved_percpu(size_t size, size_t align);
+extern void __percpu *__alloc_reserved_percpu(size_t size, size_t align) __alloc_size(1);
 extern bool __is_kernel_percpu_address(unsigned long addr, unsigned long *can_addr);
 extern bool is_kernel_percpu_address(unsigned long addr);
@@ -131,8 +131,8 @@ extern bool is_kernel_percpu_address(unsigned long addr);
 extern void __init setup_per_cpu_areas(void);
-extern void __percpu *__alloc_percpu_gfp(size_t size, size_t align, gfp_t gfp);
-extern void __percpu *__alloc_percpu(size_t size, size_t align);
+extern void __percpu *__alloc_percpu_gfp(size_t size, size_t align, gfp_t gfp) __alloc_size(1);
+extern void __percpu *__alloc_percpu(size_t size, size_t align) __alloc_size(1);
 extern void free_percpu(void __percpu *__pdata);
 extern phys_addr_t per_cpu_ptr_to_phys(void *addr);

Powered by blists - more mailing lists