Re: [PATCH v2] mm/vmalloc: widen guard region to defeat ENTER-based stack pivot
From: H. Peter Anvin
Date: Wed Jul 01 2026 - 04:16:29 EST
On July 1, 2026 12:48:34 AM PDT, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>On Wed, Jul 01, 2026 at 09:27:47AM +0200, Peter Zijlstra wrote:
>> On Mon, Jun 29, 2026 at 03:29:50PM -0700, Dave Hansen wrote:
>>
>> > But, really, if ENTER is so evil and nobody uses it, shouldn't we just
>> > have an MSR bit somewhere to tell the CPU to #UD for it rather than
>> > playing these stack games?
>>
>> For supervisor mode only, I suppose. We can't ever get rid of userspace
>> ENTER because legacy I suppose. But we can make sure the kernel is
>> clean.
>>
>> So yeah, having a knob to make supervisor-ENTER trap would be useful I
>> suppose.
>
>x86_64-defconfig builds clean with the below :-)
>
>
>diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c
>index 1b387d5a195b..9e53db863203 100644
>--- a/tools/objtool/arch/x86/decode.c
>+++ b/tools/objtool/arch/x86/decode.c
>@@ -642,6 +642,10 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
>
> break;
>
>+ case 0xc8:
>+ WARN("ENTER instruction at %s:%lx", sec->name, offset);
>+ break;
>+
> case 0xc9:
> /*
> * leave
The problem is that it being a single byte long it can appear in the middle of another instruction.
ENTER was primarily designed for languages with nested local scopes, for which it can do quite a bit of work.