From: alex.bennee@linaro.org (Alex Bennée)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: KVM: Fix user access for debug registers
Date: Wed, 16 Sep 2015 15:42:45 +0100 [thread overview]
Message-ID: <87vbbamnmi.fsf@linaro.org> (raw)
In-Reply-To: <1442400070-23316-1-git-send-email-marc.zyngier@arm.com>
Marc Zyngier <marc.zyngier@arm.com> writes:
> When setting the debug register from userspace, make sure that
> copy_from_user() is called with its parameters in the expected
> order. It otherwise doesn't do what you think.
Oops. Well that exposes a big hole in my testing. While I tested
debugging inside the guest worked before and after being guest debugged
I think GDBs tendency to reload all the debug registers between each
step may have masked this.
Debugging GDB in action or some sort of migration event would of course
screw this up but I'm afraid my testing wasn't evil enough.
Anyway have a:
Reviewed-by: Alex Benn?e <alex.bennee@linaro.org>
>
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Cc: Alex Benn?e <alex.bennee@linaro.org>
> Fixes: 84e690bfbed1 ("KVM: arm64: introduce vcpu->arch.debug_ptr")
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
> ---
> arch/arm64/kvm/sys_regs.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> index b41607d..1d0463e 100644
> --- a/arch/arm64/kvm/sys_regs.c
> +++ b/arch/arm64/kvm/sys_regs.c
> @@ -272,7 +272,7 @@ static int set_bvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
> {
> __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->reg];
>
> - if (copy_from_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0)
> + if (copy_from_user(r, uaddr, KVM_REG_SIZE(reg->id)) != 0)
> return -EFAULT;
> return 0;
> }
> @@ -314,7 +314,7 @@ static int set_bcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
> {
> __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_bcr[rd->reg];
>
> - if (copy_from_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0)
> + if (copy_from_user(r, uaddr, KVM_REG_SIZE(reg->id)) != 0)
> return -EFAULT;
>
> return 0;
> @@ -358,7 +358,7 @@ static int set_wvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
> {
> __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wvr[rd->reg];
>
> - if (copy_from_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0)
> + if (copy_from_user(r, uaddr, KVM_REG_SIZE(reg->id)) != 0)
> return -EFAULT;
> return 0;
> }
> @@ -400,7 +400,7 @@ static int set_wcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd,
> {
> __u64 *r = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->reg];
>
> - if (copy_from_user(uaddr, r, KVM_REG_SIZE(reg->id)) != 0)
> + if (copy_from_user(r, uaddr, KVM_REG_SIZE(reg->id)) != 0)
> return -EFAULT;
> return 0;
> }
--
Alex Benn?e
prev parent reply other threads:[~2015-09-16 14:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-16 10:41 [PATCH] arm64: KVM: Fix user access for debug registers Marc Zyngier
2015-09-16 13:41 ` Christoffer Dall
2015-09-16 14:06 ` Marc Zyngier
2015-09-16 14:35 ` Alex Bennée
2015-09-16 14:46 ` Marc Zyngier
2015-09-16 14:42 ` Alex Bennée [this message]
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=87vbbamnmi.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).