On Mon, Mar 18, 2019 at 09:58:20AM -0700, Linus Torvalds wrote: > On Mon, Mar 18, 2019 at 8:54 AM Peter Zijlstra <pet...@infradead.org> wrote: > > > > We rely on objtool to verify AC=1 doesn't escape. However there is no > > objtool support for x86_32, and thus we cannot guarantee the > > correctness of the 32bit code. > > Absolutely not. > > This is just crazy. We had working SMAP long before objtool, and we > will have it regardless of objtool.
Well, 'working', because as shown with this work, there's been a number of bugs around this. Anyway, since you mentioned it, I checked, about 16 months: Broadwell was Oct'14, objtool was Feb'16. > This is like saying "ok, I don't have an oxygen sensor, so I don't > know that the air I'm breathing is sufficient to maintain life, so > I'll just stop breathing". With PTI, booting a 32bit kernel on a Broadwell or later will already complain about it being sub-optimal for missing out on PCID. But sure; if you want to enable this.. > So no way in hell do we make SMAP go away on 32-bit for no sane reason > what-so-ever. then I'd sleep much better if we make 32bit context switch EFLAGS. Because, yes, x86_64 objtool validates a lot of the x86_32 code too, but unless we have 100% coverage, there's always the chance an AC=1 escapes. --- arch/x86/entry/entry_32.S | 2 ++ arch/x86/include/asm/switch_to.h | 1 + arch/x86/kernel/process_32.c | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S index d309f30cf7af..5fc76b755510 100644 --- a/arch/x86/entry/entry_32.S +++ b/arch/x86/entry/entry_32.S @@ -650,6 +650,7 @@ ENTRY(__switch_to_asm) pushl %ebx pushl %edi pushl %esi + pushfl /* switch stack */ movl %esp, TASK_threadsp(%eax) @@ -672,6 +673,7 @@ ENTRY(__switch_to_asm) #endif /* restore callee-saved registers */ + popfl popl %esi popl %edi popl %ebx diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h index 7cf1a270d891..18a4b6890fa8 100644 --- a/arch/x86/include/asm/switch_to.h +++ b/arch/x86/include/asm/switch_to.h @@ -46,6 +46,7 @@ struct inactive_task_frame { unsigned long r13; unsigned long r12; #else + unsigned long flags; unsigned long si; unsigned long di; #endif diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c index e471d8e6f0b2..d28e9a74b736 100644 --- a/arch/x86/kernel/process_32.c +++ b/arch/x86/kernel/process_32.c @@ -127,6 +127,11 @@ int copy_thread_tls(unsigned long clone_flags, unsigned long sp, struct task_struct *tsk; int err; + /* + * We start a new task with the RESET value of EFLAGS, in particular we + * context switch with IRQs disabled. + */ + frame->flags = X86_EFLAGS_FIXED; frame->bp = 0; frame->ret_addr = (unsigned long) ret_from_fork; p->thread.sp = (unsigned long) fork_frame;