Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2707948pxj; Mon, 31 May 2021 08:45:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymE/Us86eJ8pGadOUKPfATzSzJBNjFXS8MLYN+Lz32qXhan7lCJRwtFzJB6GQbql+uiw+a X-Received: by 2002:aa7:cc10:: with SMTP id q16mr26772600edt.53.1622475915760; Mon, 31 May 2021 08:45:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622475915; cv=none; d=google.com; s=arc-20160816; b=bCXq6jE4WLXYCMRJH/klPWhlOv2wnpx3nCuLle0oKYzuVFQcuCVDcwBWk7jVdMzb3T Ppyo3wgLFsxCbT4vrOypql5vylH8KLruU9QcmFt6yc0pXolVlIWSnMw2z++dEED43vp0 8Qf1thdQJzFUmCVIcd1pW1t2u7aunBCJnoeB8zc/5rc3/2RuFZEVlQ40C2roaVJ3h9iH 0DO8BfNUSIxH9JXa+1o6ZqEiJo0AIrXjbT4u3c/75JOJk4cdW6ta/aB83MOEEvntzj8K x7G+JZGFFKAd3uPNejrJss8ZT0vacSu28w9JmCTe+ofBcEZxQ2zHNpVjFQnImSTptPAl A04Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZyOLYDsWm38UbIuPQXX2wFZkWHg+2nG4dEncIGUaqcg=; b=nH2W3pCELIT9wXVENWYzomB89WeFZdV54MM7fTUPdxlRpx5X6taeFJi8da0sxjwN3K SlEbJAqgOXZyb4pzcRnvqfrYN6hV9+nfZGIKoPXwj6202hKHNEapXZw6ck62L1tS7RoT Qx9dNknScucbXAKwvlqNCwyyjUPJJLXEdoHz+VXKQ0hlsDXVIT33F+0atanJ/3ReDaAO ucGU6wXMIBP1hHRgeYA7+Ne5zI80Nl9ATcaFDBVMBVp+TJLMqJdnqhmjnsHw/AUXVq2Z TSUGJw8PN3aRm6WN1o+yAZAZ2E2RIgh2KogwnobqRlwqhF7TXwqwMtTHcWFXC3lzCSc4 ZItg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JkvAtTeB; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z16si2795766ejx.706.2021.05.31.08.44.52; Mon, 31 May 2021 08:45:15 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JkvAtTeB; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232707AbhEaPpc (ORCPT + 99 others); Mon, 31 May 2021 11:45:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:48840 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233767AbhEaOZZ (ORCPT ); Mon, 31 May 2021 10:25:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DBA4B61A30; Mon, 31 May 2021 13:46:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468797; bh=RTjny6HL8e3577Pf5+XgvUc+oCBngcpPP1oip52yf+E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JkvAtTeBIVZTGjdtVUcBQ2ybwdCZXmnzhOQ1vC1wXHD1zyQbd25ZlLb1nC2/va9Qo +vz7OSlluY2Ym5BrJIvMPM1N5+1X9GPdFt42Ehpcgu0I+M43nA+G2qIvPl1fZ3CWH/ G0s8ZqR70M76iZU+6othe11mjQVWJa52eCk6oF4o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, xinhui pan , =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher , Sasha Levin Subject: [PATCH 5.4 133/177] drm/amdgpu: Fix a use-after-free Date: Mon, 31 May 2021 15:14:50 +0200 Message-Id: <20210531130652.533300639@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130647.887605866@linuxfoundation.org> References: <20210531130647.887605866@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: xinhui pan [ Upstream commit 1e5c37385097c35911b0f8a0c67ffd10ee1af9a2 ] looks like we forget to set ttm->sg to NULL. Hit panic below [ 1235.844104] general protection fault, probably for non-canonical address 0x6b6b6b6b6b6b7b4b: 0000 [#1] SMP DEBUG_PAGEALLOC NOPTI [ 1235.989074] Call Trace: [ 1235.991751] sg_free_table+0x17/0x20 [ 1235.995667] amdgpu_ttm_backend_unbind.cold+0x4d/0xf7 [amdgpu] [ 1236.002288] amdgpu_ttm_backend_destroy+0x29/0x130 [amdgpu] [ 1236.008464] ttm_tt_destroy+0x1e/0x30 [ttm] [ 1236.013066] ttm_bo_cleanup_memtype_use+0x51/0xa0 [ttm] [ 1236.018783] ttm_bo_release+0x262/0xa50 [ttm] [ 1236.023547] ttm_bo_put+0x82/0xd0 [ttm] [ 1236.027766] amdgpu_bo_unref+0x26/0x50 [amdgpu] [ 1236.032809] amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu+0x7aa/0xd90 [amdgpu] [ 1236.040400] kfd_ioctl_alloc_memory_of_gpu+0xe2/0x330 [amdgpu] [ 1236.046912] kfd_ioctl+0x463/0x690 [amdgpu] Signed-off-by: xinhui pan Reviewed-by: Christian König Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 91e3a87b1de8..58e14d3040f0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1300,6 +1300,7 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm) if (gtt && gtt->userptr) { amdgpu_ttm_tt_set_user_pages(ttm, NULL); kfree(ttm->sg); + ttm->sg = NULL; ttm->page_flags &= ~TTM_PAGE_FLAG_SG; return; } -- 2.30.2