Skip to content
This repository was archived by the owner on Jul 16, 2020. It is now read-only.

Commit 6531996

Browse files
marpomppajda
authored andcommitted
KVM: x86: Refactor picdev_write() to prevent Spectre-v1/L1TF attacks
[ Upstream commit 14e32321f3606e4b0970200b6e5e47ee6f1e6410 ] This fixes a Spectre-v1/L1TF vulnerability in picdev_write(). It replaces index computations based on the (attacked-controlled) port number with constants through a minor refactoring. Fixes: 85f455f ("KVM: Add support for in-kernel PIC emulation") Signed-off-by: Nick Finco <nifi@google.com> Signed-off-by: Marios Pomonis <pomonis@google.com> Reviewed-by: Andrew Honig <ahonig@google.com> Cc: stable@vger.kernel.org Reviewed-by: Jim Mattson <jmattson@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Lee Jones <lee.jones@linaro.org> Change-Id: I48f503d0c0ad3f108d7b23f2edb86664f8b42429
1 parent 9904315 commit 6531996

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

arch/x86/kvm/i8259.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,14 @@ static int picdev_write(struct kvm_pic *s,
468468
switch (addr) {
469469
case 0x20:
470470
case 0x21:
471+
pic_lock(s);
472+
pic_ioport_write(&s->pics[0], addr, data);
473+
pic_unlock(s);
474+
break;
471475
case 0xa0:
472476
case 0xa1:
473477
pic_lock(s);
474-
pic_ioport_write(&s->pics[addr >> 7], addr, data);
478+
pic_ioport_write(&s->pics[1], addr, data);
475479
pic_unlock(s);
476480
break;
477481
case 0x4d0:

0 commit comments

Comments
 (0)