linux-hardening.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nick Desaulniers <ndesaulniers@google.com>
To: Kees Cook <keescook@chromium.org>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	"Gustavo A . R . Silva" <gustavoars@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>,
	Keith Busch <kbusch@kernel.org>, Len Baker <len.baker@gmx.com>,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH 1/2] overflow: Implement size_t saturating arithmetic helpers
Date: Mon, 24 Jan 2022 13:16:51 -0800	[thread overview]
Message-ID: <CAKwvOdk+S=sTJWePADwrHFbVKKW1-WijzcS898GU2B0h57vt3Q@mail.gmail.com> (raw)
In-Reply-To: <202201241237.C82267B66C@keescook>

On Mon, Jan 24, 2022 at 1:13 PM Kees Cook <keescook@chromium.org> wrote:
>
> What I'd really like is a "store this in a size_t" check to catch dumb
> storage size problems (or related overflows). In other words:
>
> size_t big1 = 2147483647;
> size_t big2 = 2147483647;
>
> /* Doesn't overflow, but 4611686014132420609 becomes a 1 for int */
> int size = size_mul(big1, big2);
> ...
> ptr = kmalloc(size, GFP_KERNEL); /* Allocates a 1 instead... */

-Wshorten-64-to-32
?

-- 
Thanks,
~Nick Desaulniers

  reply	other threads:[~2022-01-24 23:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-20 18:08 [PATCH 0/2] " Kees Cook
2021-09-20 18:08 ` [PATCH 1/2] " Kees Cook
2021-09-20 22:06   ` Nick Desaulniers
2021-09-21  1:38     ` Kees Cook
2021-09-21  6:51   ` Rasmus Villemoes
2021-09-21 19:07     ` Kees Cook
2022-01-24 21:13     ` Kees Cook
2022-01-24 21:16       ` Nick Desaulniers [this message]
2022-01-25 12:58       ` Jason Gunthorpe
2021-09-20 18:08 ` [PATCH 2/2] test_overflow: Regularize test reporting output Kees Cook
2021-09-20 22:10   ` Nick Desaulniers
2021-09-21  6:56     ` Rasmus Villemoes

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='CAKwvOdk+S=sTJWePADwrHFbVKKW1-WijzcS898GU2B0h57vt3Q@mail.gmail.com' \
    --to=ndesaulniers@google.com \
    --cc=gustavoars@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=kbusch@kernel.org \
    --cc=keescook@chromium.org \
    --cc=len.baker@gmx.com \
    --cc=leon@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=nathan@kernel.org \
    --subject='Re: [PATCH 1/2] overflow: Implement size_t saturating arithmetic helpers' \
    /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

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).