Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1689677rwb; Sat, 19 Nov 2022 01:27:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf5FU0yNGpqYk0567avP+dxupKTojGfJsyhgAoGg4pxfV7yDBD9nkB24+r8Pjj2BO7b/m4X+ X-Received: by 2002:aa7:9097:0:b0:56c:674a:16f0 with SMTP id i23-20020aa79097000000b0056c674a16f0mr11845703pfa.10.1668850076891; Sat, 19 Nov 2022 01:27:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668850076; cv=none; d=google.com; s=arc-20160816; b=enTs7M5iJO6fPoYtN+i2eYZ4/k2OtTd3nOICu+B8PthDjGtWGkYJEl/qUPqxxCrCMt 1DcOaswkD89qTbSr08QDusOuxZ2r0ylr9X0LSrsnN9CIrV54Z82VIdm9t5dTTtZn1Ps4 2LSR2sLXpASzdBtEs+wwXgqZytkvgLJzYhuBrcwSusV8eFR2RJc9jn5rJVgBtA0MTx2o wy/uGmjybQSGweyPb5jnBHo95BYdw1z7OozXIc9uNF/MNzQYNszf1jWI+ZwURqFSVGXS HSrHqf2W24T6F0EjoUhQYwDQvDtLXJ+8fDE6Qk33mV1KO5f4euKQgnwXulCvnKaN5/Nr r53g== 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=Zb98RNsub6/w0ud2LWwi51iY7RICLGemUviTnmi1WyQ=; b=NZcYeu1H8aGlZjMEdbRWdb90Si9DvLyYl3tG5dYU9m+V/6un33jBNFpUo2kn/rmXIy q/O+CqeMoB6is7hGfgz+gvG7wIhgrEC8+h7S8VWqrSqUQ58XQ13iOo45p5oWQ4/ullcL HRiW90sg013GZ4jlRJuPYYkAxURusQlrFaczcHaIRmsUa+ybVtXjZ9oehMr4bqmVJg3q 3q2kXxQiPrj+T/Dmi2Fm4SEITOxhgx3id2PPFW21GzCbYapUXdleevoo07U4dtUwlppb HnpCTQkxWS+FQsFF2muRwbvozCwVVS4dnm3js+k9hD9sj9QBy3ds43yeeWASvqR/7LtB GyaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@8bytes.org header.s=default header.b=pxqePUhE; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w62-20020a638241000000b004701dd79afbsi6097904pgd.495.2022.11.19.01.27.45; Sat, 19 Nov 2022 01:27:56 -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=@8bytes.org header.s=default header.b=pxqePUhE; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232568AbiKSJSb (ORCPT + 91 others); Sat, 19 Nov 2022 04:18:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbiKSJSa (ORCPT ); Sat, 19 Nov 2022 04:18:30 -0500 Received: from mail.8bytes.org (mail.8bytes.org [IPv6:2a01:238:42d9:3f00:e505:6202:4f0c:f051]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 357A1271A for ; Sat, 19 Nov 2022 01:18:27 -0800 (PST) Received: from 8bytes.org (p200300c27724780086ad4f9d2505dd0d.dip0.t-ipconnect.de [IPv6:2003:c2:7724:7800:86ad:4f9d:2505:dd0d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.8bytes.org (Postfix) with ESMTPSA id 765282A02A4; Sat, 19 Nov 2022 10:18:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=8bytes.org; s=default; t=1668849506; bh=Vt5L0VElcFLbmhh0x4LVugTf29bcONLPlCjevjgvFSg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pxqePUhEdc0C9R5uhSi+uSJ/g85ULckh94wlPP27t6X8nuCvyvAbpxUIWRuoahfuu eO7zx1vYItI4B4YLKAFyGoTjN3jl8oPfhNj3hiS4jdlr7j2/SSq56ihOmpnizwj9JC ZDxF8CW4kvQDq7qD+2LlGw16aJqTA4Xkw8FB/qCsBGq6I+JG2miXnT/kA3v7NnMx0R wlNqj27wNFIwt+f2Gcp5q90fWxR6IY7+dczbcH7seymKYp1REx45BgSfsVi5YXlI9x VQxRI4RZa4v0JIxw4wT0eEv5YQqpKM47wIcpp/qPGa2B1VZoJw0RyOq92GRsXeoCPG yr65UEbrXrAPg== Date: Sat, 19 Nov 2022 10:18:25 +0100 From: Joerg Roedel To: Robin Murphy Cc: will@kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Brian Norris Subject: Re: [PATCH] iommu: Avoid races around device probe Message-ID: References: <1946ef9f774851732eed78760a78ec40dbc6d178.1667591503.git.robin.murphy@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1946ef9f774851732eed78760a78ec40dbc6d178.1667591503.git.robin.murphy@arm.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Fri, Nov 04, 2022 at 07:51:43PM +0000, Robin Murphy wrote: > We currently have 3 different ways that __iommu_probe_device() may be > called, but no real guarantee that multiple callers can't tread on each > other, especially once asynchronous driver probe gets involved. It would > likely have taken a fair bit of luck to hit this previously, but commit > 57365a04c921 ("iommu: Move bus setup to IOMMU device registration") ups > the odds since now it's not just omap-iommu that may trigger multiple > bus_iommu_probe() calls in parallel if probing asynchronously. > > Add a lock to ensure we can't try to double-probe a device, and also > close some possible race windows to make sure we're truly robust against > trying to double-initialise a group via two different member devices. > > Reported-by: Brian Norris > Signed-off-by: Robin Murphy > --- > drivers/iommu/iommu.c | 28 ++++++++++++++++++++++------ > 1 file changed, 22 insertions(+), 6 deletions(-) Applied, thanks Robin.