Re: [PATCH 1/4] x86: entry.S: tidy up several suboptimal insns

From: Ingo Molnar
Date: Wed Feb 25 2015 - 04:39:55 EST



* H. Peter Anvin <hpa@xxxxxxxxx> wrote:

> > So could we just zap the high 32 bits of RAX early in
> > the entry code, and then from that point on we could
> > both use 32-bit ops and won't have to remember the
> > possibility either?
>
> We do that, [...]

Ok, indeed, so in ia32_sysenter_target() we have:

movl %eax, %eax

> [...] but people keep "optimizing" the zero extend away.
> [...]

Possibly because there's not a single comment near that
code explaining the importance of that line. But nobody
will get a change past me with such a warning next to the
line.

> [...] We have had this cause a wide-open security hole
> twice already. So the extra REX prefix is a cheap cost
> to avoid this happen again.

But since we already zap the high bits, there's no point in
doing 64-bit compares...

Just make sure the high zero bit clearing is there and is
never removed.

So in that sense the changes are correct, even in the
security robustness sense.

Furthermore, with the masking suggestion I made in the
previous mail it's moot as we can solve both problems:
64-bit uses of RAX will become correct as well, and it
will be a bit faster as well.

Hm?

Thanks,

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/