From: Alexander Popov References: <1515766769-9120-1-git-send-email-alex.popov@linux.com> <0c1950e9-626d-c7b8-5551-fcc233501025@linux.com> Message-ID: Date: Thu, 18 Jan 2018 16:09:23 +0300 MIME-Version: 1.0 In-Reply-To: <0c1950e9-626d-c7b8-5551-fcc233501025@linux.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: [kernel-hardening] Re: [PATCH RFC v7 0/6] Introduce the STACKLEAK feature and a test for it To: Kees Cook Cc: kernel-hardening@lists.openwall.com, PaX Team , Brad Spengler , Ingo Molnar , Andy Lutomirski , Tycho Andersen , Laura Abbott , Mark Rutland , Ard Biesheuvel , Borislav Petkov , Thomas Gleixner , "H . Peter Anvin" , Peter Zijlstra , "Dmitry V . Levin" , X86 ML List-ID: Hello Kees, On 17.01.2018 14:37, Alexander Popov wrote: > On 15.01.2018 22:59, Kees Cook wrote: >> On Fri, Jan 12, 2018 at 6:19 AM, Alexander Popov wrote: >>> This is the 7th version of the patch series introducing STACKLEAK to the >>> mainline kernel. STACKLEAK is a security feature developed by Grsecurity/PaX >>> (kudos to them), which: >>> - reduces the information that can be revealed through kernel stack leak bugs; >>> - blocks some uninitialized stack variable attacks (e.g. CVE-2010-2963); >>> - introduces some runtime checks for kernel stack overflow detection. >> >> I think this is really looking good. I had some thoughts while reading >> through the patches: >> >> There are really three features in this series, and it might make >> sense to separate them a bit more clearly (at least with CONFIG >> choices): >> >> 1) stack clearing (with depth searching) >> >> 2) runtime stack depth tracking (making 1 much more efficient) >> >> 3) alloca checking (an additional feature, not strictly part of >> clearing, but needs the same plugin infrastructure) >> >> It seems like it should be possible to get 1 without 2 and 3 (both of >> which happen in the gcc plugin), and might be good to separate for >> builds that don't have gcc plugins. >> >> Once compilers are doing alloca checking (or all VLAs are removed from >> the kernel), it'd be nice to be able to avoid the redundancy of 3. > > Agree with your point. I'll make this separation in the next version. I have more thoughts about this separation. Splitting (1) from (2) ---------------------- It makes the stack erasing not only slow but also unreliable. For example, an attacker can craft some STACKLEAK_POISON values on the thread stack to deceive the poison search during the erasing. Of course, I can increase STACKLEAK_POISON_CHECK_DEPTH or change the default value of lowest_stack. It will make the stack erasing even slower, but will not give guarantees. So I don't think that (1) without (2) is actually a good feature. I would propose to refrain from separating the stack erasing and the lowest_stack tracking. Splitting (2) and (3) --------------------- The STACKLEAK gcc plugin needs to search for alloca anyway (for the correct lowest_stack tracking). But I can introduce the "no-check-alloca" plugin parameter for disabling the check_alloca() call insertion. Is it worth providing something like CONFIG_GCC_PLUGIN_STACKLEAK_NO_CHECK_ALLOCA in the Kconfig? Thanks! Best regards, Alexander