Re: [PATCHv3] x86/selftests: add clobbers for int80 on x86_64
From: Andy Lutomirski
Date: Fri Feb 17 2017 - 12:03:53 EST
On Mon, Feb 13, 2017 at 2:18 PM, <hpa@xxxxxxxxx> wrote:
> On February 13, 2017 11:06:04 AM PST, Andy Lutomirski <luto@xxxxxxxxxxxxxx> wrote:
>>On Mon, Feb 13, 2017 at 2:13 AM, Dmitry Safonov
>>> Kernel erases R8..R11 registers prior returning to userspace
>>> from int80: https://lkml.org/lkml/2009/10/1/164
>>> GCC can reuse this registers and doesn't expect them to change
>>> during syscall invocation. I met this kind of bug in CRIU once
>>> gcc 6.1 and clang stored local variables in those registers
>>> and the kernel zerofied them during syscall:
>>> By that reason I suggest to add those registers to clobbers
>>> in selftests. Also, as notted by Andy - removed unneeded clobber
>>> for flags in int 0x80 inline asm.
>>Acked-by: Andy Lutomirski <luto@xxxxxxxxxx>
>>Although these days we could preserve these regs in the kernel at the
>>cost of (I think) 4 bytes of text and zero runtime overhead.
> If we can do so that cheaply I think we should.
Sure, but we should still apply Dmitry's patches first.