[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202104151107.8E3D919@keescook>
Date: Thu, 15 Apr 2021 11:08:31 -0700
From: Kees Cook <keescook@...omium.org>
To: David Laight <David.Laight@...LAB.COM>
Cc: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Miguel Ojeda <ojeda@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"rust-for-linux@...r.kernel.org" <rust-for-linux@...r.kernel.org>,
Linux Kbuild mailing list <linux-kbuild@...r.kernel.org>,
"open list:DOCUMENTATION" <linux-doc@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 00/13] [RFC] Rust support
On Thu, Apr 15, 2021 at 08:26:21AM +0000, David Laight wrote:
> ...
> > Besides just FP, 128-bit, etc, I remain concerned about just basic
> > math operations. C has no way to describe the intent of integer
> > overflow, so the kernel was left with the only "predictable" result:
> > wrap around. Unfortunately, this is wrong in most cases, and we're left
> > with entire classes of vulnerability related to such overflows.
>
> I'm not sure any of the alternatives (except perhaps panic)
> are much better.
> Many years ago I used a COBOL system that skipped the assignment
> if ADD X to Y (y += x) would overflow.
> That gave a very hard to spot error when the sump of a long list
> way a little too large.
> If it had wrapped the error would be obvious.
>
> There are certainly places where saturate is good.
> Mostly when dealing with analogue samples.
>
> I guess the problematic code is stuff that checks:
> if (foo->size + constant > limit) goto error;
> instead of:
> if (foo->size > limit - constant) goto error;
Right. This and alloc(size * count) are the primary offenders. :)
--
Kees Cook
Powered by blists - more mailing lists