Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp418042pxb; Wed, 24 Feb 2021 05:52:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJw6oI5cni9HEzTC7GiUNEQcbfrkvb1NxaEHp+qNnIuG/9PZ7+DfaCZSVIf1wxMjp7X4vUBV X-Received: by 2002:aa7:da52:: with SMTP id w18mr27217115eds.219.1614174774757; Wed, 24 Feb 2021 05:52:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614174774; cv=none; d=google.com; s=arc-20160816; b=f4lEUX8VjADJd8VxBVTmm+VVG1QnL9wTr0r+jXsbtXoUUDxzpcDpGI4K8c5m/CIrSY L2mnyw5gazS1ag797vpacpXbbkj133xPCnxqq6Sv2eLFbB7XZVeEGkcqa0f7B+7U5RgL b64/gbdeQjqbeSAQQYHPPw7DeASh7VQ+1FSwXh3k4GMk7pyWPdkLzZEc/UZUdq0S2LW3 oygVppe2C9EPgTUNX53pB2Ex46wen2MR4jnuTDb4lsJ18mMMF046m24zLIRMhhMLvz3I EcObPrppZoyWKCtMyXlYlN5N7iZyCB3cpfps6VNrfhR7jEQVBKIE9yGQ2TQje80DrTlX dAjQ== 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=AYnldpfGnDEUVYnCUdIysjI6eFemcv3ikK2HpHW7H+I=; b=HN6kR5pvYf8P9jDZQD9GWva3VIX5VaOfyPcDDanrsJGp0hH21bLosfB5UsgMqZZNZ1 JEfuseOSMNKWGQX7sswlCN77HCeBk7rjhjYijvKlXjtFu6nTSNpEa8o54WA4avJ+bhOT 4JXI5IvgS9Dv8hopuYHc2Sk60mHnjWDD3+WpVWC4zWs7uGc5TMGn/0sb065aLsQSoJMZ OS28JxnyMu6yvAg1RRwxi0ejo0Y/Q2kdv2s8YS70NAoRE7/R2TAQjqSSC4CR365JjvR6 gDkHvQCESzw6mQLdWchk8KrNFefN+cAz4Ud86nYEw/p6fSx2Mo0fgTmrzSr4fXzoKeuO WMOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q1xQynQR; 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 i10si1366453ejd.325.2021.02.24.05.51.40; Wed, 24 Feb 2021 05:52:54 -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=Q1xQynQR; 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 S237665AbhBXNmL (ORCPT + 99 others); Wed, 24 Feb 2021 08:42:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:58430 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234494AbhBXNE5 (ORCPT ); Wed, 24 Feb 2021 08:04:57 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 23CA064F69; Wed, 24 Feb 2021 12:53:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614171239; bh=a9Wb6AuQMN/7zK98kdFvu3TDKGA+YbUdRLoskq2N3Tw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q1xQynQRU3P5Ks8JOdTRp2LH5X3CCK54Et4Kp6SmWrOy8jd3yC6XaIB6sr2eEpT6P 0mNbXL23LMfuux/fddFet+sEq1Up19mJqu5t75BGGkUr/rVcFfonyTahuAWdaFDliL pomYmOpKCewyUhsqP8YRr+tv1yzfign/XPX9QfRtUmMB2blOAEq+oSEunqJ7hmaMhn Ho99BbsJreLFOQ1gtvV42xAgWaaJVP7t/Pu23Xl3ZAqAv4OSgK3Vsdu/v/33JlfUp8 LE8n+5/4+31qrcTf58UwL6s4UJvdB25xYyGob6yKH0w1Nxv4OM6dGOiLrE7AQbnVKB GzZR2xwfMvhkQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Tian Tao , Thomas Zimmermann , Sasha Levin , dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.4 14/40] drm/hisilicon: Fix use-after-free Date: Wed, 24 Feb 2021 07:53:14 -0500 Message-Id: <20210224125340.483162-14-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210224125340.483162-1-sashal@kernel.org> References: <20210224125340.483162-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tian Tao [ Upstream commit c855af2f9c5c60760fd1bed7889a81bc37d2591d ] Fix the problem of dev being released twice. ------------[ cut here ]------------ refcount_t: underflow; use-after-free. WARNING: CPU: 75 PID: 15700 at lib/refcount.c:28 refcount_warn_saturate+0xd4/0x150 CPU: 75 PID: 15700 Comm: rmmod Tainted: G E 5.10.0-rc3+ #3 Hardware name: Huawei TaiShan 200 (Model 2280)/BC82AMDDA, BIOS 0.88 07/24/2019 pstate: 40400009 (nZcv daif +PAN -UAO -TCO BTYPE=--) pc : refcount_warn_saturate+0xd4/0x150 lr : refcount_warn_saturate+0xd4/0x150 sp : ffff2028150cbc00 x29: ffff2028150cbc00 x28: ffff2028150121c0 x27: 0000000000000000 x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000003 x23: 0000000000000000 x22: ffff2028150cbc90 x21: ffff2020038a30a8 x20: ffff2028150cbc90 x19: ffff0020cd938020 x18: 0000000000000010 x17: 0000000000000000 x16: 0000000000000000 x15: ffffffffffffffff x14: ffff2028950cb88f x13: ffff2028150cb89d x12: 0000000000000000 x11: 0000000005f5e0ff x10: ffff2028150cb800 x9 : 00000000ffffffd0 x8 : 75203b776f6c6672 x7 : ffff800011a6f7c8 x6 : 0000000000000001 x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000000 x2 : ffff202ffe2f9dc0 x1 : ffffa02fecf40000 x0 : 0000000000000026 Call trace: refcount_warn_saturate+0xd4/0x150 devm_drm_dev_init_release+0x50/0x70 devm_action_release+0x20/0x30 release_nodes+0x13c/0x218 devres_release_all+0x80/0x170 device_release_driver_internal+0x128/0x1f0 driver_detach+0x6c/0xe0 bus_remove_driver+0x74/0x100 driver_unregister+0x34/0x60 pci_unregister_driver+0x24/0xd8 hibmc_pci_driver_exit+0x14/0xe858 [hibmc_drm] __arm64_sys_delete_module+0x1fc/0x2d0 el0_svc_common.constprop.3+0xa8/0x188 do_el0_svc+0x80/0xa0 el0_sync_handler+0x8c/0xb0 el0_sync+0x15c/0x180 CPU: 75 PID: 15700 Comm: rmmod Tainted: G E 5.10.0-rc3+ #3 Hardware name: Huawei TaiShan 200 (Model 2280)/BC82AMDDA, BIOS 0.88 07/24/2019 Call trace: dump_backtrace+0x0/0x208 show_stack+0x2c/0x40 dump_stack+0xd8/0x10c __warn+0xac/0x128 report_bug+0xcc/0x180 bug_handler+0x24/0x78 call_break_hook+0x80/0xa0 brk_handler+0x28/0x68 do_debug_exception+0x9c/0x148 el1_sync_handler+0x7c/0x128 el1_sync+0x80/0x100 refcount_warn_saturate+0xd4/0x150 devm_drm_dev_init_release+0x50/0x70 devm_action_release+0x20/0x30 release_nodes+0x13c/0x218 devres_release_all+0x80/0x170 device_release_driver_internal+0x128/0x1f0 driver_detach+0x6c/0xe0 bus_remove_driver+0x74/0x100 driver_unregister+0x34/0x60 pci_unregister_driver+0x24/0xd8 hibmc_pci_driver_exit+0x14/0xe858 [hibmc_drm] __arm64_sys_delete_module+0x1fc/0x2d0 el0_svc_common.constprop.3+0xa8/0x188 do_el0_svc+0x80/0xa0 el0_sync_handler+0x8c/0xb0 el0_sync+0x15c/0x180 ---[ end trace 00718630d6e5ff18 ]--- Signed-off-by: Tian Tao Acked-by: Thomas Zimmermann Link: https://patchwork.freedesktop.org/patch/msgid/1607941973-32287-1-git-send-email-tiantao6@hisilicon.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c index c103005b0a33e..a34ef5ec7d429 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c @@ -376,7 +376,6 @@ static void hibmc_pci_remove(struct pci_dev *pdev) drm_dev_unregister(dev); hibmc_unload(dev); - drm_dev_put(dev); } static struct pci_device_id hibmc_pci_table[] = { -- 2.27.0