[PATCH 0/5] Add __alloc_size() for better bounds checking
From: Kees Cook
Date: Wed Aug 18 2021 - 01:08:57 EST
Hi,
GCC and Clang both use the "alloc_size" attribute to assist with bounds
checking around the use of allocation functions. Add the attribute,
adjust the Makefile to silence needless warnings, and add the hints to
the allocators where possible. These changes have been in use for a
while now in GrapheneOS.
To build without warnings, this series needs a couple small fixes for
allmodconfig, which I sent separately:
https://lore.kernel.org/lkml/20210818044540.1601664-1-keescook@xxxxxxxxxxxx/
https://lore.kernel.org/lkml/20210818044252.1533634-1-keescook@xxxxxxxxxxxx/
https://lore.kernel.org/lkml/20210818043912.1466447-1-keescook@xxxxxxxxxxxx/
I figure I can take this via my "overflow" series, or it could go via
-mm?
-Kees
Kees Cook (5):
Compiler Attributes: Add __alloc_size() for better bounds checking
slab: Add __alloc_size attributes for better bounds checking
mm/page_alloc: Add __alloc_size attributes for better bounds checking
percpu: Add __alloc_size attributes for better bounds checking
mm/vmalloc: Add __alloc_size attributes for better bounds checking
Makefile | 6 +++-
include/linux/compiler_attributes.h | 6 ++++
include/linux/gfp.h | 4 +--
include/linux/percpu.h | 6 ++--
include/linux/slab.h | 50 ++++++++++++++++++-----------
include/linux/vmalloc.h | 22 ++++++-------
6 files changed, 58 insertions(+), 36 deletions(-)
--
2.30.2