Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6327128rwn; Tue, 13 Sep 2022 02:31:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR6VRJRT1Gu0iw/ZxLE4O4Wk7sScirDdPUbgftlQB2xzn6ZXoA3ZrDNskTnA1TZyxslt+gpR X-Received: by 2002:a17:907:31c3:b0:770:852b:71a2 with SMTP id xf3-20020a17090731c300b00770852b71a2mr20706735ejb.557.1663061463312; Tue, 13 Sep 2022 02:31:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663061463; cv=none; d=google.com; s=arc-20160816; b=UIWFdrgKZ84UtuV83ItZrSvXPnRiKlyBxUyVDPGGDKCfZL/F63gju7PS7nsy8gXZLQ B6/BOGBHKrtQ4hnf9JB87H5kMdf21dH4+SIUv1IyVEFKzPZ6WZmi7mp8EyDgob2w6QvG jP0zp9fpAXrtTZzxTkrdDc8nbaqAJER62ox1UEz3afP9m+Mhkw9mxxVaYILwlPs3LQk+ /2F08EvFO7lJqkYdc6sbG1DVcrmUZyFq8rHDIDKNxw0o6fCjvEyzBpMK4Rx8t0XIR2wv +mePXqwxtMv8LPpKsAW0d4MZgQ06R2pQefO+Uk6Mg0Xx6/pcKadvoKRzteEUez2ZaAmp 96mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=a+GRfduLUlmDJ1iBbsPK2dWy33E7mB9eGRGi/KzzYOs=; b=E2WFKkxhda5SDbOuovtoOBZ1+GFVnpKQnAhExf9gp8Mk2CV8oWIYkrpwp7k3B1ih+6 bNNJY4kcs20Wmo4Q0bRnD8+cqd6xTg2zmihOf/88IQ+GMtdbgEDpGq3Ke3e+7m98m1wl OO2CIQzrmZpdvNC5kWRqp+nI8AhCpmvR7fxfQnCWoSIdZpmoB6LAF7coN+awS698aFO2 rMrfrpVLVrJik1D7s0c0yP8orWybGu439m0KJled6wBe+Yl6v1xhzmace8liIGnUP2tU 0h+qLNpTZul3APmRtpXCyHC9M6ZekOBqZhoW8A9R8MJy3anx3Om6GgxnNrvmXn6IS74i JzXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RSs6PLSg; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h6-20020a50c386000000b004479eacc9acsi8069052edf.222.2022.09.13.02.30.38; Tue, 13 Sep 2022 02:31:03 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=RSs6PLSg; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231469AbiIMI60 (ORCPT + 99 others); Tue, 13 Sep 2022 04:58:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230350AbiIMI6W (ORCPT ); Tue, 13 Sep 2022 04:58:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72DBE3C8DC; Tue, 13 Sep 2022 01:58:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 10F7361345; Tue, 13 Sep 2022 08:58:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6ED99C433C1; Tue, 13 Sep 2022 08:58:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663059499; bh=Oc6WoDRTsN2YXtrJHeii3slQl1T1Cqsqme8eYe4nODc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RSs6PLSgaXtiUrS+7L3CAiMNRarG7ovHpUdoaMrDyOxfuEhuJq4IvZaJxSG0VA8wP LF8Av6IYbPm4fcPfmgyfKm+UyZ/1MU5qQ7hPBykZgCvzA/urBF/MGeIJ2yznpuZp3f 2AwPXnyDGxht13kbECWivAeNYPUEwJQ5hzTMyMoUB//KIw3dhzxAsR3pfB42+XAVFM qPF4UUS+nYU0u1n+ZlSX54aR7g5PhBq2O976DLAb2lntuNWzImI677R4m5Rjp+MJ4r 58WxVskC9wWrbzDO2hJFZAfv/r6xtwzxVkVhVm7KN1e5WVUz+HECgZemuef7b73qYg N8v0uiKWhSKEg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oY1kI-0002H2-Cp; Tue, 13 Sep 2022 10:58:18 +0200 From: Johan Hovold To: Douglas Anderson , Dmitry Baryshkov , Rob Clark , Abhinav Kumar Cc: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Daniel Vetter , Sean Paul , Stephen Boyd , Bjorn Andersson , Manivannan Sadhasivam , Kuogee Hsieh , Steev Klimaszewski , dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH v2 01/10] drm/msm: fix use-after-free on probe deferral Date: Tue, 13 Sep 2022 10:53:11 +0200 Message-Id: <20220913085320.8577-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220913085320.8577-1-johan+linaro@kernel.org> References: <20220913085320.8577-1-johan+linaro@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 The bridge counter was never reset when tearing down the DRM device so that stale pointers to deallocated structures would be accessed on the next tear down (e.g. after a second late bind deferral). Given enough bridges and a few probe deferrals this could currently also lead to data beyond the bridge array being corrupted. Fixes: d28ea556267c ("drm/msm: properly add and remove internal bridges") Fixes: a3376e3ec81c ("drm/msm: convert to drm_bridge") Cc: stable@vger.kernel.org # 3.12 Reviewed-by: Dmitry Baryshkov Signed-off-by: Johan Hovold --- drivers/gpu/drm/msm/msm_drv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 391d86b54ded..d254fe2507ec 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -241,6 +241,7 @@ static int msm_drm_uninit(struct device *dev) for (i = 0; i < priv->num_bridges; i++) drm_bridge_remove(priv->bridges[i]); + priv->num_bridges = 0; pm_runtime_get_sync(dev); msm_irq_uninstall(ddev); -- 2.35.1