Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2127605rwb; Thu, 17 Nov 2022 06:57:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf7xvNvw0/fMA94TuUdE2wXuGUzih5bXayL18kFyTa4LpSmeMprrzVQJhxEddv6fCYZLPory X-Received: by 2002:a17:906:4f0b:b0:78d:aaf9:7b8c with SMTP id t11-20020a1709064f0b00b0078daaf97b8cmr2509670eju.229.1668697056452; Thu, 17 Nov 2022 06:57:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668697056; cv=none; d=google.com; s=arc-20160816; b=rUSfXuUeaqVxDer/3mfHJ2rV13L6MVpWhw1Yyte/LkQEOZvz04Rkp9+YMRXRyZro1C Xw+tDilqGmzaSNv9N4PY6KxozdMpiif1/84H0D1U8RK8L6oOTn2G4MoEWzaEIKwc8vsl O5eGZWQH+93Ht9YmYviGdCpFDzJMVPPfNkSWss708zbExFM8XpmQ9jd7evtJHC34TSI3 Px8i4m+6uLsUhXKwCEDEiPpsm/sYuujvXXUPVJkGR93lI1L5uEkweGMlNsvU7WGLJ5CW FkUIkCyF1hNL3YdDzJfViarc0qChpjiKjFQfyWUnt3+fk6qViXmKuBHzZJYDN/9pfrpC 2pxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=D3x133dVtwVv7jvx8g97kW4FBOvvKkB/v2oc16Tf4lc=; b=Qxu4i3+1Y2zpybOXP0FvlMgscP6bODbxbIYdT7KsupR5A+FiI21X9vXBBSt7/y4CI2 /aJeLkNTQDAgSf0hAMON13C1nQCS2DBKnFZ3KD1eUDwVhfndvYYT7bFPU0oAaniTzGAS Bj1H+D1hWzaJLK8rjkwoLAu7tI0c6n2QF4dljfeUKl2sIMYltLTDB/TNYYHp5hhfgVqu RiDyFyoFSpBxCIj9bv75Ha7HD9BEOMEatXrmnS9WKMhQuehgiWt7v6rftGno0VCJmD1m 6O9rWJgcEHyVsz+zj7N7w1Xj/ixyC53kZQJgahh5AQv+OXwF/m0gYVNy0weUwk4Rr+bK sf0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=HrVH8yqh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i11-20020a05640242cb00b004679f8aaa2fsi1183843edc.370.2022.11.17.06.57.12; Thu, 17 Nov 2022 06:57:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=HrVH8yqh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240350AbiKQOTd (ORCPT + 92 others); Thu, 17 Nov 2022 09:19:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240327AbiKQOTb (ORCPT ); Thu, 17 Nov 2022 09:19:31 -0500 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 954D91007C for ; Thu, 17 Nov 2022 06:19:30 -0800 (PST) Received: by mail-lf1-x132.google.com with SMTP id g7so3030031lfv.5 for ; Thu, 17 Nov 2022 06:19:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=D3x133dVtwVv7jvx8g97kW4FBOvvKkB/v2oc16Tf4lc=; b=HrVH8yqh59n941IfjY8F2X3AvLLvdAiPmJ+LjuOQJSHpEVGtdgWDTTcoEKtqXZjfcH BJYvIAQKdWMlCETZNgkGvK2ciql3SNLG9lNHBolWfrYQlE1P534aKrS/+HPFui6P5pnu +2OW6S+9MkUOpfawuNT4zCy+QFH/k7z27DPt2l8ozLtQ1sEjJcQE+t/YYzx0J3XW1VR1 26P7roYiX5qFLu//qxeLGFlXXH/0B/JYGVMXtNsmJekqdxNjeq9hIGghT+h3LNaxKFrA oA48gB3qhT6DzyyqhzUmjAOKTkQJSu2AwoieLsRXVR3gzJv8IOtsNUuO8cFjA+yU+Vrk Ph9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=D3x133dVtwVv7jvx8g97kW4FBOvvKkB/v2oc16Tf4lc=; b=pyOPl4kui1eF21QM2ccJZdwEqsIZYOHKzDfxRc1F8gCn8RgwfU3YFDmU1KVOwckI8A jw9Xz14dVTSgpGQ9CzY+M0zTS14AD8RIM6Ek4H96cdvkae7Z2vlbVZy9IjAzv7MtwhJg 5SgtAKyxBE4y2PuR/t/UChtvxV+ophodADD/me2myjff+6ONCr2Of1vt19jmkXGrzXyE 3WH7Q3Tj0J8IG8+uoVoT79lDMSa+ab7RtQmofy28EmsLQ5w6Sfz1sziXRW3xt1CVgRKC i3cd080n5RLO12z4u37YkSKiTV9HARCyGFy5v2k7mKaABaS5FncjHQ4+foDUZLfiEish O6eQ== X-Gm-Message-State: ANoB5pk6MjG9ldsPUpMzLB4TJNvEQgknlESWNKRyuxQ6gobjtSk6P5pk cK0KP+IqwBfAslRyoS4c4zxqDbgIGnsfyQI6AmeJsA== X-Received: by 2002:a05:6512:3a3:b0:4b1:11a3:d1b with SMTP id v3-20020a05651203a300b004b111a30d1bmr1092769lfp.291.1668694768789; Thu, 17 Nov 2022 06:19:28 -0800 (PST) MIME-Version: 1.0 References: <20221116175558.2373112-1-pgonda@google.com> <3e50c258-8732-088c-d9d8-dfaae82213f0@amd.com> In-Reply-To: <3e50c258-8732-088c-d9d8-dfaae82213f0@amd.com> From: Peter Gonda Date: Thu, 17 Nov 2022 07:19:17 -0700 Message-ID: Subject: Re: [PATCH V5] virt: sev: Prevent IV reuse in SNP guest driver To: Tom Lendacky Cc: Borislav Petkov , Michael Roth , Haowen Bai , Yang Yingliang , Marc Orr , David Rientjes , Dionna Glaze , Ashish Kalra , stable@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 16, 2022 at 12:02 PM Tom Lendacky wrote: > > On 11/16/22 11:55, Peter Gonda wrote: > > The AMD Secure Processor (ASP) and an SNP guest use a series of > > AES-GCM keys called VMPCKs to communicate securely with each other. > > The IV to this scheme is a sequence number that both the ASP and the > > guest track. Currently this sequence number in a guest request must > > exactly match the sequence number tracked by the ASP. This means that > > if the guest sees an error from the host during a request it can only > > retry that exact request or disable the VMPCK to prevent an IV reuse. > > AES-GCM cannot tolerate IV reuse see: "Authentication Failures in NIST > > version of GCM" - Antoine Joux et al. > > > > In order to address this make handle_guest_request() delete the VMPCK > > on any non successful return. To allow userspace querying the cert_data > > length make handle_guest_request() safe the number of pages required by > > s/safe/save/ > > > the host, then handle_guest_request() retry the request without > > ... then have handle_guest_request() ... > > > requesting the extended data, then return the number of pages required > > back to userspace. > > > > Fixes: fce96cf044308 ("virt: Add SEV-SNP guest driver") > > Signed-off-by: Peter Gonda > > Reported-by: Peter Gonda > > Just some nits on the commit message and comments below, otherwise > > Reviewed-by: Tom Lendacky Thanks Tom. I'll update with all the feedback after Boris chimes in.