Re: [PATCH] input: i8042 - fix a double-fetch vulnerability introduced by GCC

From: Dmitry Torokhov
Date: Fri Nov 04 2022 - 14:24:09 EST


Hi Greg,

On Fri, Nov 04, 2022 at 11:45:48AM +0100, Greg KH wrote:
> On Fri, Nov 04, 2022 at 03:23:47PM +0800, Kunbo Zhang wrote:
> > As in the source code, the global variable is tested (at line 408) before three assignments of irq_bit, disable_bit and port_name.
> > However, as shown in the following disassembly of i8042_port_close(),
> > the variable (0x0(%rip)) is fetched and tested three times for each
> > assignment of irq_bit, disable_bit and port_name.
>
> There should not be any problem with this as that value does not ever
> change except in rare cases (shutdown or init).

We use this chunk only to establish identity of the port, we do not
expect instances to change while driver operates, so I do not think
there is any concern with re-fetching/re-checking the port while it is
being closed.

Thanks.

--
Dmitry