* re: KVM: Introduce a 'release' method for KVM devices
@ 2019-05-01 14:42 Colin Ian King
2019-05-02 2:35 ` Alexey Kardashevskiy
0 siblings, 1 reply; 3+ messages in thread
From: Colin Ian King @ 2019-05-01 14:42 UTC (permalink / raw)
To: Paolo Bonzini, Radim Krčmář, kvm, Cédric Le Goater
Cc: linux-kernel
Hi,
Static analysis with Coverity picked up an issue in the following commit:
commit 2bde9b3ec8bdf60788e9e2ce8c07a2f8d6003dbd
Author: Cédric Le Goater <clg@kaod.org>
Date: Thu Apr 18 12:39:41 2019 +0200
KVM: Introduce a 'release' method for KVM devices
struct kvm *kvm = dev->kvm;
+ if (!dev)
+ return -ENODEV;
If dev is null then the dereference of dev->kvm when assigning pointer
kvm will cause an null pointer dereference. This is easily fixed by
assigning kvm after the dev null check.
+
+ if (dev->kvm != kvm)
+ return -EPERM;
I don't understand the logic of the above check. kvm is the same
dev->kvm on the earlier assignment, so dev->kvm != kvm seems to be
always false, so this check seems to be redundant. Am I missing
something more fundamental here?
Colin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: KVM: Introduce a 'release' method for KVM devices
2019-05-01 14:42 KVM: Introduce a 'release' method for KVM devices Colin Ian King
@ 2019-05-02 2:35 ` Alexey Kardashevskiy
2019-05-06 9:50 ` Cédric Le Goater
0 siblings, 1 reply; 3+ messages in thread
From: Alexey Kardashevskiy @ 2019-05-02 2:35 UTC (permalink / raw)
To: Colin Ian King, Paolo Bonzini, Radim Krčmář,
kvm, Cédric Le Goater
Cc: linux-kernel
On 02/05/2019 00:42, Colin Ian King wrote:
> Hi,
>
> Static analysis with Coverity picked up an issue in the following commit:
>
> commit 2bde9b3ec8bdf60788e9e2ce8c07a2f8d6003dbd
> Author: Cédric Le Goater <clg@kaod.org>
> Date: Thu Apr 18 12:39:41 2019 +0200
>
> KVM: Introduce a 'release' method for KVM devices
>
>
> struct kvm *kvm = dev->kvm;
>
> + if (!dev)
> + return -ENODEV;
>
> If dev is null then the dereference of dev->kvm when assigning pointer
> kvm will cause an null pointer dereference. This is easily fixed by
> assigning kvm after the dev null check.
Yes, this is a bug.
>
> +
> + if (dev->kvm != kvm)
> + return -EPERM;
>
> I don't understand the logic of the above check. kvm is the same
> dev->kvm on the earlier assignment, so dev->kvm != kvm seems to be
> always false, so this check seems to be redundant. Am I missing
> something more fundamental here?
Nope. This looks like unfortunate cut-n-paste which slipped through out
reviewing process :-D
--
Alexey
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: KVM: Introduce a 'release' method for KVM devices
2019-05-02 2:35 ` Alexey Kardashevskiy
@ 2019-05-06 9:50 ` Cédric Le Goater
0 siblings, 0 replies; 3+ messages in thread
From: Cédric Le Goater @ 2019-05-06 9:50 UTC (permalink / raw)
To: Alexey Kardashevskiy, Colin Ian King, Paolo Bonzini,
Radim Krčmář,
kvm
Cc: linux-kernel
On 5/2/19 4:35 AM, Alexey Kardashevskiy wrote:
>
>
> On 02/05/2019 00:42, Colin Ian King wrote:
>> Hi,
>>
>> Static analysis with Coverity picked up an issue in the following commit:
>>
>> commit 2bde9b3ec8bdf60788e9e2ce8c07a2f8d6003dbd
>> Author: Cédric Le Goater <clg@kaod.org>
>> Date: Thu Apr 18 12:39:41 2019 +0200
>>
>> KVM: Introduce a 'release' method for KVM devices
>>
>>
>> struct kvm *kvm = dev->kvm;
>>
>> + if (!dev)
>> + return -ENODEV;
>>
>> If dev is null then the dereference of dev->kvm when assigning pointer
>> kvm will cause an null pointer dereference. This is easily fixed by
>> assigning kvm after the dev null check.
>
> Yes, this is a bug.
Clearly.
>>
>> +
>> + if (dev->kvm != kvm)
>> + return -EPERM;
>>
>> I don't understand the logic of the above check. kvm is the same
>> dev->kvm on the earlier assignment, so dev->kvm != kvm seems to be
>> always false, so this check seems to be redundant. Am I missing
>> something more fundamental here?
>
> Nope. This looks like unfortunate cut-n-paste which slipped through out
> reviewing process :-D
Yes. My bad :/ I will send a cleanup patch for 5.2
Thanks,
C.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-05-06 11:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-01 14:42 KVM: Introduce a 'release' method for KVM devices Colin Ian King
2019-05-02 2:35 ` Alexey Kardashevskiy
2019-05-06 9:50 ` Cédric Le Goater
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.