* [Nouveau] [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: alex000young, security, hackerzheng666, linux-kernel,
Julia.Lawall, bskeggs, daniel, 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 related [flat|nested] 5+ messages in thread
* Re: [Nouveau] [PATCH] drm/nouveau/mmu: fix use-after-free bug in nvkm_vmm_pfn_map
2022-10-29 7:46 [Nouveau] [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
2 siblings, 0 replies; 5+ messages in thread
From: Zheng Hacker @ 2022-11-02 10:35 UTC (permalink / raw)
To: Zheng Wang
Cc: alex000young, security, nouveau, linux-kernel, Julia.Lawall,
bskeggs, daniel
Friendly Ping :)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Nouveau] [PATCH] drm/nouveau/mmu: fix use-after-free bug in nvkm_vmm_pfn_map
2022-10-29 7:46 [Nouveau] [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
2 siblings, 0 replies; 5+ messages in thread
From: Lyude Paul @ 2023-03-07 0:04 UTC (permalink / raw)
To: Zheng Wang, nouveau
Cc: alex000young, security, hackerzheng666, linux-kernel,
Julia.Lawall, bskeggs, daniel
Reviewed-by: Lyude Paul <lyude@redhat.com>
Will push upstream in a moment
On Sat, 2022-10-29 at 15:46 +0800, Zheng Wang wrote:
> 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))
--
Cheers,
Lyude Paul (she/her)
Software Engineer at Red Hat
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Nouveau] [PATCH] drm/nouveau/mmu: fix use-after-free bug in nvkm_vmm_pfn_map
2022-10-29 7:46 [Nouveau] [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
2 siblings, 1 reply; 5+ messages in thread
From: Lyude Paul @ 2023-03-07 0:11 UTC (permalink / raw)
To: Zheng Wang, nouveau
Cc: alex000young, security, hackerzheng666, linux-kernel,
Julia.Lawall, bskeggs, daniel
Actually - could you resend this with dri-devel@lists.freedesktop.org added to
the cc list just to make patchwork happy?
On Sat, 2022-10-29 at 15:46 +0800, Zheng Wang wrote:
> 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))
--
Cheers,
Lyude Paul (she/her)
Software Engineer at Red Hat
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Nouveau] [PATCH] drm/nouveau/mmu: fix use-after-free bug in nvkm_vmm_pfn_map
2023-03-07 0:11 ` Lyude Paul
@ 2023-03-07 4:24 ` Zheng Hacker
0 siblings, 0 replies; 5+ messages in thread
From: Zheng Hacker @ 2023-03-07 4:24 UTC (permalink / raw)
To: Lyude Paul
Cc: alex000young, security, nouveau, linux-kernel, Julia.Lawall,
bskeggs, daniel, Zheng Wang
Hi,
This bug has been proved to be a false positive. So there is no need
to make the patch.
Thanks,
Zheng
Lyude Paul <lyude@redhat.com> 于2023年3月7日周二 08:11写道:
>
> Actually - could you resend this with dri-devel@lists.freedesktop.org added to
> the cc list just to make patchwork happy?
>
> On Sat, 2022-10-29 at 15:46 +0800, Zheng Wang wrote:
> > 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))
>
> --
> Cheers,
> Lyude Paul (she/her)
> Software Engineer at Red Hat
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-05-04 12:34 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 [Nouveau] [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;
as well as URLs for NNTP newsgroup(s).