mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/nouveau/mmu: fix use-after-free bug in nvkm_vmm_pfn_map
@ 2022-10-29  7:46 Zheng Wang
  2022-11-02 10:35 ` Zheng Hacker
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Zheng Wang @ 2022-10-29  7:46 UTC (permalink / raw)
  To: nouveau
  Cc: bskeggs, kherbst, lyude, airlied, hackerzheng666, alex000young,
	security, daniel, Julia.Lawall, linux-kernel, Zheng Wang

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@gmail.com>
Reported-by: Zhuorao Yang <alex000young@gmail.com>

Fix it by returning to upper caller as soon as error occurs.

Signed-off-by: Zheng Wang <zyytlz.wz@163.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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-03-07  4:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-29  7:46 [PATCH] drm/nouveau/mmu: fix use-after-free bug in nvkm_vmm_pfn_map Zheng Wang
2022-11-02 10:35 ` Zheng Hacker
2023-03-07  0:04 ` Lyude Paul
2023-03-07  0:11 ` Lyude Paul
2023-03-07  4:24   ` Zheng Hacker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®