mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] LoongArch: KVM: Check return values for put_user
@ 2026-05-26  7:42 Qiang Ma
  2026-05-27  6:16 ` Bibo Mao
  0 siblings, 1 reply; 2+ messages in thread
From: Qiang Ma @ 2026-05-26  7:42 UTC (permalink / raw)
  To: zhaotianrui, maobibo, chenhuacai, kernel
  Cc: kvm, loongarch, linux-kernel, Qiang Ma

put_user() may return -EFAULT, so, when the user space address
is invalid, it should return -EFAULT.

Signed-off-by: Qiang Ma <maqianga@uniontech.com>
---
 arch/loongarch/kvm/vcpu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c
index 782dc1a36e29..67441edf0e1f 100644
--- a/arch/loongarch/kvm/vcpu.c
+++ b/arch/loongarch/kvm/vcpu.c
@@ -1104,7 +1104,8 @@ static int kvm_loongarch_cpucfg_get_attr(struct kvm_vcpu *vcpu,
 		return -ENXIO;
 	}
 
-	put_user(val, uaddr);
+	if (put_user(val, uaddr))
+		return -EFAULT;
 
 	return ret;
 }
-- 
2.20.1


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

* Re: [PATCH] LoongArch: KVM: Check return values for put_user
  2026-05-26  7:42 [PATCH] LoongArch: KVM: Check return values for put_user Qiang Ma
@ 2026-05-27  6:16 ` Bibo Mao
  0 siblings, 0 replies; 2+ messages in thread
From: Bibo Mao @ 2026-05-27  6:16 UTC (permalink / raw)
  To: Qiang Ma, zhaotianrui, chenhuacai, kernel; +Cc: kvm, loongarch, linux-kernel



On 2026/5/26 下午3:42, Qiang Ma wrote:
> put_user() may return -EFAULT, so, when the user space address
> is invalid, it should return -EFAULT.
> 
> Signed-off-by: Qiang Ma <maqianga@uniontech.com>
> ---
>   arch/loongarch/kvm/vcpu.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c
> index 782dc1a36e29..67441edf0e1f 100644
> --- a/arch/loongarch/kvm/vcpu.c
> +++ b/arch/loongarch/kvm/vcpu.c
> @@ -1104,7 +1104,8 @@ static int kvm_loongarch_cpucfg_get_attr(struct kvm_vcpu *vcpu,
>   		return -ENXIO;
>   	}
>   
> -	put_user(val, uaddr);
> +	if (put_user(val, uaddr))
> +		return -EFAULT;
>   
>   	return ret;
>   }
> 
Reviewed-by: Bibo Mao <maobibo@loongson.cn>


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

end of thread, other threads:[~2026-05-27  6:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-26  7:42 [PATCH] LoongArch: KVM: Check return values for put_user Qiang Ma
2026-05-27  6:16 ` Bibo Mao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®