On Mon, Dec 17, 2018 at 10:34 PM Gustavo A. R. Silva <gustavo@xxxxxxxxxxxxxx> wrote: > offset and lineinfo.line_offset are indirectly controlled by user-space, > hence leading to a potential exploitation of the Spectre variant 1 > vulnerability. Goodness gracious me! > This issue was detected with the help of Smatch: > > drivers/gpio/gpiolib.c:580 linehandle_create() warn: potential spectre issue 'gdev->descs' [r] (local cap) > drivers/gpio/gpiolib.c:927 lineevent_create() warn: potential spectre issue 'gdev->descs' [r] (local cap) > drivers/gpio/gpiolib.c:1053 gpio_ioctl() warn: potential spectre issue 'gdev->descs' [r] (local cap) > > Fix this by sanitizing both offset and lineinfo.line_offset before > using them to index gdev->descs. > > Notice that given that speculation windows are large, the policy is > to kill the speculation on the first load and not worry if it can be > completed with a dependent load/store [1]. > > [1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2 > > Cc: stable@xxxxxxxxxxxxxxx > Signed-off-by: Gustavo A. R. Silva <gustavo@xxxxxxxxxxxxxx> Bartosz can you take this for a ride with libgpiod and see if we get performance regressions from this speculation killing? If you get some data on that I would like to include it with the changelog. Yours, Linus Walleij