From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CE08C433EF for ; Thu, 9 Sep 2021 16:21:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 42647611CB for ; Thu, 9 Sep 2021 16:21:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 42647611CB Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 7C6366B006C; Thu, 9 Sep 2021 12:21:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 74EB66B0072; Thu, 9 Sep 2021 12:21:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5EFD56B0073; Thu, 9 Sep 2021 12:21:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0085.hostedemail.com [216.40.44.85]) by kanga.kvack.org (Postfix) with ESMTP id 4BE196B006C for ; Thu, 9 Sep 2021 12:21:35 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E8CB91846CA3D for ; Thu, 9 Sep 2021 16:21:34 +0000 (UTC) X-FDA: 78568550508.20.6D85F2F Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) by imf28.hostedemail.com (Postfix) with ESMTP id B3CF690000A9 for ; Thu, 9 Sep 2021 16:21:34 +0000 (UTC) Received: by mail-lj1-f172.google.com with SMTP id q21so3859116ljj.6 for ; Thu, 09 Sep 2021 09:21:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=50boaNouSSTnvb0c2eCNnctIiz+x2UvGPCv3kZE2AMI=; b=CGlS41mR+Axb4y9wrWknWpwz18CNGuBs4jPnMvqDoRK2oZuinLZetPH/MFKIb8QsFq dwjlyvlbpGylKPvinmbj4zrK082kTzJ/A04BP0LPHPiMny8rw5XtJdbuLyAS2Cu3Iq2a 5mNDcYlZpJ2rQYFynA/vjgP5nvtJhW6kmblNhC/mlC/ZRbrsvDSWmxVX/yijiPJwLctZ Ok3XosICIt8PBk3Z4ObHrWttu9jOcUZBhM97/+okCfieuqwKAP85xxSsRIcM0i6dEpx6 CSdgzkqPT6zNjVZ+EGv4lv3irK7wfuuFFRAdH8Mg0EGSH/uIQU2+RRXceMf1eqItaojC GeKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=50boaNouSSTnvb0c2eCNnctIiz+x2UvGPCv3kZE2AMI=; b=voUIgCrGabqnm96leGgySs61uGuBhe8XwH/ITxJR8Gzogzpjgr6RuzPhaeLTM6RfkD MfXy1/TIRqzkcw39mfmOnm7Hsglgyx8uRntxM0/hqC1acKZJ858oXUQsyCwQOnLDqhmY rnVR4egkHY49tpaLylrDDnnNwfu6bZTAki1lAweQY0FOOef7mKxoqXD/4t/P0aNrd6wO 1oPMoT3tosnf4sUDAOQ42L5LjdSnQeuoeGzcfD2LalzYpMz2HDcQIbtRh5y2UWT08FhG 6kEULJyy8ahCfoV1sYW0JdnBiSofTzjyHKBij2wvMnP+Rrn0y39PlkhToQRnPtdVYcO5 6Ujw== X-Gm-Message-State: AOAM533YYbG2WEcym6shzmkcQ3o56qJEL3KGdfW4mHZgk7C39OEXaWhx 13Q5sZ9Ft8cUyVWP5OiLFjG70X/fHBtPG/z1+hxJZQ== X-Google-Smtp-Source: ABdhPJzsPtWW1AxipaV2pMWSdisA0skj+HLtMngumlXVDQINaNFPekQ15ydtkZbF3rf81kHbTiw9diF0ZbdCGuQNGTc= X-Received: by 2002:a05:651c:98c:: with SMTP id b12mr557878ljq.83.1631204492754; Thu, 09 Sep 2021 09:21:32 -0700 (PDT) MIME-Version: 1.0 References: <20210820151933.22401-1-brijesh.singh@amd.com> <20210820151933.22401-35-brijesh.singh@amd.com> <4742dbfe-4e02-a7e3-6464-905ccc602e6c@amd.com> In-Reply-To: From: Peter Gonda Date: Thu, 9 Sep 2021 10:21:20 -0600 Message-ID: Subject: Re: [PATCH Part1 v5 34/38] x86/sev: Add snp_msg_seqno() helper To: Brijesh Singh Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm list , linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.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 Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , Borislav Petkov , Michael Roth , Vlastimil Babka , "Kirill A . Shutemov" , Andi Kleen , tony.luck@intel.com, Marc Orr , sathyanarayanan.kuppuswamy@linux.intel.com Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=CGlS41mR; spf=pass (imf28.hostedemail.com: domain of pgonda@google.com designates 209.85.208.172 as permitted sender) smtp.mailfrom=pgonda@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: B3CF690000A9 X-Stat-Signature: tppmgdicc38xh5zh8g1ippdibe5f8ypo X-HE-Tag: 1631204494-967287 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Sep 9, 2021 at 10:17 AM Brijesh Singh wrote: > > > > On 9/9/21 10:43 AM, Peter Gonda wrote: > ... > > >> > >> Does this address your concern? > > > > So the 'snp_msg_seqno()' call in 'enc_payload' will not increment the > > counter, its only incremented on 'snp_gen_msg_seqno()'? If thats > > correct, that addresses my first concern. > > > > Yes, that is goal. > > >>> > >> > >> So far, the only user for the snp_msg_seqno() is the attestation driver. > >> And the driver is designed to serialize the vmgexit request and thus we > >> should not run into concurrence issue. > > > > That seems a little dangerous as any module new code or out-of-tree > > module could use this function thus revealing this race condition > > right? Could we at least have a comment on these functions > > (snp_msg_seqno and snp_gen_msg_seqno) noting this? > > > > Yes, if the driver is not performing the serialization then we will get > into race condition. > > One way to avoid this requirement is to do all the crypto inside the > snp_issue_guest_request() and eliminate the need to export the > snp_msg_seqno(). > > I will add the comment about it in the function. Actually I forgot that the sequence number is the only component of the AES-GCM IV. Seen in 'enc_payload'. Given the AES-GCM spec requires uniqueness of the IV. I think we should try a little harder than a comment to guarantee we never expose 2 requests encrypted with the same sequence number / IV. It's more than just a DOS against the guest's PSP request ability but also could be a guest security issue, thoughts? https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf (Section 8 page 18) > > thanks