Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp662640pxj; Tue, 18 May 2021 11:16:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxG+0BHUmdP0am6HcrL/15N5rXYXkHax8hV0Kpip+GFopdKc4QLtL9MK2Tnc9OzvzIaiLM5 X-Received: by 2002:a17:906:6549:: with SMTP id u9mr7141294ejn.506.1621361812859; Tue, 18 May 2021 11:16:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621361812; cv=none; d=google.com; s=arc-20160816; b=ohJjKIywpQQ6R8PA18TXmEcMCzLLrrg1/ORaqJdxX6nYq8NiuYweXiWHQb0CqIkNOx HWJzpj/ZY+BIwWPKDIN9W74/6Tm19wkygbUTkZ7JIuvkzUo+9kqt4ZFC5QrCYJGWLyf3 lNoXRvt30OWwjRuijDFaUq5gJOV/SwiexbotYZcIGyCKWJtpmEqu7BFE8MfO/eWOdhFQ mfH9I0zjR5i0dA0qD80gbTaQ4BcShKJIWUy5JoF9eG0jF8xujry5r9VOGfaMJg4V/Fes yH6tOTHJiQIWKCl3+PaHY84ruXYRqi86cCP9pp0jaNeqENaUJMAiYzpqmiHPaf9EZoxZ FEuw== 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=2sIY8QAbI+3A18H77WnamTmbQQF75Vy3flAcMx6iUPI=; b=MSPXzYvvCQjsa4PjJnepKyYpbtu84niooTENlbC8i/+33q/PjDKKnU43PeNmmEjNwX Gc60iFZLYNGw5tpIvCqkl7si0P8MT7d1PVwIUj1FP5dRhOQ+9+ZXVUnSoMH+ry3cqs6G cPNIoqa1Jp9wORIjjRYYBfqPaXewxlMyowhWnf3kfz4cKeBB1jCA6otVZBbkHLI5M2z7 MA6dqsm0dYs5DuVzn+lF7RoSHqq/1PxU3/vo2LlJWRqZadgN3gv7VUP0YlVQb7LXzhCY ehGLp9m1hae+5IhmHc4fiI9bS7hYHsoDNgxmWiLnfeGZDV3dlKHrl1e8e4Y6tg1Zr2ge Qstw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1xLRsG3b; 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 en9si11617421ejc.84.2021.05.18.11.16.29; Tue, 18 May 2021 11:16:52 -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=1xLRsG3b; 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 S1345455AbhEQQM4 (ORCPT + 99 others); Mon, 17 May 2021 12:12:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:36422 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245503AbhEQPsm (ORCPT ); Mon, 17 May 2021 11:48:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8DEBE61951; Mon, 17 May 2021 14:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262717; bh=ZMPdg8c/xRnNPF8aSdEzeYilHDUSfxsID6p4SkBLYVw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1xLRsG3bCRV8iW7OvJudoXAvRHKNs5wZ6/q0qg4igm8LJtUNofAmluKRCxBBcAL9p 7PqxY27Lb1BU0XLgkt7opSlusyzKcVAsdGGw6SYFlBS4cBWmJEEZb6A1VGn7j3uhq7 gtteA6yPmd8i2hgmKIFtK7E3BVw0ct8c4qu6rGKY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lv Yunlong , Matthew Auld , Jani Nikula Subject: [PATCH 5.10 277/289] drm/i915/gt: Fix a double free in gen8_preallocate_top_level_pdp Date: Mon, 17 May 2021 16:03:22 +0200 Message-Id: <20210517140314.463780862@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@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: Lv Yunlong commit ea995218dddba171fecd05496c69617c5ef3c5b8 upstream. Our code analyzer reported a double free bug. In gen8_preallocate_top_level_pdp, pde and pde->pt.base are allocated via alloc_pd(vm) with one reference. If pin_pt_dma() failed, pde->pt.base is freed by i915_gem_object_put() with a reference dropped. Then free_pd calls free_px() defined in intel_ppgtt.c, which calls i915_gem_object_put() to put pde->pt.base again. As pde->pt.base is protected by refcount, so the second put will not free pde->pt.base actually. But, maybe it is better to remove the first put? Fixes: 82adf901138cc ("drm/i915/gt: Shrink i915_page_directory's slab bucket") Signed-off-by: Lv Yunlong Reviewed-by: Matthew Auld Signed-off-by: Matthew Auld Link: https://patchwork.freedesktop.org/patch/msgid/20210426124340.4238-1-lyl2019@mail.ustc.edu.cn (cherry picked from commit ac69496fe65cca0611d5917b7d232730ff605bc7) Signed-off-by: Jani Nikula Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/i915/gt/gen8_ppgtt.c | 1 - 1 file changed, 1 deletion(-) --- a/drivers/gpu/drm/i915/gt/gen8_ppgtt.c +++ b/drivers/gpu/drm/i915/gt/gen8_ppgtt.c @@ -628,7 +628,6 @@ static int gen8_preallocate_top_level_pd err = pin_pt_dma(vm, pde->pt.base); if (err) { - i915_gem_object_put(pde->pt.base); free_pd(vm, pde); return err; }