* [Nouveau] [PATCH] drm/nouveau/mmu: Fix an UAF issue in NVKM
@ 2023-01-12 7:18 korantwork
2023-02-03 9:49 ` Xinghui Li
0 siblings, 1 reply; 2+ messages in thread
From: korantwork @ 2023-01-12 7:18 UTC (permalink / raw)
To: bskeggs, kherbst, airlied, daniel
Cc: nouveau, loydlv, Xinghui Li, linux-kernel, dri-devel
From: Xinghui Li <korantli@tencent.com>
In nvkm_mem_new_host, the mem is be alloced. And mem->memory is
assigned to pmemory. During this process, the mem will be free if
the error occurs. But the *pmemory still points to the &mem->memory
which has been relased.Laterly, the nvkm_memory_unref will put the
memory which points to the pmemory again.So, we set the *pmemory to
NULL to avoid UAF issue.
Reported-by: loydlv <loydlv@tencent.com>
Signed-off-by: Xinghui Li <korantli@tencent.com>
---
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mem.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mem.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mem.c
index 92e363dbbc5a..ab30eb1fc0a3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mem.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mem.c
@@ -185,6 +185,7 @@ nvkm_mem_new_host(struct nvkm_mmu *mmu, int type, u8 page, u64 size,
} else
if ( (ret = nvif_unvers(ret, &argv, &argc, args->vn))) {
kfree(mem);
+ *pmemory = NULL;
return ret;
}
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Nouveau] [PATCH] drm/nouveau/mmu: Fix an UAF issue in NVKM
2023-01-12 7:18 [Nouveau] [PATCH] drm/nouveau/mmu: Fix an UAF issue in NVKM korantwork
@ 2023-02-03 9:49 ` Xinghui Li
0 siblings, 0 replies; 2+ messages in thread
From: Xinghui Li @ 2023-02-03 9:49 UTC (permalink / raw)
To: bskeggs, kherbst, airlied, daniel
Cc: nouveau, loydlv, Xinghui Li, linux-kernel, dri-devel
hi all
friendly ping...
<korantwork@gmail.com> 于2023年1月12日周四 15:18写道:
>
> From: Xinghui Li <korantli@tencent.com>
>
> In nvkm_mem_new_host, the mem is be alloced. And mem->memory is
> assigned to pmemory. During this process, the mem will be free if
> the error occurs. But the *pmemory still points to the &mem->memory
> which has been relased.Laterly, the nvkm_memory_unref will put the
> memory which points to the pmemory again.So, we set the *pmemory to
> NULL to avoid UAF issue.
>
> Reported-by: loydlv <loydlv@tencent.com>
> Signed-off-by: Xinghui Li <korantli@tencent.com>
> ---
> drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mem.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mem.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mem.c
> index 92e363dbbc5a..ab30eb1fc0a3 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mem.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mem.c
> @@ -185,6 +185,7 @@ nvkm_mem_new_host(struct nvkm_mmu *mmu, int type, u8 page, u64 size,
> } else
> if ( (ret = nvif_unvers(ret, &argv, &argc, args->vn))) {
> kfree(mem);
> + *pmemory = NULL;
> return ret;
> }
>
> --
> 2.31.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-04 12:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-12 7:18 [Nouveau] [PATCH] drm/nouveau/mmu: Fix an UAF issue in NVKM korantwork
2023-02-03 9:49 ` Xinghui Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).