Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp765271pxb; Wed, 3 Feb 2021 18:00:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPIousVhxY3yDrpN0we2Wt80LARNYKyNpRiZKr8hb8DooF1I81z9LTfNIQ3eB3mCq4y92K X-Received: by 2002:a17:906:b217:: with SMTP id p23mr6070854ejz.126.1612404045158; Wed, 03 Feb 2021 18:00:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612404045; cv=none; d=google.com; s=arc-20160816; b=vfU5bj8Vnbu4IFGqNkXXd8JsPfEFFvklNKALEDOqpCyy/FnP/P2s8j1WLJNTLiwAfY GUajG/3zYfhVIabir2E3v1IOBgnEA0jMRpMHCKkq1KyA7R7oDdGb2gsFNV2awZuKotAV Ifz76ppghWIho3D66aVu352HxUIgVuOErEUfK7vwKBjTP84iZql1wYJDubqhn5FGB9zo rlZrQYt3t/3o2Zj39C/YJij8KUpKLSR4efnK5ZDJ4lHaXk2X/MWe6WKv9Vz/BvWrsM2Q 08D3rqErxUlkqjZbLIjP0gzRQRfUg68/sQdwZIGlrJjMSvL26LulXOF69OFVk7GcXeuc Guag== 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=8xMx06kXnz9AehE2/tjS9GJvPYHQBlhn4bXqnwQtMtU=; b=W6NA9MWBL81rbuMlxGAoBk3Aoq9Y37paDsrh2SbSaUx2ccNeZuv1e0a6WAkmQgahDQ 7GD9T2xXh1KUCTKUeWXQuGiV1IMTDf8OIx/O4vgwl0EagBSIr3mKYtEla06SQzt4eFcx eD1j5VIG4Sc+TEl6aHlQjQAKQeM6702yiNvh/xM45n8rhMvvxqwr5fZF/ataru8yYK5Y K6ETVxlvjIPu62+d38siFspVtLcEkrRoYQeb8nV9yh6QHO4AJBOh+m7En1RaMeRR3W0M 0XSQwbkB3nH8AZ0LYf921P7TbRqGqDwe9hlBc8NHjPYFt9Ozn4MP7qU2BRbhvoWqQYWH qViQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=B+WwauRu; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f22si2373152edw.413.2021.02.03.18.00.19; Wed, 03 Feb 2021 18:00:45 -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=@kernel.org header.s=k20201202 header.b=B+WwauRu; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232203AbhBCVzb (ORCPT + 99 others); Wed, 3 Feb 2021 16:55:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:42392 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229897AbhBCVz3 (ORCPT ); Wed, 3 Feb 2021 16:55:29 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A29A664F6C; Wed, 3 Feb 2021 21:54:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612389289; bh=Qiz8MokgGBvGwkrU9ihniujcsOk/Nkcte47kBrXcYkI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=B+WwauRu+ZWiuFTJALuFrywN0e9jHN59j51oBYr/Vmcf8Jibicp09+UjpgHkpLAf2 bBh7dN/pixZMx3Fn5PeNVvn4phhOc5jnIC5Saav6I8qPfEAF2GYVoP557i+jtnnK9X QWiQ6zXquX8PGxbfOT/OVtZAUNURamgC0QSNrtS236dekOPZtlrpWwI0c7LI7Ztqjb 5oqMYfrtnGgcFu8zRsDp59pNKkNKZx4mB/4GYbtTMRS2MhjMw1cZpcVjcDYeAnAjFs WmfA47qr2hMbyIodJI/8I4nBhorsekjO0qibvaUKpDqcRI61jSJfobbHSdAf8dyKs8 d80ZhK1pL2Q6g== Date: Wed, 3 Feb 2021 23:54:42 +0200 From: Jarkko Sakkinen To: Dave Hansen Cc: linux-sgx@vger.kernel.org, stable@vger.kernel.org, Sean Christopherson , Haitao Huang , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Jethro Beekman , linux-kernel@vger.kernel.org Subject: Re: [PATCH v5] x86/sgx: Fix use-after-free in sgx_mmu_notifier_release() Message-ID: References: <20210128125823.18660-1-jarkko@kernel.org> <9dd2a962-2328-8784-9aed-b913502e1102@intel.com> <8df884af-825e-bae0-f0c3-c3e97f48d138@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8df884af-825e-bae0-f0c3-c3e97f48d138@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 03, 2021 at 07:46:48AM -0800, Dave Hansen wrote: > On 1/30/21 11:20 AM, Jarkko Sakkinen wrote: > ... > > Example scenario would such that all removals "side-channel" through > > the notifier callback. Then mmu_notifier_unregister() gets called > > exactly zero times. No MMU notifier srcu sync would be then happening. > > > > NOTE: There's bunch of other examples, I'm just giving one. > > Could you flesh this out a bit? I don't quite understand the scenario > from what you describe above. > > In any case, I'm open to other implementations that fix the race we know > about. If you think you have a better fix, I'm happy to review it and > make sure it closes the other race. I'll bake up a new patch. Generally speaking, I think why this has been so difficult, is because of a chicken-egg-problem. The whole issue should be sorted when a new entry is first added to the mm_list, i.e. increase the refcount for each added entry. /Jarkko