From: Qiang Ma <maqianga@uniontech.com>
To: zhaotianrui@loongson.cn, maobibo@loongson.cn,
chenhuacai@kernel.org, kernel@xen0n.name
Cc: kvm@vger.kernel.org, loongarch@lists.linux.dev,
linux-kernel@vger.kernel.org, Qiang Ma <maqianga@uniontech.com>
Subject: [PATCH] LoongArch: KVM: Check return values for put_user
Date: Tue, 26 May 2026 15:42:02 +0800 [thread overview]
Message-ID: <20260526074202.789799-1-maqianga@uniontech.com> (raw)
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
next reply other threads:[~2026-05-26 7:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 7:42 Qiang Ma [this message]
2026-05-27 6:16 ` Bibo Mao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260526074202.789799-1-maqianga@uniontech.com \
--to=maqianga@uniontech.com \
--cc=chenhuacai@kernel.org \
--cc=kernel@xen0n.name \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=maobibo@loongson.cn \
--cc=zhaotianrui@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®