From patchwork Mon Oct 24 11:29:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8890 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp433650wru; Mon, 24 Oct 2022 05:50:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4qvHMO7TFM8lpVkEqjlrLx7fqC3IhOG+r2XU5kT2oBJYMU3ih8AUW4w50CwMK6UvFcrG16 X-Received: by 2002:a17:907:7294:b0:7a9:8a22:74d4 with SMTP id dt20-20020a170907729400b007a98a2274d4mr2614582ejc.139.1666615806536; Mon, 24 Oct 2022 05:50:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615806; cv=none; d=google.com; s=arc-20160816; b=j4bw7fQjVpD6OABclgg+RcgyTVQBI2tMj8XLdwlVssMIRB/+3+TvN6BYj7W3Qo3g+M SNEDXIpLhYGc3j8acJs/Zhj0K7TSpaNJ9DIACt5iMh7Xk6ww/z2Tfrvv1j4QL1PUqyxp AJ/pkpqm0di0pHbAGShN8SJGkeEEg76qceS8yZiaOS1dvva7R+6YasFDWaG4FPUiL2lU scsLepKYqVXqB1YlXBs4F/c80hRkPr4EryRWOeIYkSHPQjyUY4WybN0tjClD773K1Mkc qz37c1u622/dgjRJblToYMqz+Vfa4441s71105HLFqK8FkCV3JZd3rzeYsbLbZ+nP9Qf j3oQ== 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=o32l6BKZYdLZ6S5J+7PckgRhd7KCOB8Wm+23asHvIRg=; b=ggNCMe01tBf20K4YJuwz2ilRl229LO551klOO3dGRSecDZzgGE0Hqjq8HBPuXpCuU8 YUh1Ia4a+QDdbE+B23DD4g8JukMmMXUnLUzPEOkpv9Av/+NwaqdaQsI6gC0flSGm8QtX vCcik8X+5hyOSDB4kGvuboi6QjluEIdY2ktao63qE8P19zl3utCcJ6rCNjjXW2eKuLiz rMin+smlyDbDhzrCNa9HWHT7kfFrxCY/wDowahObsBlbUwxRj64JkESg3s1dGqWmrXCw aTce7fNkFif11+j8J2vGNkdqALdK0iGsr0x4uekGMuMgXsDZAXtdDN4NtHvdvzckSE24 Bdaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=r3RrXqRP; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb6-20020a170907160600b0078dcee0cf13si31207456ejc.561.2022.10.24.05.49.40; Mon, 24 Oct 2022 05:50:06 -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=@linuxfoundation.org header.s=korg header.b=r3RrXqRP; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234220AbiJXMsD (ORCPT + 99 others); Mon, 24 Oct 2022 08:48:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231810AbiJXMnL (ORCPT ); Mon, 24 Oct 2022 08:43:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 656907F0AC; Mon, 24 Oct 2022 05:09:03 -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 179CC6128E; Mon, 24 Oct 2022 12:07:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A6C1C433D7; Mon, 24 Oct 2022 12:07:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613245; bh=yT4I2SIf6prmOQ5TA2r4Sm95rU2zqmrlMEcsNxaDwgM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r3RrXqRPzlxM9pdJHzgbzcDs3K1eK22R6nWAREfmOF/nrQxoBbYsuqGwdNfGNI7LO UFKqKTH3te7j57yDYZcwALeke/hPFsi1XfUa4tjea0yo1CMiklguYb1JMCiFRaX/ZX cF8tWkebIImraliiPEEyKitYB0p5cKogUggNac7s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jianglei Nie , Lyude Paul , Thierry Reding Subject: [PATCH 5.4 056/255] drm/nouveau: fix a use-after-free in nouveau_gem_prime_import_sg_table() Date: Mon, 24 Oct 2022 13:29:26 +0200 Message-Id: <20221024113004.362252810@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747573336408433707?= X-GMAIL-MSGID: =?utf-8?q?1747573336408433707?= From: Jianglei Nie commit 540dfd188ea2940582841c1c220bd035a7db0e51 upstream. nouveau_bo_init() is backed by ttm_bo_init() and ferries its return code back to the caller. On failures, ttm will call nouveau_bo_del_ttm() and free the memory.Thus, when nouveau_bo_init() returns an error, the gem object has already been released. Then the call to nouveau_bo_ref() will use the freed "nvbo->bo" and lead to a use-after-free bug. We should delete the call to nouveau_bo_ref() to avoid the use-after-free. Signed-off-by: Jianglei Nie Reviewed-by: Lyude Paul Signed-off-by: Lyude Paul Fixes: 019cbd4a4feb ("drm/nouveau: Initialize GEM object before TTM object") Cc: Thierry Reding Cc: # v5.4+ Link: https://patchwork.freedesktop.org/patch/msgid/20220705132546.2247677-1-niejianglei2021@163.com Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/nouveau/nouveau_prime.c | 1 - 1 file changed, 1 deletion(-) --- a/drivers/gpu/drm/nouveau/nouveau_prime.c +++ b/drivers/gpu/drm/nouveau/nouveau_prime.c @@ -90,7 +90,6 @@ struct drm_gem_object *nouveau_gem_prime ret = nouveau_bo_init(nvbo, size, align, flags, sg, robj); if (ret) { - nouveau_bo_ref(NULL, &nvbo); obj = ERR_PTR(ret); goto unlock; }