提交 14e32321 编写于 作者: M Marios Pomonis 提交者: Paolo Bonzini

KVM: x86: Refactor picdev_write() to prevent Spectre-v1/L1TF attacks

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: 85f455f7 ("KVM: Add support for in-kernel PIC emulation")
Signed-off-by: NNick Finco <nifi@google.com>
Signed-off-by: NMarios Pomonis <pomonis@google.com>
Reviewed-by: NAndrew Honig <ahonig@google.com>
Cc: stable@vger.kernel.org
Reviewed-by: NJim Mattson <jmattson@google.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 86187937
...@@ -460,10 +460,14 @@ static int picdev_write(struct kvm_pic *s, ...@@ -460,10 +460,14 @@ static int picdev_write(struct kvm_pic *s,
switch (addr) { switch (addr) {
case 0x20: case 0x20:
case 0x21: case 0x21:
pic_lock(s);
pic_ioport_write(&s->pics[0], addr, data);
pic_unlock(s);
break;
case 0xa0: case 0xa0:
case 0xa1: case 0xa1:
pic_lock(s); pic_lock(s);
pic_ioport_write(&s->pics[addr >> 7], addr, data); pic_ioport_write(&s->pics[1], addr, data);
pic_unlock(s); pic_unlock(s);
break; break;
case 0x4d0: case 0x4d0:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册