forked from luck/tmp_suning_uos_patched
KVM: s390: Fix potential spectre warnings
Fix some warnings from smatch: arch/s390/kvm/interrupt.c:2310 get_io_adapter() warn: potential spectre issue 'kvm->arch.adapters' [r] (local cap) arch/s390/kvm/interrupt.c:2341 register_io_adapter() warn: potential spectre issue 'dev->kvm->arch.adapters' [w] Signed-off-by: Eric Farman <farman@linux.ibm.com> Message-Id: <20190417005414.47801-1-farman@linux.ibm.com> Reviewed-by: David Hildenbrand <david@redhat.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
This commit is contained in:
parent
79a3aaa7b8
commit
58616e6a37
|
@ -14,6 +14,7 @@
|
||||||
#include <linux/kvm_host.h>
|
#include <linux/kvm_host.h>
|
||||||
#include <linux/hrtimer.h>
|
#include <linux/hrtimer.h>
|
||||||
#include <linux/mmu_context.h>
|
#include <linux/mmu_context.h>
|
||||||
|
#include <linux/nospec.h>
|
||||||
#include <linux/signal.h>
|
#include <linux/signal.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/bitmap.h>
|
#include <linux/bitmap.h>
|
||||||
|
@ -2307,6 +2308,7 @@ static struct s390_io_adapter *get_io_adapter(struct kvm *kvm, unsigned int id)
|
||||||
{
|
{
|
||||||
if (id >= MAX_S390_IO_ADAPTERS)
|
if (id >= MAX_S390_IO_ADAPTERS)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
id = array_index_nospec(id, MAX_S390_IO_ADAPTERS);
|
||||||
return kvm->arch.adapters[id];
|
return kvm->arch.adapters[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2320,8 +2322,13 @@ static int register_io_adapter(struct kvm_device *dev,
|
||||||
(void __user *)attr->addr, sizeof(adapter_info)))
|
(void __user *)attr->addr, sizeof(adapter_info)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
if ((adapter_info.id >= MAX_S390_IO_ADAPTERS) ||
|
if (adapter_info.id >= MAX_S390_IO_ADAPTERS)
|
||||||
(dev->kvm->arch.adapters[adapter_info.id] != NULL))
|
return -EINVAL;
|
||||||
|
|
||||||
|
adapter_info.id = array_index_nospec(adapter_info.id,
|
||||||
|
MAX_S390_IO_ADAPTERS);
|
||||||
|
|
||||||
|
if (dev->kvm->arch.adapters[adapter_info.id] != NULL)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
|
adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user