From: Rasmus Villemoes Subject: Re: [PATCH] staging: lustre: Remove VLA usage References: <20180307054608.GA9300@beast> Date: Wed, 07 Mar 2018 21:48:33 +0100 In-Reply-To: (Kees Cook's message of "Wed, 7 Mar 2018 09:20:31 -0800") Message-ID: <87ina7ehni.fsf@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain To: Kees Cook Cc: Rasmus Villemoes , Greg Kroah-Hartman , LKML , "Tobin C. Harding" , Tycho Andersen , Oleg Drokin , Andreas Dilger , James Simmons , Dmitry Eremin , Gargi Sharma , Lustre Development List , devel@driverdev.osuosl.org, Kernel Hardening List-ID: On Wed, Mar 07 2018, Kees Cook wrote: > On Wed, Mar 7, 2018 at 5:10 AM, Rasmus Villemoes > wrote: >> On 2018-03-07 06:46, Kees Cook wrote: >>> The kernel would like to remove all VLA usage. This switches to a >>> simple kasprintf() instead. >>> >> >> It's probably worth pointing out that this actually fixes an >> unconditional buffer overflow: fullname only has room for the two >> strings and the '\n', but vsnprintf() is told that the buffer has >> infinite size (well, INT_MAX), so there should be plenty of room to >> append the '\0' after the '\n'. >> > > Oh yes, hah. I didn't even see the \n in the string. :P > > So, both a VLA fix and a buffer over-run fix. Can I add your "Reviewed-by"? :) Sure, Reviewed-by: Rasmus Villemoes A nit, if you're resending anyway: can you move the "char *fullname" declarations down a bit, to between pv,valid, and lli,rc, respectively? That keeps the initialized and uninitialized variables nicely together and ends up looking better.