From: Nicholas Piggin <npiggin@gmail.com>
To: Fabiano Rosas <farosas@linux.ibm.com>, kvm-ppc@vger.kernel.org
Cc: christophe.leroy@c-s.fr, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v2 2/3] KVM: PPC: Book3S HV: Add sanity check to copy_tofrom_guest
Date: Fri, 06 Aug 2021 10:10:44 +0000 [thread overview]
Message-ID: <1628244579.t79ynn05df.astroid@bobo.none> (raw)
In-Reply-To: <20210805212616.2641017-3-farosas@linux.ibm.com>
Excerpts from Fabiano Rosas's message of August 6, 2021 7:26 am:
> Both paths into __kvmhv_copy_tofrom_guest_radix ensure that we arrive
> with an effective address that is smaller than our total addressable
> space and addresses quadrant 0.
>
> - The H_COPY_TOFROM_GUEST hypercall path rejects the call with
> H_PARAMETER if the effective address has any of the twelve most
> significant bits set.
>
> - The kvmhv_copy_tofrom_guest_radix path clears the top twelve bits
> before calling the internal function.
>
> Although the callers make sure that the effective address is sane, any
> future use of the function is exposed to a programming error, so add a
> sanity check.
We possibly should put these into #defines in radix pgtable headers
somewhere but KVM already open codes them so this is good for now.
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
>
> Suggested-by: Nicholas Piggin <npiggin@gmail.com>
> Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
> ---
> arch/powerpc/kvm/book3s_64_mmu_radix.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c
> index 44eb7b1ef289..1b1c9e9e539b 100644
> --- a/arch/powerpc/kvm/book3s_64_mmu_radix.c
> +++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c
> @@ -44,6 +44,9 @@ unsigned long __kvmhv_copy_tofrom_guest_radix(int lpid, int pid,
> (to != NULL) ? __pa(to): 0,
> (from != NULL) ? __pa(from): 0, n);
>
> + if (eaddr & (0xFFFUL << 52))
> + return ret;
> +
> quadrant = 1;
> if (!pid)
> quadrant = 2;
> --
> 2.29.2
>
>
next prev parent reply other threads:[~2021-08-06 10:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-05 21:26 [PATCH v2 0/3] KVM: PPC: Book3S HV: kvmhv_copy_tofrom_guest_radix changes Fabiano Rosas
2021-08-05 21:26 ` [PATCH v2 1/3] KVM: PPC: Book3S HV: Fix copy_tofrom_guest routines Fabiano Rosas
2021-08-06 10:09 ` Nicholas Piggin
2021-08-05 21:26 ` [PATCH v2 2/3] KVM: PPC: Book3S HV: Add sanity check to copy_tofrom_guest Fabiano Rosas
2021-08-06 10:10 ` Nicholas Piggin [this message]
2021-08-05 21:26 ` [PATCH v2 3/3] KVM: PPC: Book3S HV: Stop exporting symbols from book3s_64_mmu_radix Fabiano Rosas
2021-08-27 13:15 ` [PATCH v2 0/3] KVM: PPC: Book3S HV: kvmhv_copy_tofrom_guest_radix changes Michael Ellerman
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=1628244579.t79ynn05df.astroid@bobo.none \
--to=npiggin@gmail.com \
--cc=christophe.leroy@c-s.fr \
--cc=farosas@linux.ibm.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.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