[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221029074654.203153-1-zyytlz.wz@163.com>
Date: Sat, 29 Oct 2022 15:46:54 +0800
From: Zheng Wang <zyytlz.wz@....com>
To: nouveau@...ts.freedesktop.org
Cc: bskeggs@...hat.com, kherbst@...hat.com, lyude@...hat.com,
airlied@...il.com, hackerzheng666@...il.com,
alex000young@...il.com, security@...nel.org, daniel@...ll.ch,
Julia.Lawall@...ia.fr, linux-kernel@...r.kernel.org,
Zheng Wang <zyytlz.wz@....com>
Subject: [PATCH] drm/nouveau/mmu: fix use-after-free bug in nvkm_vmm_pfn_map
If it failed in kzalloc, vma will be freed in nvkm_vmm_node_merge.
The later use of vma will casue use after free.
Reported-by: Zheng Wang <hackerzheng666@...il.com>
Reported-by: Zhuorao Yang <alex000young@...il.com>
Fix it by returning to upper caller as soon as error occurs.
Signed-off-by: Zheng Wang <zyytlz.wz@....com>
---
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c | 3 +--
1 file changed, 1 insertion(+), 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..04befd28f80b 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c
@@ -1272,8 +1272,7 @@ nvkm_vmm_pfn_map(struct nvkm_vmm *vmm, u8 shift, u64 addr, u64 size, u64 *pfn)
page -
vmm->func->page, map);
if (WARN_ON(!tmp)) {
- ret = -ENOMEM;
- goto next;
+ return -ENOMEM;
}
if ((tmp->mapped = map))
--
2.25.1
Powered by blists - more mailing lists