linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/6] Provide saturating helpers for allocation
@ 2018-05-09 20:02 Kees Cook
  2018-05-09 20:02 ` [PATCH v2 1/6] compiler.h: enable builtin overflow checkers and add fallback code Kees Cook
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Kees Cook @ 2018-05-09 20:02 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Kees Cook, Rasmus Villemoes, Matthew Wilcox, LKML, Linux-MM,
	Kernel Hardening

This is a stab at providing three new helpers for allocation size
calculation:

struct_size(), array_size(), and array3_size().

These are implemented on top of Rasmus's overflow checking functions. The
existing allocators are adjusted to use the more efficient overflow
checks as well.

I have left out the 8 tree-wide conversion patches of open-coded
multiplications into the new helpers, as those are largely
unchanged from v1. Everything can be seen here, though:
https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/log/?h=kspp/overflow/array_size

The question remains for what to do with the *calloc() and *_array*()
API. They could be entirely removed in favor of using the new helpers:

kcalloc(n, size, gfp)        ->  kzalloc(array_size(n, size), gfp)
kmalloc_array(n, size, gfp)  ->  kmalloc(array_size(n, size), gfp)

Changes from v1:
- use explicit overflow helpers instead of array_size() helpers.
- drop early-checks for SIZE_MAX.
- protect devm_kmalloc()-family from addition overflow.
- added missing overflow.h includes.
- fixed 0-day issues in a few treewide manual conversions

-Kees

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-05-11  0:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-09 20:02 [PATCH v2 0/6] Provide saturating helpers for allocation Kees Cook
2018-05-09 20:02 ` [PATCH v2 1/6] compiler.h: enable builtin overflow checkers and add fallback code Kees Cook
2018-05-09 20:02 ` [PATCH v2 2/6] lib: add runtime test of check_*_overflow functions Kees Cook
2018-05-09 20:02 ` [PATCH v2 3/6] overflow.h: Add allocation size calculation helpers Kees Cook
2018-05-09 20:02 ` [PATCH v2 4/6] mm: Use overflow helpers in kmalloc_array*() Kees Cook
2018-05-09 20:02 ` [PATCH v2 5/6] mm: Use overflow helpers in kvmalloc() Kees Cook
2018-05-09 20:02 ` [PATCH v2 6/6] device: Use overflow helpers for devm_kmalloc() Kees Cook
2018-05-11  0:02 ` [PATCH v2 0/6] Provide saturating helpers for allocation Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).