Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp378564ybg; Wed, 3 Jun 2020 03:11:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8IAejdcZvRFWmtz+ZRPMRCot1p7pykmLY29kGxYuOSPsjB67famwNEeJHLPWAt8JH/gsx X-Received: by 2002:a50:8b05:: with SMTP id l5mr18725730edl.276.1591179090355; Wed, 03 Jun 2020 03:11:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591179090; cv=none; d=google.com; s=arc-20160816; b=FiEBsA0N1o+sCgVuIDSHa0IG95sguNctAHYGcnqimn6kDpUHhT1jU92liCpoZ0Mc1r s7B0n1cjpsyQtL0DjHI9bksPIzW6Rx8+U0f9+abCSnpaTW84c5RpstDQLlC/4zq5J7jM /1yDqvUFaUcA2Zzntsl4jDJRk3w5PYrrm1ObPVFvXjU3j6/UkNIO59iSeBRKBoFtd7d9 q1+fSU+1JDZqNtt2PtmOjtIrZ3xj7VTq0DAHsmWEVtJ3l+hMBGGMKvi0IE0wzBj9mATl 7FLrHS0V5ZzWj9WPHq4STnmyoDYMPWRNf0kSf08Al40pcg+DTrRIJMRGCjqagHOUJDCO YfLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=HqHoh+aTAzXTgdJ4pQ8wC+GtsvYNRqIDpE1mNuTlOU8=; b=Go7ks9GG0tqw8POKtWByqtrmlZt7KKHNzoyMK47gdN604HFSt41XlflIwMxNF3RHH9 5DWU/bJNE54v7bpgWbvo3l06Jz92xF0jsywtAeU2kzzexZt/wvVpHt89TZ1mYC1zAteM YRdY8DXxMi86yKPGv76NcJPvRIAL0HE+WtXtGxP7fABiofFZjzQcg2EHO5yhpdf4Z3uD Mca2XEU6ikPr9ruZJap+26SQKtSIe0c7YYIxfhKu3dM9vwlccpAahtHEvSW3ZyPeb32c A0vD9h4PC/Rh3yqKmccBPJze5bOHdqNt9lGwYAHaLlV9gJo9zaJnXLzE/GCClXgMDbbO 9Mfw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a24si884256ejs.603.2020.06.03.03.11.07; Wed, 03 Jun 2020 03:11:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726865AbgFCKJB (ORCPT + 99 others); Wed, 3 Jun 2020 06:09:01 -0400 Received: from 8bytes.org ([81.169.241.247]:45858 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725943AbgFCKJB (ORCPT ); Wed, 3 Jun 2020 06:09:01 -0400 Received: by theia.8bytes.org (Postfix, from userid 1000) id 4CD7E28B; Wed, 3 Jun 2020 12:08:59 +0200 (CEST) Date: Wed, 3 Jun 2020 12:08:57 +0200 From: Joerg Roedel To: Borislav Petkov Cc: x86@kernel.org, hpa@zytor.com, Andy Lutomirski , Dave Hansen , Peter Zijlstra , Thomas Hellstrom , Jiri Slaby , Dan Williams , Tom Lendacky , Juergen Gross , Kees Cook , David Rientjes , Cfir Cohen , Erdem Aktas , Masami Hiramatsu , Mike Stunes , Joerg Roedel , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH v3 23/75] x86/boot/compressed/64: Setup GHCB Based VC Exception handler Message-ID: <20200603100857.GA20099@8bytes.org> References: <20200428151725.31091-1-joro@8bytes.org> <20200428151725.31091-24-joro@8bytes.org> <20200511200709.GE25861@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200511200709.GE25861@zn.tnic> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 11, 2020 at 10:07:09PM +0200, Borislav Petkov wrote: > On Tue, Apr 28, 2020 at 05:16:33PM +0200, Joerg Roedel wrote: > > @@ -63,3 +175,45 @@ void __init do_vc_no_ghcb(struct pt_regs *regs, unsigned long exit_code) > > while (true) > > asm volatile("hlt\n"); > > } > > + > > +static enum es_result vc_insn_string_read(struct es_em_ctxt *ctxt, > > + void *src, char *buf, > > + unsigned int data_size, > > + unsigned int count, > > + bool backwards) > > +{ > > + int i, b = backwards ? -1 : 1; > > + enum es_result ret = ES_OK; > > + > > + for (i = 0; i < count; i++) { > > + void *s = src + (i * data_size * b); > > + char *d = buf + (i * data_size); > > >From a previous review: > > Where are we checking whether that count is not exceeding @buf or > similar discrepancies? These two functions are only called from vc_handle_ioio() and buf always points to ghcb->shared_buffer. In general, the caller has to make sure that sizeof(*buf) is at least data_size*count, and handle_ioio() calculates count based on the size of *buf. Joerg