Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3021952pxj; Mon, 14 Jun 2021 12:29:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwG7IjeEzoKGxzFH04nbS0XP/5qFIKHbfdXXu9UMG72iVM9VG7UUIlx4Gx8kgo2Ac/w1xXo X-Received: by 2002:aa7:c6c8:: with SMTP id b8mr18989799eds.213.1623698962481; Mon, 14 Jun 2021 12:29:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623698962; cv=none; d=google.com; s=arc-20160816; b=J3c2DzFwIUWhyiCz9FilMgwRnUdtV0LITz3OkZeG6wMRG1jM7eTtsFjG/tqMp8mzmJ sdaao8Apzp044uk1rsZxFNwmwXon06dFxzJCiFOeiZAySmLvr4kWjZK6IKFKIEc26J4z HN9z/FG8nYRP2LhfuDw7wMyOaI/34QsnMXU5pJDexXgMVgc/G0dZE4gbwymCaxXfQpkO +NIBMPElGnr5JrITr7GfVAkLuEh6Jbis9gPyPNYpWHNErhF/fvX6H6/cAh4uEvTCcOpl ooUIkm3lTJ70b6ayKzeD0WSrd0ip6gCsEi8DNn+5BCgCUiskP4nF2TFumjaGaSUhAvY0 Lkyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=laL7XkHns5/yXOay8jXifFn3byoXTFqIh5OZCqwkQxA=; b=cRe1IPPE8/R/Vif1h9UYhu990kIN+qCeLV+XML86ya5N9+ebHgGRBBeNAvPtVwTOWz 41E/yY/Rn111IawXgt6e3xbc8d1mTISK69NuKniThHzevvbyBK00TTXhZ5lE+DrKmBMu egGpPGKnRPv7w+iT31D0rCBsfRrQ3RH1luX3adz7xWNflWbwry9Z7Jjmvq3W3Ou8tKtE gTc+tlLYp/Oz/zN2PMZotOmmWn/ZYph+D98FgiCjiMIn3Vv5jraFrb7OKE5l0DPpxEVz blZ5WNajCZI6DMGohMIJzWqOCEEDQGTJerxfyjFtPmlg/qDc3tzQm5tiFu58NJMl57sg wf0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=QU37vsFR; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v9si7834701edc.545.2021.06.14.12.28.52; Mon, 14 Jun 2021 12:29:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=QU37vsFR; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234339AbhFNTaD (ORCPT + 99 others); Mon, 14 Jun 2021 15:30:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232877AbhFNTaC (ORCPT ); Mon, 14 Jun 2021 15:30:02 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1803C061574; Mon, 14 Jun 2021 12:27:59 -0700 (PDT) Received: from zn.tnic (p200300ec2f09b9000b7fffe760596043.dip0.t-ipconnect.de [IPv6:2003:ec:2f09:b900:b7f:ffe7:6059:6043]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 483B41EC036C; Mon, 14 Jun 2021 21:27:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1623698878; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=laL7XkHns5/yXOay8jXifFn3byoXTFqIh5OZCqwkQxA=; b=QU37vsFRCs1g8V2Hv19vW6MzgEmVl3iprMJ1vstfinAJMWwvaB4Htigv81twAQEglWqxVr nw9WIU69ua8LDbYF6WGgczvr3uPNBm0+grzV0iaNqYc05YVjVa0fTlY2MQKPaKO0+rjxqn dgR5T/C67PFm8cx8E/Of8m643q9ujrY= Date: Mon, 14 Jun 2021 21:27:50 +0200 From: Borislav Petkov To: Brijesh Singh Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-crypto@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Joerg Roedel , Tom Lendacky , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Gonda , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , tony.luck@intel.com, npmccallum@redhat.com Subject: Re: [PATCH Part1 RFC v3 14/22] x86/mm: Add support to validate memory when changing C-bit Message-ID: References: <20210602140416.23573-1-brijesh.singh@amd.com> <20210602140416.23573-15-brijesh.singh@amd.com> <267dc549-fcef-480e-891c-effd3d5b2058@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <267dc549-fcef-480e-891c-effd3d5b2058@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, Jun 14, 2021 at 08:05:51AM -0500, Brijesh Singh wrote: > Guest OS depend on the hypervisor to assist in this operation. The loop > will terminate only after the hypervisor completes the requested > operation. Guest is not protecting itself from DoS type of attack. A > guest should not proceed until hypervisor performs the request page > state change in the RMP table. Some of that could be in a comment over that loop, so that it is clear what the guest strategy is. > Let me understand, are you saying that hypervisor could trick us into > believing that page state change completed without actually changing it ? Nah, I'm just saying that you should verify those ->cur_entry and ->end_entry values. Of course the guest doesn't protect itself against DoS types of attacks but this function page_state_vmgexit() here could save ->cur_entry and ->end_entry on function entry and then compare it each time the hypercall returns to make sure HV is not doing some shenanigans with the entries range or even has a bug or so. I.e., it has not changed ->end_entry or ->cur_entry is not going backwards into the buffer. I know, if uncaught here, it probably will explode later but a cheap sanity check like that doesn't hurt to have just in case. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette