diff options
Diffstat (limited to 'sys-kernel/cairn-sources/files/5.9.6/hardened-patches/0061-add-kmalloc-krealloc-alloc_size-attributes.patch')
| -rw-r--r-- | sys-kernel/cairn-sources/files/5.9.6/hardened-patches/0061-add-kmalloc-krealloc-alloc_size-attributes.patch | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/sys-kernel/cairn-sources/files/5.9.6/hardened-patches/0061-add-kmalloc-krealloc-alloc_size-attributes.patch b/sys-kernel/cairn-sources/files/5.9.6/hardened-patches/0061-add-kmalloc-krealloc-alloc_size-attributes.patch new file mode 100644 index 000000000000..e6b7b48e1248 --- /dev/null +++ b/sys-kernel/cairn-sources/files/5.9.6/hardened-patches/0061-add-kmalloc-krealloc-alloc_size-attributes.patch @@ -0,0 +1,65 @@ +From 72c23039fe70b52b494550922f2022baf94cf381 Mon Sep 17 00:00:00 2001 +From: Daniel Micay <danielmicay@gmail.com> +Date: Wed, 3 May 2017 12:02:56 -0400 +Subject: [PATCH 061/108] add kmalloc/krealloc alloc_size attributes + +Note that this is overly strict when combined with ksize users accessing +beyond the requested data size. + +Signed-off-by: Daniel Micay <danielmicay@gmail.com> +--- + include/linux/slab.h | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/include/linux/slab.h b/include/linux/slab.h +index 24df2393ec03..a87e721d7abf 100644 +--- a/include/linux/slab.h ++++ b/include/linux/slab.h +@@ -181,7 +181,7 @@ int kmem_cache_shrink(struct kmem_cache *); + /* + * Common kmalloc functions provided by all allocators + */ +-void * __must_check krealloc(const void *, size_t, gfp_t); ++void * __must_check krealloc(const void *, size_t, gfp_t) __attribute((alloc_size(2))); + void kfree(const void *); + void kfree_sensitive(const void *); + size_t __ksize(const void *); +@@ -388,7 +388,7 @@ static __always_inline unsigned int kmalloc_index(size_t size) + } + #endif /* !CONFIG_SLOB */ + +-void *__kmalloc(size_t size, gfp_t flags) __assume_kmalloc_alignment __malloc; ++void *__kmalloc(size_t size, gfp_t flags) __assume_kmalloc_alignment __malloc __attribute__((alloc_size(1))); + void *kmem_cache_alloc(struct kmem_cache *, gfp_t flags) __assume_slab_alignment __malloc; + void kmem_cache_free(struct kmem_cache *, void *); + +@@ -412,7 +412,7 @@ static __always_inline void kfree_bulk(size_t size, void **p) + } + + #ifdef CONFIG_NUMA +-void *__kmalloc_node(size_t size, gfp_t flags, int node) __assume_kmalloc_alignment __malloc; ++void *__kmalloc_node(size_t size, gfp_t flags, int node) __assume_kmalloc_alignment __malloc __attribute__((alloc_size(1))); + void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node) __assume_slab_alignment __malloc; + #else + static __always_inline void *__kmalloc_node(size_t size, gfp_t flags, int node) +@@ -537,7 +537,7 @@ static __always_inline void *kmalloc_large(size_t size, gfp_t flags) + * Try really hard to succeed the allocation but fail + * eventually. + */ +-static __always_inline void *kmalloc(size_t size, gfp_t flags) ++static __always_inline __attribute__((alloc_size(1))) void *kmalloc(size_t size, gfp_t flags) + { + if (__builtin_constant_p(size)) { + #ifndef CONFIG_SLOB +@@ -559,7 +559,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags) + return __kmalloc(size, flags); + } + +-static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) ++static __always_inline __attribute__((alloc_size(1))) void *kmalloc_node(size_t size, gfp_t flags, int node) + { + #ifndef CONFIG_SLOB + if (__builtin_constant_p(size) && +-- +2.29.2 + |
