Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1611334pxj; Fri, 18 Jun 2021 10:45:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuX43VadLu5tA4ovkgdw9pzCOb1K08yYbIhhYByotqe1dn2K8aW9gs67XhccE+iY+Wy0PC X-Received: by 2002:a05:6402:4404:: with SMTP id y4mr6812533eda.282.1624038345240; Fri, 18 Jun 2021 10:45:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624038345; cv=none; d=google.com; s=arc-20160816; b=QRy4bDXZdY3YjxFCVyrVHmVtoUEhIwe7hnzD07v0lqCrlcqf4ZW6Sh3bTvidj2HZ5n 4dDNpfK8kCiDjnn1MkAECpxTqZGDPAIrbeEaap/WoyFTYUdUxxtZNM2zDr8Icg/6BB0p HORQ52n6AeRZXw6q8HmAX6eFM4PSUp2KQiDjEeXgYFMCk0CZ4k0Wd3K19CzwxcYANpVa BXkgJTHYV+y3I1lU8ZCf4KY0u3D2R2MtGw4Sum6Hm4ASd4oUc3FQuF5WdngvZd/zPf7A Om3zQzDj79XKVESpFt3riU9nOstIzyAwN389pRls++KeuFgsUsBKSYVnPk+yQO9KcYZO NeoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=F2dAGmKW8kyqzfOBnPTiGbC4j4BffTV73vtj7G7zjaQ=; b=dqillmyXU48/mfwmROSZFPg/S8CYlMSqEjFLHBVefYi65Ja+DaSCl9pvhCL5iYfGw6 pj00QQhzk0CEa5rU9TOKybrfXYGwXZ5p2+Al/Sc4BUtY2Uw/JcK3m6WvcpMw5nz8JYbA dMpbGfWAPvGvpkKvaFKpRqkqcaDnFyWURbGa0F/fSBAF6IUsz/LU1PjYbTk9uIUJLxn6 rvRK4O7hOkx0WnKbE+sEr2BbAJ8Kv9Y1weKJiUzO4mC9gchJVqU/Q8Q3sWpMfj5ErcdZ zOcOreKqUaMcJ86gUGFGmjMTTYW8YYdT3mZmn8YUFljJDx+G2iQBL3HClPBvrYyjfs3v yJ/Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f25si3093592ejh.718.2021.06.18.10.45.21; Fri, 18 Jun 2021 10:45:45 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234612AbhFROmd (ORCPT + 99 others); Fri, 18 Jun 2021 10:42:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:39244 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234595AbhFROm2 (ORCPT ); Fri, 18 Jun 2021 10:42:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EF63061260; Fri, 18 Jun 2021 14:40:15 +0000 (UTC) Date: Fri, 18 Jun 2021 15:40:13 +0100 From: Catalin Marinas To: Steven Price Cc: Marc Zyngier , Will Deacon , James Morse , Julien Thierry , Suzuki K Poulose , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Dave Martin , Mark Rutland , Thomas Gleixner , qemu-devel@nongnu.org, Juan Quintela , "Dr. David Alan Gilbert" , Richard Henderson , Peter Maydell , Andrew Jones Subject: Re: [PATCH v16 1/7] arm64: mte: Handle race when synchronising tags Message-ID: <20210618144013.GE16116@arm.com> References: <20210618132826.54670-1-steven.price@arm.com> <20210618132826.54670-2-steven.price@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210618132826.54670-2-steven.price@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 18, 2021 at 02:28:20PM +0100, Steven Price wrote: > mte_sync_tags() used test_and_set_bit() to set the PG_mte_tagged flag > before restoring/zeroing the MTE tags. However if another thread were to > race and attempt to sync the tags on the same page before the first > thread had completed restoring/zeroing then it would see the flag is > already set and continue without waiting. This would potentially expose > the previous contents of the tags to user space, and cause any updates > that user space makes before the restoring/zeroing has completed to > potentially be lost. > > Since this code is run from atomic contexts we can't just lock the page > during the process. Instead implement a new (global) spinlock to protect > the mte_sync_page_tags() function. > > Fixes: 34bfeea4a9e9 ("arm64: mte: Clear the tags when a page is mapped in user-space with PROT_MTE") > Reviewed-by: Catalin Marinas > Signed-off-by: Steven Price Although I reviewed this patch, I think we should drop it from this series and restart the discussion with the Chromium guys on what/if they need PROT_MTE with MAP_SHARED. It currently breaks if you have two PROT_MTE mappings but if they are ok with only one of the mappings being PROT_MTE, I'm happy to just document it. Not sure whether subsequent patches depend on it though. -- Catalin