From: Kees Cook <keescook@chromium.org>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>,
Andrzej Hajda <andrzej.hajda@intel.com>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
linux-hardening@vger.kernel.org,
Daniel Latypov <dlatypov@google.com>,
Vitor Massaru Iha <vitor@massaru.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] overflow: Allow mixed type arguments
Date: Mon, 29 Aug 2022 14:19:59 -0700 [thread overview]
Message-ID: <202208291415.01271EA1@keescook> (raw)
In-Reply-To: <d325bf21-efa4-b3e9-a0d8-3662a9f7ab1a@rasmusvillemoes.dk>
On Mon, Aug 29, 2022 at 11:14:56PM +0200, Rasmus Villemoes wrote:
> On 29/08/2022 22.47, Kees Cook wrote:
> > When the check_[op]_overflow() helpers were introduced, all arguments were
> > required to be the same type to make the fallback macros simpler. However,
> > once the fallback macros were removed[1], it is fine to allow mixed
> > types, which makes using the helpers much more useful, as they can be
> > used to test for type-based overflows (e.g. adding two large ints but
> > storing into a u8), as would be handy in the drm core[2].
> >
> > Remove the restriction, and add additional self-tests that exercise some
> > of the mixed-type overflow cases.
>
> Makes sense. I'm a little worried about the implications for -stable
> backports to kernels that can still be built with gcc < 5.1, but we
> can't let that dictate what is done in mainline. And even people
> building old kernels shouldn't be using ancient compilers.
Right. I hope this will remain a theoretical problem, but if it really
comes up, the -stable patch can get some explicit type size checking or
something...
>
> >
> > -#define DEFINE_TEST_ARRAY(t) \
> > - static const struct test_ ## t { \
> > - t a, b; \
> > - t sum, diff, prod; \
> > - bool s_of, d_of, p_of; \
> > - } t ## _tests[]
> > +#define DEFINE_TEST_ARRAY_TYPED(t1, t2, t) \
> > + static const struct test_ ## t1 ## t2 ## t { \
> > + t1 a; \
> > + t2 b; \
> > + t sum, diff, prod; \
> > + bool s_of, d_of, p_of; \
> > + } t1 ## t2 ## t ## _tests[]
>
> Can I get you to throw in some extra _, because this...
>
> > +DEFINE_TEST_FUNC_TYPED(u32u32int, int, "%d");
>
> ...makes my eyes hurt a little. Maybe even make it u32_u32__int, so it's
> emphasized that the order is [src op src -> tgt] and not [tgt = src op src].
Sure! Everything I tried hurt my eyes, so I opted for fewest characters.
;)
--
Kees Cook
prev parent reply other threads:[~2022-08-29 21:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-29 20:47 Kees Cook
2022-08-29 21:14 ` Rasmus Villemoes
2022-08-29 21:19 ` Kees Cook [this message]
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=202208291415.01271EA1@keescook \
--to=keescook@chromium.org \
--cc=andrzej.hajda@intel.com \
--cc=dlatypov@google.com \
--cc=gustavoars@kernel.org \
--cc=gwan-gyeong.mun@intel.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=ndesaulniers@google.com \
--cc=vitor@massaru.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
all inboxes | Powered by JetHome®