Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp518943pxb; Wed, 27 Jan 2021 13:41:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6gTgY46JYmFW+2FapkbHjJcto693v2xmwfVXgVoxY8vGTsKxshR+NfQOVrU1U9QDzvrFH X-Received: by 2002:aa7:c9c9:: with SMTP id i9mr10863991edt.160.1611783713768; Wed, 27 Jan 2021 13:41:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611783713; cv=none; d=google.com; s=arc-20160816; b=o5tyxqUWXAZ7+58BqfaLgGhImRD94hZGe2Z9Se0pEXz+DLzD/0KJZ2IpsBiscM/sCh oyuMpvmP8pEsdn4nn4iucTPazSZU9+cTBTWPuKFr6lzF8VbenyEcZrx89pRcTs+Z1ZdL iJ084KpoKMtf27mej7RUZmtY40w8Up5IzAwA/McdbqNgdXLbKZxFWeq7H5V9Jx64mSKv FKWO0q3K0Q8FHpXI7MC+cZHQ2iOwo+9Kij9PPEN05l8sAdcYATyogFPDyRJ/vxBT2SwV h3xkOf4PbmKiYU94vudITP5avyQxvua2K9IK6CnqwyvA1IiVrH4D+8n0M3RfHbJ+IV1x Z2Iw== 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=HQObKKSE5vuDsoooUB32J7Kk+tA9rn8yWjz82H0MqC8=; b=AGLvxxWw1uwHcMjn5g73HNfsx8mK4V8ItPSy+Ui9wRD6YfytOpwDFEev0Ts40gNSKf CYkcVvrXrDZUcvjm9oIRQztKOv/I3zjH/2ev77m+SOF4kKfXZQjjNASZi6ssHBfskcFp EnYrjclFurWB+gbLHSISdqtv03xrqf72nWAcNuSHCSmY3ivIkiLKF776AYQN7yvxFs5e ygbwxEg9/q03Hv15tLSF86iHLjEEp49H9hIfa5mohOSUXyv1ZjROutZb5iBJK8qxnb+o UNbiDJeFD5acaJDCEM8XUd/VhXLdpmw/Ap/obX4HcLONJS32KDP7vzExuflIJQNwSU7V rnXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=IsXZ6AVs; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y25si1297812ejb.546.2021.01.27.13.41.28; Wed, 27 Jan 2021 13:41:53 -0800 (PST) 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; dkim=pass header.i=@google.com header.s=20161025 header.b=IsXZ6AVs; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232173AbhA0In3 (ORCPT + 99 others); Wed, 27 Jan 2021 03:43:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S316833AbhAZXK4 (ORCPT ); Tue, 26 Jan 2021 18:10:56 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5822FC061756 for ; Tue, 26 Jan 2021 15:10:16 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id e9so147391pjj.0 for ; Tue, 26 Jan 2021 15:10:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=HQObKKSE5vuDsoooUB32J7Kk+tA9rn8yWjz82H0MqC8=; b=IsXZ6AVsbd6O9Z0cFT3PBS/RJNtNM2XJtyaaO0UwmfubfXJoIdSncE7qf0pmXEDit3 H8dX/ubGwBjS6aA4Q2sSM7Onoa3N3i3/V6LcwH/ryOrbDmmjVqTeti6AUbYZJ8c9HdQi D1TfpWnzciIxEy4DkfQyf9U5EeyWpFDmgFPHCaIWJkWzjQwa7BljNsU3peKEfCY4zLgk UVoYirmVQrL/GbuA7oEohpSHUtmla6fTZ6y1IYsp5WIgRFEujTU+QlKNadINq5yKzpWl rsrnYI2DT8IFm1XFhtMRCeQGHR1+Nn25595y0VuVGvxpbOfrbzDHxTioqvFYA6jgC2PB s8Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=HQObKKSE5vuDsoooUB32J7Kk+tA9rn8yWjz82H0MqC8=; b=Cc/e6l4Vlu61R4eYDViL+48yRv1rTEGY89QO19VVvpEWSyR0n509WJXYW4H0zow31t vEqlIvQOyjuXDN2acAJo64sYpYg+WuNiMXyvqDrzvbe9RBHd9gYF9L3hhQq2gZJ8UIap atjdGD5mee9pDbDF3DlrCXlHTU+Ag2hPgM7ckHkn+Tnj92xI3wWZvS/MD4BDOo4uRJBX uS1LpPxf1ftXqgjzpha718RFIGzQTbnyTf5L8+hetPhA3OjL62+Wp1GoPl1e1R32OPuK tZFuNI/u6GaXqMTXbAl+uZSy0jMt1ABe7DZ+7jeezP5VR/BrI+TNr+TEGEKE1UOKxtBm +WDQ== X-Gm-Message-State: AOAM531NDA8odyTDa1s5V5JND7uCCFIsakqtCxHA394A5LxVkuP2If8I lv079s8t5X3HXHNWWKJrS9wZ/g== X-Received: by 2002:a17:90a:7e82:: with SMTP id j2mr2147173pjl.217.1611702615801; Tue, 26 Jan 2021 15:10:15 -0800 (PST) Received: from google.com ([2620:15c:f:10:1ea0:b8ff:fe73:50f5]) by smtp.gmail.com with ESMTPSA id m77sm155892pfd.82.2021.01.26.15.10.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 15:10:15 -0800 (PST) Date: Tue, 26 Jan 2021 15:10:08 -0800 From: Sean Christopherson To: Tom Lendacky Cc: Peter Gonda , kvm@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Paolo Bonzini , Joerg Roedel , Brijesh Singh , x86@kernel.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Fix unsynchronized access to sev members through svm_register_enc_region Message-ID: References: <20210126185431.1824530-1-pgonda@google.com> <6407cdf6-5dc7-96c0-343b-d2c0e1d7aaa4@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6407cdf6-5dc7-96c0-343b-d2c0e1d7aaa4@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 26, 2021, Tom Lendacky wrote: > On 1/26/21 12:54 PM, Peter Gonda wrote: > > sev_pin_memory assumes that callers hold the kvm->lock. This was true for > > all callers except svm_register_enc_region since it does not originate > > from svm_mem_enc_op. Also added lockdep annotation to help prevent > > future regressions. > > I'm not exactly sure what the problem is that your fixing? What is the > symptom that you're seeing? svm_register_enc_region() calls sev_pin_memory() without holding kvm->lock. If userspace does multiple KVM_MEMORY_ENCRYPT_REG_REGION in parallel, it could circumvent the rlimit(RLIMIT_MEMLOCK) check.