Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4333751pxu; Mon, 12 Oct 2020 16:34:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPm3gXwbly4QuW68QiBoAwBbvMNwmPCxYfA/2aJuw7oK6M2gOq72ll42DhIbxqJEuUlSEn X-Received: by 2002:a17:906:5618:: with SMTP id f24mr29832406ejq.86.1602545698757; Mon, 12 Oct 2020 16:34:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602545698; cv=none; d=google.com; s=arc-20160816; b=TYicIVLDIMAV6AWVONgSveikrAVUsiw+Pk27AHrkGs0/hceu8T82sDiU6j3jUvfuZo XlDc+3JqcPVty2cfKR0ZvzZmE58N7uzoPrquH+O6ivDUVdYDJlpF4IWb/30dwN0leHjt 9ReIpykzomEuYRtSJCkh+XStCD9BeUQ48JZY+tBFj7g5Rcqy+q9CSdf4tgTrOJQzgSkC biJy9UAq7E144uBeJ0YTJRceMqBiuDCr4InTLdDBnoPaAkJ77sA87n65meru2K6N3Cyv NULWwVHSP0JsNgfKsoNCsqE8QeKL2TZInhYBsMQQ2qao63wV5ywMABbVzrGIsQzlq+Uv 3L6A== 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=bZx74URu/bV80Jrvkl3ELIiw7EGvNWmGbACJ3fsybyQ=; b=r5sLxz9kL4sEnMpm+m16knWj4WG/0bXyZnZrsvvzmHXbbBpiLqf6nWXJYt6rE5icVv NhVaul0SjpX6n3pTR6yJhVyYaF/91u85vtDY5VuoiJFMlyuOdWi0/A87HaqEykOtAGaL K/nx1g8L2KhgKq1ZXUSl3Mb+pP+3unwnivYTprb+h6k7sIqIkg81GB9+Z98VzR5gXDth vxpKpZLZxJy2kP28SG1he49bF9Y4uzaakdibDuYwBLB1IqJy1d+N+N9QKjHelgJiIt/C vcF44Qv2pt6Spo92RBqwxdwkKe+863K/D3IRlvZrCiPn/fn3bijo63krI582ix9hXnqR k/SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="G/3p3q8B"; 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=fail (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 n15si13937548edw.94.2020.10.12.16.34.36; Mon, 12 Oct 2020 16:34:58 -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=@kernel.org header.s=default header.b="G/3p3q8B"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389432AbgJLNoF (ORCPT + 99 others); Mon, 12 Oct 2020 09:44:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:48360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389240AbgJLNnJ (ORCPT ); Mon, 12 Oct 2020 09:43:09 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AF5E521D7F; Mon, 12 Oct 2020 13:43:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602510187; bh=cC7A/1XNwMahsxsDjfK6e58NMOTVoy/bsg2dYBlczGA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G/3p3q8BF4OIeLM8jUxg0ef8+KXwaCs1mgBCnphrz06ORt6fNuNfUhbTVggqN3BFR ERvIg4bUG15wsJbi9fUsuk32Ji1bYDKkUCt7672zLeR+qRhyyGyjPXuWSJSrEOy5nl K6DCOta8Tnqj11/UQM/ILQJ5e0HhQzCM+HA9/ddw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Philip Yang , Felix Kuehling , =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher , Sasha Levin Subject: [PATCH 5.4 47/85] drm/amdgpu: prevent double kfree ttm->sg Date: Mon, 12 Oct 2020 15:27:10 +0200 Message-Id: <20201012132635.127438168@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012132632.846779148@linuxfoundation.org> References: <20201012132632.846779148@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: Philip Yang [ Upstream commit 1d0e16ac1a9e800598dcfa5b6bc53b704a103390 ] Set ttm->sg to NULL after kfree, to avoid memory corruption backtrace: [ 420.932812] kernel BUG at /build/linux-do9eLF/linux-4.15.0/mm/slub.c:295! [ 420.934182] invalid opcode: 0000 [#1] SMP NOPTI [ 420.935445] Modules linked in: xt_conntrack ipt_MASQUERADE [ 420.951332] Hardware name: Dell Inc. PowerEdge R7525/0PYVT1, BIOS 1.5.4 07/09/2020 [ 420.952887] RIP: 0010:__slab_free+0x180/0x2d0 [ 420.954419] RSP: 0018:ffffbe426291fa60 EFLAGS: 00010246 [ 420.955963] RAX: ffff9e29263e9c30 RBX: ffff9e29263e9c30 RCX: 000000018100004b [ 420.957512] RDX: ffff9e29263e9c30 RSI: fffff3d33e98fa40 RDI: ffff9e297e407a80 [ 420.959055] RBP: ffffbe426291fb00 R08: 0000000000000001 R09: ffffffffc0d39ade [ 420.960587] R10: ffffbe426291fb20 R11: ffff9e49ffdd4000 R12: ffff9e297e407a80 [ 420.962105] R13: fffff3d33e98fa40 R14: ffff9e29263e9c30 R15: ffff9e2954464fd8 [ 420.963611] FS: 00007fa2ea097780(0000) GS:ffff9e297e840000(0000) knlGS:0000000000000000 [ 420.965144] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 420.966663] CR2: 00007f16bfffefb8 CR3: 0000001ff0c62000 CR4: 0000000000340ee0 [ 420.968193] Call Trace: [ 420.969703] ? __page_cache_release+0x3c/0x220 [ 420.971294] ? amdgpu_ttm_tt_unpopulate+0x5e/0x80 [amdgpu] [ 420.972789] kfree+0x168/0x180 [ 420.974353] ? amdgpu_ttm_tt_set_user_pages+0x64/0xc0 [amdgpu] [ 420.975850] ? kfree+0x168/0x180 [ 420.977403] amdgpu_ttm_tt_unpopulate+0x5e/0x80 [amdgpu] [ 420.978888] ttm_tt_unpopulate.part.10+0x53/0x60 [amdttm] [ 420.980357] ttm_tt_destroy.part.11+0x4f/0x60 [amdttm] [ 420.981814] ttm_tt_destroy+0x13/0x20 [amdttm] [ 420.983273] ttm_bo_cleanup_memtype_use+0x36/0x80 [amdttm] [ 420.984725] ttm_bo_release+0x1c9/0x360 [amdttm] [ 420.986167] amdttm_bo_put+0x24/0x30 [amdttm] [ 420.987663] amdgpu_bo_unref+0x1e/0x30 [amdgpu] [ 420.989165] amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu+0x9ca/0xb10 [amdgpu] [ 420.990666] kfd_ioctl_alloc_memory_of_gpu+0xef/0x2c0 [amdgpu] Signed-off-by: Philip Yang Reviewed-by: Felix Kuehling 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 f15ded1ce9057..c6a1dfe79e809 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -967,6 +967,7 @@ static int amdgpu_ttm_tt_pin_userptr(struct ttm_tt *ttm) release_sg: kfree(ttm->sg); + ttm->sg = NULL; return r; } -- 2.25.1