Skip to content

Add __alloc_size() for better bounds checking

Kees Cook linux-hardening linux-kbuild linux-mm lkml 2 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest7 patches 12 repliesIn review
  2. v15 patches 15 repliesSuperseded

Changes in v2 from the cover letter

- clean up slab function declarations (joe)
- update checkpatch.pl attribute regex (joe)
- explain the Makefile changes better (ojeda, nathan)
v1: https://lore.kernel.org/lkml/[email protected]

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7Compiler Attributes: Add __alloc_size() for better bounds checkingMakefile include/linux/compiler_attributes.h+11 -14 replies
2/7checkpatch: Add __alloc_size() to known $Attributescripts/checkpatch.pl+2 -10 replies
3/7slab: Clean up function declarationsinclude/linux/slab.h+35 -330 replies
4/7slab: Add __alloc_size attributes for better bounds checkinginclude/linux/slab.h+18 -23 replies
5/7mm/page_alloc: Add __alloc_size attributes for better bounds checkinginclude/linux/gfp.h+2 -00 replies
6/7percpu: Add __alloc_size attributes for better bounds checkinginclude/linux/percpu.h+3 -05 replies
7/7mm/vmalloc: Add __alloc_size attributes for better bounds checkinginclude/linux/vmalloc.h+11 -00 replies

Reviews trailers per patch

2 of 7 patches have a Reviewed-by or Acked-by.

PatchNathan ChancellorMiguel OjedaNick Desaulniers
1/7R-b R-b
2/7
3/7
4/7R-b
5/7
6/7
7/7

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [PATCH v2 0/7] Add __alloc_size() for better bounds checking

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/[email protected]/
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/

I figure I can take this via my "overflow" series, or it could go via -mm?

-Kees

v2:
- clean up slab function declarations (joe)
- update checkpatch.pl attribute regex (joe)
- explain the Makefile changes better (ojeda, nathan)
v1: https://lore.kernel.org/lkml/[email protected]

Kees Cook (7):
Compiler Attributes: Add __alloc_size() for better bounds checking
checkpatch: Add __alloc_size() to known $Attribute
slab: Clean up function declarations
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                 |  2 +
 include/linux/percpu.h              |  3 ++
 include/linux/slab.h                | 84 +++++++++++++++++------------
 include/linux/vmalloc.h             | 11 ++++
 scripts/checkpatch.pl               |  3 +-
 7 files changed, 80 insertions(+), 35 deletions(-)
Signature · 1 line
2.30.2