All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: s390: Check kvm pointer when testing KVM_CAP_S390_HPAGE_1M
@ 2024-04-19 16:07 Jean-Philippe Brucker
  2024-04-19 16:43 ` Claudio Imbrenda
  2024-04-22  8:25 ` Christian Borntraeger
  0 siblings, 2 replies; 3+ messages in thread
From: Jean-Philippe Brucker @ 2024-04-19 16:07 UTC (permalink / raw)
  To: borntraeger, frankja, imbrenda, david
  Cc: hca, gor, agordeev, svens, kvm, linux-s390, Jean-Philippe Brucker

KVM allows issuing the KVM_CHECK_EXTENSION ioctl either on the /dev/kvm
fd or the VM fd. In the first case, kvm_vm_ioctl_check_extension() is
called with kvm==NULL. Ensure we don't dereference the pointer in that
case.

Fixes: 40ebdb8e59df ("KVM: s390: Make huge pages unavailable in ucontrol VMs")
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
Only build-tested
---
 arch/s390/kvm/kvm-s390.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 5147b943a864a..7721eb522f43d 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -587,7 +587,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
 		break;
 	case KVM_CAP_S390_HPAGE_1M:
 		r = 0;
-		if (hpage && !kvm_is_ucontrol(kvm))
+		if (hpage && !(kvm && kvm_is_ucontrol(kvm)))
 			r = 1;
 		break;
 	case KVM_CAP_S390_MEM_OP:
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: s390: Check kvm pointer when testing KVM_CAP_S390_HPAGE_1M
  2024-04-19 16:07 [PATCH] KVM: s390: Check kvm pointer when testing KVM_CAP_S390_HPAGE_1M Jean-Philippe Brucker
@ 2024-04-19 16:43 ` Claudio Imbrenda
  2024-04-22  8:25 ` Christian Borntraeger
  1 sibling, 0 replies; 3+ messages in thread
From: Claudio Imbrenda @ 2024-04-19 16:43 UTC (permalink / raw)
  To: Jean-Philippe Brucker
  Cc: borntraeger, frankja, david, hca, gor, agordeev, svens, kvm, linux-s390

On Fri, 19 Apr 2024 17:07:24 +0100
Jean-Philippe Brucker <jean-philippe@linaro.org> wrote:

> KVM allows issuing the KVM_CHECK_EXTENSION ioctl either on the /dev/kvm
> fd or the VM fd. In the first case, kvm_vm_ioctl_check_extension() is
> called with kvm==NULL. Ensure we don't dereference the pointer in that
> case.
> 
> Fixes: 40ebdb8e59df ("KVM: s390: Make huge pages unavailable in ucontrol VMs")
> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>

Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

> ---
> Only build-tested
> ---
>  arch/s390/kvm/kvm-s390.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index 5147b943a864a..7721eb522f43d 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -587,7 +587,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
>  		break;
>  	case KVM_CAP_S390_HPAGE_1M:
>  		r = 0;
> -		if (hpage && !kvm_is_ucontrol(kvm))
> +		if (hpage && !(kvm && kvm_is_ucontrol(kvm)))
>  			r = 1;
>  		break;
>  	case KVM_CAP_S390_MEM_OP:


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: s390: Check kvm pointer when testing KVM_CAP_S390_HPAGE_1M
  2024-04-19 16:07 [PATCH] KVM: s390: Check kvm pointer when testing KVM_CAP_S390_HPAGE_1M Jean-Philippe Brucker
  2024-04-19 16:43 ` Claudio Imbrenda
@ 2024-04-22  8:25 ` Christian Borntraeger
  1 sibling, 0 replies; 3+ messages in thread
From: Christian Borntraeger @ 2024-04-22  8:25 UTC (permalink / raw)
  To: Jean-Philippe Brucker, frankja, imbrenda, david
  Cc: hca, gor, agordeev, svens, kvm, linux-s390



Am 19.04.24 um 18:07 schrieb Jean-Philippe Brucker:
> KVM allows issuing the KVM_CHECK_EXTENSION ioctl either on the /dev/kvm
> fd or the VM fd. In the first case, kvm_vm_ioctl_check_extension() is
> called with kvm==NULL. Ensure we don't dereference the pointer in that
> case.
> 
> Fixes: 40ebdb8e59df ("KVM: s390: Make huge pages unavailable in ucontrol VMs")
> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>

Reviewed-by: Christian Borntraeger <borntraeger@linux.ibm.com>

thanks applied.

> ---
> Only build-tested
> ---
>   arch/s390/kvm/kvm-s390.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index 5147b943a864a..7721eb522f43d 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -587,7 +587,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
>   		break;
>   	case KVM_CAP_S390_HPAGE_1M:
>   		r = 0;
> -		if (hpage && !kvm_is_ucontrol(kvm))
> +		if (hpage && !(kvm && kvm_is_ucontrol(kvm)))
>   			r = 1;
>   		break;
>   	case KVM_CAP_S390_MEM_OP:

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-22  8:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-19 16:07 [PATCH] KVM: s390: Check kvm pointer when testing KVM_CAP_S390_HPAGE_1M Jean-Philippe Brucker
2024-04-19 16:43 ` Claudio Imbrenda
2024-04-22  8:25 ` Christian Borntraeger

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.