From: Kees Cook <keescook@chromium.org>
To: Matthew Wilcox <mawilcox@microsoft.com>
Cc: Kees Cook <keescook@chromium.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Matthew Wilcox <willy@infradead.org>,
LKML <linux-kernel@vger.kernel.org>,
Linux-MM <linux-mm@kvack.org>,
Kernel Hardening <kernel-hardening@lists.openwall.com>
Subject: [PATCH v2 0/6] Provide saturating helpers for allocation
Date: Wed, 9 May 2018 13:02:17 -0700 [thread overview]
Message-ID: <20180509200223.22451-1-keescook@chromium.org> (raw)
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
next reply other threads:[~2018-05-09 20:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-09 20:02 Kees Cook [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180509200223.22451-1-keescook@chromium.org \
--to=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mawilcox@microsoft.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox