Re: [PATCH v3] x86,entry: Use PUSH_AND_CLEAR_REGS for compat

From: Lai Jiangshan
Date: Fri Apr 29 2022 - 08:00:59 EST


On Fri, Apr 29, 2022 at 5:13 PM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
>
> Since the upper regs don't exist for ia32 code, preserving them
> doesn't hurt and it simplifies the code.
>
> If there was any attack surface on this, that attack surface already
> exists for INT80 and needs to be otherwise dealt with.
>
> Notably:
>
> - SYSENTER: didn't clear si, dx, cx.
> - SYSCALL, INT80: *do* clear si since the C functions don't take a
> second argument.
>

If CLEAR_REGS for SYSCALL, INT80 clears si, it is better, IMO, to
make CLEAR_REGS clear si unconditionally.

SYSCALL, INT80 will explicitly clear si via calling
syscall_enter_from_user_mode().

But some handlers called from the macro idtentry don't clear
si explicitly, although it is likely to be cleared.

So if %rsi is a concern for SYSCALL, INT80, please make CLEAR_REGS
clear %rsi unconditionally.

Thanks
Lai