The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: "Hyunwook (Wooky) Baek" <baekhw@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Joerg Roedel <jroedel@suse.de>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	David Rientjes <rientjes@google.com>,
	Sean Christopherson <seanjc@google.com>,
	linux-kernel@vger.kernel.org, x86@kernel.org
Subject: Re: [PATCH] x86/sev-es: Fix SEV-ES #VC handler for string port IO
Date: Fri, 8 Jan 2021 18:20:49 +0100	[thread overview]
Message-ID: <20210108172049.GF4042@zn.tnic> (raw)
In-Reply-To: <20210108025107.1223487-1-baekhw@google.com>

On Thu, Jan 07, 2021 at 06:51:07PM -0800, Hyunwook (Wooky) Baek wrote:
> Don't assume dest/source buffers are userspace addresses when manually
> copying data for string I/O or MOVS MMIO, as {get,put}_user() will fail
> if handed a kernel address and ultimately lead to a kernel panic.
> 
> Signed-off-by: Hyunwook (Wooky) Baek <baekhw@google.com>
> Acked-by: David Rientjes <rientjes@google.com>
> ---
>  arch/x86/kernel/sev-es.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/arch/x86/kernel/sev-es.c b/arch/x86/kernel/sev-es.c
> index 0bd1a0fc587e..812494d216ba 100644
> --- a/arch/x86/kernel/sev-es.c
> +++ b/arch/x86/kernel/sev-es.c
> @@ -286,6 +286,12 @@ static enum es_result vc_write_mem(struct es_em_ctxt *ctxt,
>  	u16 d2;
>  	u8  d1;
>  
> +	/* If instruction ran in kernel mode and the I/O buffer is in kernel space */
> +	if (!user_mode(ctxt->regs) && !access_ok(s, size)) {
						^^^

Just by looking at this patch I know you haven't tested it before sending.

:-(

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

  reply	other threads:[~2021-01-08 17:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-08  2:51 [PATCH] x86/sev-es: Fix SEV-ES #VC handler for string port IO Hyunwook (Wooky) Baek
2021-01-08 17:20 ` Borislav Petkov [this message]
2021-01-08 19:32   ` Hyunwook (Wooky) Baek

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=20210108172049.GF4042@zn.tnic \
    --to=bp@alien8.de \
    --cc=baekhw@google.com \
    --cc=jroedel@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rientjes@google.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=x86@kernel.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