Re: [PATCH v7 4/6] x86/entry: Enable random_kstack_offset support
From: Kees Cook <hidden>
Date: 2021-03-29 18:44:09
Also in:
linux-hardening, linux-mm, lkml
From: Kees Cook <hidden>
Date: 2021-03-29 18:44:09
Also in:
linux-hardening, linux-mm, lkml
On Sun, Mar 28, 2021 at 04:18:56PM +0200, Thomas Gleixner wrote:
On Fri, Mar 19 2021 at 14:28, Kees Cook wrote:quoted
+ + /* + * x86_64 stack alignment means 3 bits are ignored, so keep + * the top 5 bits. x86_32 needs only 2 bits of alignment, so + * the top 6 bits will be used. + */ + choose_random_kstack_offset(rdtsc() & 0xFF);Comment mumbles about 5/6 bits and the TSC value is masked with 0xFF and then the applied offset is itself limited with 0x3FF. Too many moving parts for someone who does not have the details of all this memorized.
Each piece is intentional -- I will improve the comments to explain each level of masking happening (implicit compiler stack alignment mask, explicit per-arch mask, and the VLA upper-bound protection mask). -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel