Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1666166rdb; Tue, 20 Feb 2024 03:27:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW2u/QT0uXekfoqd5s9ARVbQWU4FH6ltH58BBdxDcRBE2NOiuUoeVk92QR2Co1LTalCaqobsKYOzILIfCGAkk+nAx+DAnQwKPtofx1Siw== X-Google-Smtp-Source: AGHT+IGEx7YFgNg3k0mM2XW8272JfXqfhwfys3di0zaiyfttaMldluQBgU01mAORNcaA0WvUwx0H X-Received: by 2002:a05:620a:34a:b0:785:ab77:fe6c with SMTP id t10-20020a05620a034a00b00785ab77fe6cmr13850624qkm.6.1708428438671; Tue, 20 Feb 2024 03:27:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708428438; cv=pass; d=google.com; s=arc-20160816; b=RelUpYzutB7rPFrxqixalLWOJ27NBkLvq+7r9vnjexlsMP7JpdL064wMxtliXwM84M hXiXUQe5xzd5mPnhorEw5OCbU7zQXuM9c5Gv+qnIWyVAqqWWdxTHTE8yHLj3dALwLH71 wMmCG+1FYAxM45hXLChvsfTApHeabd74dW699lSBm9td1KNAGXHQQfRgn+usQwAeIWBp AYu0ZFzmN0PxemuTKt/u4+AtcGfEzVM9liCffsdlctUapGvjKSsgprnxbpI6XmmC6THv VtTqUhJfko2w9J7cSG97qDvJTn6xXWmqGWpZjexB7P/Wmh8y1eFC7GPEob36t7sAWlzi 0RXg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=R8yc+b9532AQUkl/77DBZuMmfnl7ODCMrwVPiapRK9o=; fh=Ain/9B6iFmKXdmh+zNi4zsC+rc/PqwJUge9Unlwj3mc=; b=RaoQrRjxbLQiFdrDqkIQyz9sc48K9IJ7vUwOZawakf8gPxyIFdK0syiAatrs/SF+Uy eubEDpvWnFoVzfGgwfb6l2SKdQVp/qFRCY5z9qhFz8o9e7t6tXi2VhbroCj+DOEwxNoq PTlUS8WMPdLC1J+3j8YZIPiPv7sE3aLxfCFWajHkG+ivxdSNpt7kiJ729P5O1KQPO46K upIHijJ3Lqido6aydl/otCN46yJUruSW1txpNp7HO98Cnh/plzQcXhHi2CMM9dksTDxK ajm/UHzE4+9+PHWBbAHGt846/xDJacr1gBWiasaWXOPVXZCiOk0iypvcho+ClUMvkijI qSgg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r5juAYSU; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-72906-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72906-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a18-20020a05620a103200b00787225dadbdsi8076391qkk.407.2024.02.20.03.27.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 03:27:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72906-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r5juAYSU; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-72906-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72906-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 656F51C22E48 for ; Tue, 20 Feb 2024 11:27:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C8B366B52; Tue, 20 Feb 2024 11:27:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="r5juAYSU" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32D14664AD; Tue, 20 Feb 2024 11:27:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708428421; cv=none; b=lhgsQ+zt7ACnA2sg0UUcGx6Gw3mS+kTf/XfH1YKmn12+Wy4CH8wi2pqhWaoDKAOdQ79fkg7JBEq2svZQ8/8yEcwYmCaANJ56Xi9VUGnm/PmrnOEBXvKSF3u/H0iTF6sq0/CIOY9kZ4cP8cK46BCGFLK8Z33vz5V38b3Sd/5xYoA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708428421; c=relaxed/simple; bh=VddnBpFylmssPBNR8LxVy9HNAItc6vmZJuhEvw0a1cc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hkK3ol7fiS83/xXDRbRdozrmkfsDhwVEbvKyypV7dYLxm8fUL6ysXr2yHbEuwFS+iK/9bPmNyp6tYeS7pawsK830H2zUM1jYZUz5IsgyUHOEpGyV4v6RegGaZELjAbDITXx+iQ68p703OQdX8Tuc4tjYuyPxoZXk0bPB1KoDSJ4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=r5juAYSU; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0BF5C433C7; Tue, 20 Feb 2024 11:27:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708428420; bh=VddnBpFylmssPBNR8LxVy9HNAItc6vmZJuhEvw0a1cc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=r5juAYSUvCxKuNFb30xnBGP17AeDgQUJFn90heG7na3+4GVGkGHv+uzoBqj9ng/t+ EFpWosEYzWejLzvTu1Bjvd4u5MAlivbrRnLRMjMfuVHGn0lk6E5xGLqRZs6afOtc8c SYeeknMVdh8Ikld407i7xVPx2i0/h6I2pLkXnOgloW9j9ZrZa/OkqaAfpbGDOZjNpJ 726ZtnhyNIwlhqnaH68sGapgpXtajy8uqaA7IHDbJGyFupXqg/fdqFU9YA2D8CGGvs JXtfLbRWHbGtx5EOJuo+kL+Wh1rV5LD7kN3bAl4LuNNiiS6AWwXNixXdTwbJAnTXyp H2SE4ozHo1jxw== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1rcOH5-000000005Em-1y3j; Tue, 20 Feb 2024 12:26:59 +0100 Date: Tue, 20 Feb 2024 12:26:59 +0100 From: Johan Hovold To: Markus Elfring Cc: Johan Hovold , freedreno@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-phy@lists.infradead.org, linux-arm-msm@vger.kernel.org, kernel-janitors@vger.kernel.org, Andrzej Hajda , Bjorn Andersson , Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Neil Armstrong , Robert Foss , Thomas Zimmermann , Vinod Koul , LKML , Abhinav Kumar , Dmitry Baryshkov , Jernej Skrabec , Jonas Karlman , Kishon Vijay Abraham I , Konrad Dybcio , Kuogee Hsieh , Laurent Pinchart , Rob Clark , stable@vger.kernel.org Subject: Re: [PATCH 3/6] soc: qcom: pmic_glink_altmode: fix drm bridge use-after-free Message-ID: References: <20240217150228.5788-4-johan+linaro@kernel.org> <9ff4221a-7083-4cb1-abde-1690f655da8d@web.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9ff4221a-7083-4cb1-abde-1690f655da8d@web.de> On Tue, Feb 20, 2024 at 11:55:57AM +0100, Markus Elfring wrote: > … > > Specifically, the dp-hpd bridge is currently registered before all > > resources have been acquired which means that it can also be > > deregistered on probe deferrals. > > > > In the meantime there is a race window where the new aux bridge driver > > (or PHY driver previously) may have looked up the dp-hpd bridge and > > stored a (non-reference-counted) pointer to the bridge which is about to > > be deallocated. > … > > +++ b/drivers/soc/qcom/pmic_glink_altmode.c > … > > @@ -454,7 +454,7 @@ static int pmic_glink_altmode_probe(struct auxiliary_device *adev, > > alt_port->index = port; > > INIT_WORK(&alt_port->work, pmic_glink_altmode_worker); > > > > - alt_port->bridge = drm_dp_hpd_bridge_register(dev, to_of_node(fwnode)); > > + alt_port->bridge = devm_drm_dp_hpd_bridge_alloc(dev, to_of_node(fwnode)); > > if (IS_ERR(alt_port->bridge)) { > > fwnode_handle_put(fwnode); > > return PTR_ERR(alt_port->bridge); > … > > The function call “fwnode_handle_put(fwnode)” is used in multiple if branches. > https://elixir.bootlin.com/linux/v6.8-rc5/source/drivers/soc/qcom/pmic_glink_altmode.c#L435 > > I suggest to add a jump target so that a bit of exception handling > can be better reused at the end of this function implementation. Markus, as people have told you repeatedly, just stop with these comments. You're not helping, in fact, you are actively harmful to the kernel community as you are wasting people's time. Johan