[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+55aFy=T6TmG_VcLvSTb02RyKTacxVCxwUALRn8_7cdoic0pA@mail.gmail.com>
Date: Mon, 3 Sep 2018 14:28:59 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: "Uecker, Martin" <Martin.Uecker@....uni-goettingen.de>
Cc: Kees Cook <keescook@...omium.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: VLAs and security
On Mon, Sep 3, 2018 at 12:40 AM Uecker, Martin
<Martin.Uecker@....uni-goettingen.de> wrote:
>
> But if the true bound is smaller, then IMHO it is really bad advise
> to tell programmers to use
>
> char buf[MAX_SIZE]
>
> instead of something like
>
> assert(N <= MAX_SIZE);
> char buf[N]
No.
First off, we don't use asserts in the kernel. Not acceptable. You
handle errors, you don't crash.
Secondly, the compiler is usually very stupid, and will generate
horrible code for VLA's.
Third, there's no guarantee that the compiler will actually even
realize that the size is limited, and guarantee that it won't screw up
the stack.
So no. VLA's are not acceptable in the kernel. Don't do them. We're
getting rid of them.
Linus
Powered by blists - more mailing lists