Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp11916447rwl; Tue, 3 Jan 2023 06:37:25 -0800 (PST) X-Google-Smtp-Source: AMrXdXtH458jwls61ywgpmnXFeUgG3Dj2lcLSTmjTUZBidwnMTBNUg975bUSPYLtuzlq3fnsFLg6 X-Received: by 2002:a17:902:f08a:b0:189:efe8:1e with SMTP id p10-20020a170902f08a00b00189efe8001emr43312106pla.68.1672756645056; Tue, 03 Jan 2023 06:37:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672756645; cv=none; d=google.com; s=arc-20160816; b=CumTwslSYVhtiVMRrl8W4CGRKgcHc0hheM1srdRUql+GRRCz0sGJBSVjCEsC+frTXT RJYSxNzud1X3EEok9S14jZ8cAaESuZYdR6VIoOCMB35hh09juJWmWtObLWABtl+mzTaF vwxWtz7IXJrZXshPXhfwhPs3ftzQDFc7jgkOAv9/MeN8iDsO/oUqaTWcgCzuSWXO6IY/ DmaEcY3+nyTVIVbF4PUwoj0OywetwIq0Jpt61ez//2m6ZpfCx0lTFEtcuVHUdufUrWST gvlQ3rZWb3ZriNxAAfzmlw4jwq+8JSXYmrM6ZzNrSwE3c+aOSc69sMm37cIDHg8ASO8E ZJJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=HEJD9eeEtIBqJlvqHVyEk27kWefx2FkPEKnJNr3qq0U=; b=KxcIFtANrVTd+F2RsptBKJVSz6LrfF94a6IVAgQK3yM+Y01K242TJI8Ru2WzP1mQgs dF71IQv4V5iL6kNbFfY2CMqV20AfyfcanGaN5GY0UTfdgptkGzHZZMq7r9CexgAucAs2 MmHv6kGvkvr7N5mPw2BAUc67H6vbK9UDqEDhWsHWeiOHF18amdVCmJJ4FVMTuzdFetac lg6Epz1QnWL2DOdE43XP6sB/rIFyb0aFvBeV6wyNp7j1cKFDdeiCvcKOrv9CJOWSlcqx IM8o/39AHYoH7RZXySIIuhZiqlRScZ9gcckHsMPK8RD4sAohVsnsBz70yXystWdDhHoQ 4hsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=ewGcxHKi; dkim=neutral (no key) header.i=@suse.de; 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=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 84-20020a630257000000b00477ff64b022si34374816pgc.19.2023.01.03.06.37.17; Tue, 03 Jan 2023 06:37:25 -0800 (PST) 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=@suse.de header.s=susede2_rsa header.b=ewGcxHKi; dkim=neutral (no key) header.i=@suse.de; 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=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233486AbjACOIC (ORCPT + 60 others); Tue, 3 Jan 2023 09:08:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237654AbjACOIA (ORCPT ); Tue, 3 Jan 2023 09:08:00 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE80810578 for ; Tue, 3 Jan 2023 06:07:58 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 795883E6FD; Tue, 3 Jan 2023 14:07:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1672754876; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HEJD9eeEtIBqJlvqHVyEk27kWefx2FkPEKnJNr3qq0U=; b=ewGcxHKiW6jKTbH2EHIxeZ3AKvkgDmLc7QtmhsL/yUnNFFUNDjZbRqd0WWct2t/5a9wPJf dA+ahj5H4DdfLfIiATZG56JfEYYgWPFwWYvrrRl8I6YXKBqa8rrCcaU3wDq6EWz4vxb6pH Re/u45a/nvpZwudM5kli/yclwSGx9q0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1672754876; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HEJD9eeEtIBqJlvqHVyEk27kWefx2FkPEKnJNr3qq0U=; b=QeHoTZGFuEAc3aJBQH6PZzROsqxCqDNr6gAE/1r4bkinizU/plN1tLdM5Vok77Z2lro8zp +Kn/QwIzf4ZNWJAg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 41F5E1392B; Tue, 3 Jan 2023 14:07:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SuaVDrw2tGMkPQAAMHmgww (envelope-from ); Tue, 03 Jan 2023 14:07:56 +0000 Date: Tue, 03 Jan 2023 15:07:55 +0100 Message-ID: <87mt6zr9s4.wl-tiwai@suse.de> From: Takashi Iwai To: bskeggs@redhat.com Cc: Zheng Wang , alex000young@gmail.com, security@kernel.org, kherbst@redhat.com, nouveau@lists.freedesktop.org, hackerzheng666@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/nouveau/mmu: fix Use after Free bug in nvkm_vmm_node_split In-Reply-To: <20221230072758.443644-1-zyytlz.wz@163.com> References: <20221230072758.443644-1-zyytlz.wz@163.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 On Fri, 30 Dec 2022 08:27:58 +0100, Zheng Wang wrote: > > Here is a function call chain. > nvkm_vmm_pfn_map->nvkm_vmm_pfn_split_merge->nvkm_vmm_node_split > If nvkm_vma_tail return NULL in nvkm_vmm_node_split, it will > finally invoke nvkm_vmm_node_merge->nvkm_vmm_node_delete, which > will free the vma. However, nvkm_vmm_pfn_map didn't notice that. > It goes into next label and UAF happens. > > Fix it by returning the return-value of nvkm_vmm_node_merge > instead of NULL. > > Signed-off-by: Zheng Wang FWIW, CVE-2023-0030 has been assigned to this bug. It's a question whether it really deserves as a security issue, but a bug is a bug... Ben, could you review this please? thanks, Takashi > --- > drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c > index ae793f400ba1..84d6fc87b2e8 100644 > --- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c > +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c > @@ -937,8 +937,8 @@ nvkm_vmm_node_split(struct nvkm_vmm *vmm, > if (vma->size != size) { > struct nvkm_vma *tmp; > if (!(tmp = nvkm_vma_tail(vma, vma->size - size))) { > - nvkm_vmm_node_merge(vmm, prev, vma, NULL, vma->size); > - return NULL; > + tmp = nvkm_vmm_node_merge(vmm, prev, vma, NULL, vma->size); > + return tmp; > } > tmp->part = true; > nvkm_vmm_node_insert(vmm, tmp); > -- > 2.25.1 >