From: Linus Torvalds <torvalds@linux-foundation.org>
To: Kees Cook <keescook@chromium.org>
Cc: Matthew Wilcox <mawilcox@microsoft.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Matthew Wilcox <willy@infradead.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-mm <linux-mm@kvack.org>,
Kernel Hardening <kernel-hardening@lists.openwall.com>
Subject: Re: [PATCH v3 00/16] Provide saturating helpers for allocation
Date: Thu, 31 May 2018 19:54:18 -0500 [thread overview]
Message-ID: <CA+55aFzjt27tDoxU=iVo7N3cR_nVSRm5+nvTZg=+t2A4k_yNwA@mail.gmail.com> (raw)
In-Reply-To: <20180601004233.37822-1-keescook@chromium.org>
On Thu, May 31, 2018 at 7:43 PM Kees Cook <keescook@chromium.org> wrote:
>
> So, while nothing does:
> kmalloc_array(a, b, ...) -> kmalloc(array_size(a, b), ...)
> the treewide changes DO perform changes like this:
> kmalloc(a * b, ...) -> kmalloc(array_size(a, b), ...)
Ugh. I really really still absolutely despise this.
Why can't you just have a separate set of coccinelle scripts that do
the simple and clean cases?
So *before* doing any array_size() conversions, just do
kzalloc(a*b, ...) -> kcalloc(a, b, ...)
kmalloc(a*b,..) -> kmalloc_array(a,b, ...)
and the obvious variations on that (devm_xyz() has all the same helpers).
Only after doing the ones that don't have the nice obvious helpers, do
the remaining ones with array_size(), ie
*alloc(a*b, ..) -> *alloc(array_size(a,b), ...)
because that really makes for much less legible code.
Hmm?
Linus
next prev parent reply other threads:[~2018-06-01 0:54 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-01 0:42 Kees Cook
2018-06-01 0:42 ` [PATCH v3 01/16] compiler.h: enable builtin overflow checkers and add fallback code Kees Cook
2018-06-01 0:42 ` [PATCH v3 02/16] lib: add runtime test of check_*_overflow functions Kees Cook
2018-06-01 0:42 ` [PATCH v3 03/16] lib: overflow: Report test failures Kees Cook
2018-06-01 0:42 ` [PATCH v3 04/16] overflow.h: Add allocation size calculation helpers Kees Cook
2018-06-01 0:42 ` [PATCH v3 05/16] lib: overflow: Add memory allocation overflow tests Kees Cook
2018-06-01 10:18 ` Andy Shevchenko
2018-06-01 0:42 ` [PATCH v3 06/16] mm: Use overflow helpers in kmalloc_array*() Kees Cook
2018-06-01 0:42 ` [PATCH v3 07/16] mm: Use overflow helpers in kvmalloc() Kees Cook
2018-06-01 0:42 ` [PATCH v3 08/16] device: Use overflow helpers for devm_kmalloc() Kees Cook
2018-06-01 0:42 ` [PATCH v3 09/16] treewide: Use struct_size() for kmalloc()-family Kees Cook
2018-06-01 0:42 ` [PATCH v3 10/16] treewide: Use struct_size() for vmalloc()-family Kees Cook
2018-06-01 0:42 ` [PATCH v3 11/16] treewide: Use struct_size() for devm_kmalloc() and friends Kees Cook
2018-06-01 0:42 ` [PATCH v3 12/16] treewide: Use array_size() for kmalloc()-family Kees Cook
2018-07-01 8:46 ` SF Markus Elfring
2018-07-01 9:03 ` Julia Lawall
2018-07-01 9:22 ` SF Markus Elfring
2018-06-01 0:42 ` [PATCH v3 13/16] treewide: Use array_size() for kmalloc()-family, leftovers Kees Cook
2018-06-01 0:42 ` [PATCH v3 14/16] treewide: Use array_size() for vmalloc() Kees Cook
2018-06-01 0:42 ` [PATCH v3 15/16] treewide: Use array_size() for devm_*alloc()-like Kees Cook
2018-06-01 0:42 ` [PATCH v3 16/16] treewide: Use array_size() for devm_*alloc()-like, leftovers Kees Cook
2018-06-01 0:54 ` Linus Torvalds [this message]
2018-06-01 4:18 ` [PATCH v3 00/16] Provide saturating helpers for allocation Kees Cook
2018-06-01 13:50 Peter Rosin
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='CA+55aFzjt27tDoxU=iVo7N3cR_nVSRm5+nvTZg=+t2A4k_yNwA@mail.gmail.com' \
--to=torvalds@linux-foundation.org \
--cc=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