Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1896178ybg; Thu, 30 Jul 2020 05:39:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZTKTkjJ7ADTCTS2lwS3fPROLGCGggBGfbYlOwBVDebiHnDep2GvqjTVn9Oj4FZR7tWagh X-Received: by 2002:aa7:c496:: with SMTP id m22mr2475482edq.336.1596112774926; Thu, 30 Jul 2020 05:39:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596112774; cv=none; d=google.com; s=arc-20160816; b=Z1lW+JV7S7q+3Fc++0+szR+xs9dKclkzkmptEda1OFfywixTuyp+ZUP12OaXZu/YXG x5eiXdwZtF52rvtNfeR3jsWS3X7G6krdZycT7CSHNL3W/5Lc6dKvuWGHWjZXvjik0MZE mDAPmngn4yr3eqBtAdPWIQh77YZM7Fp9IzoDYYaCbo1wAGnlyIL8XVGTNYpI9Uuo5joR wkxDZ/qTCBvp0UhS1h6ZDEc+cjgv/r4TC7vihYbjEt+EUNlCFprOvT6J1GGALz9OLSST rnbxz/c0JiUgdIkihslC5iOxZWVvjQKhvJ0mIxSk+GMJyjvuht3IkgBIQ4lvb99qNpRg c+Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=bADnEpKqODZFz9Vcs0uwMa1KSX12BVouJfo4sGUrZPU=; b=RsXQcsbEDdLUDfn0d7Yj5ldjq0b7MfmL0Ghr5JzPGTnf4oAAb0e7QdwDkFUFG1zMgM 5bd+1SHba3G54G8w+6qnMqgLJWkHra0aPvyYD0f+61ym7GJBoI8qYKJOBSjDbhM0Evur tnxwS0NLoayUbQjzI3gAvoEaS3CzjKA9xScxV0C0vUV1DoIY/u9eBpXTZqpEdG4Zb9bd cAK2Znlr8EkWl2nE+L0y788R5P8ulbk18TWV3SAkPmuuGXrlESTV5To9qnyYNd0lo8np z6ZgGm/G8vKUGUCQyAaoUE/9T0imULQN5tcCgU6O5VI5VTv12Ed1/1wt61wvGZeXLlFI Oi9Q== 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 dh1si3175109edb.54.2020.07.30.05.39.13; Thu, 30 Jul 2020 05:39:34 -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 S1728141AbgG3Mi4 (ORCPT + 99 others); Thu, 30 Jul 2020 08:38:56 -0400 Received: from 8bytes.org ([81.169.241.247]:34032 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726535AbgG3Miz (ORCPT ); Thu, 30 Jul 2020 08:38:55 -0400 Received: by theia.8bytes.org (Postfix, from userid 1000) id 1D1C53C8; Thu, 30 Jul 2020 14:38:54 +0200 (CEST) Date: Thu, 30 Jul 2020 14:38:52 +0200 From: Joerg Roedel To: Sean Christopherson Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Joerg Roedel Subject: Re: [PATCH 1/4] KVM: SVM: nested: Don't allocate VMCB structures on stack Message-ID: <20200730123852.GB3257@8bytes.org> References: <20200729132234.2346-1-joro@8bytes.org> <20200729132234.2346-2-joro@8bytes.org> <20200729151454.GB27751@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200729151454.GB27751@linux.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sean, thanks for your review! On Wed, Jul 29, 2020 at 08:14:55AM -0700, Sean Christopherson wrote: > On Wed, Jul 29, 2020 at 03:22:31PM +0200, Joerg Roedel wrote: > Speaking of too large, would it be overly paranoid to add: > > BUILD_BUG_ON(sizeof(struct vmcb_control_area) + sizeof(struct vmcb_save_area) < > KVM_STATE_NESTED_SVM_VMCB_SIZE) > > More so for documentation than for any real concern that the SVM architecture > will do something silly, e.g. to make it obvious that patch 2 in this series > won't break backwards compatibility. The check should actually be '>', but then it makes sense. The control- and save-area together are still way smaller than 4k. I will add the check for '>' to this patch. > > + ret = -EFAULT; > > + if (copy_from_user(ctl, &user_vmcb->control, sizeof(ctl))) > > The sizeof() calc is wrong, this is now calculating the size of the pointer, > not the size of the struct. It'd need to be sizeof(*ctl). > > > + goto out_free; > > + if (copy_from_user(save, &user_vmcb->save, sizeof(save))) > > Same bug here. Thanks, fixed that. Regards, Joerg