Re: [PATCH] uprobes: use vm_special_mapping close() functionality

From: Linus Torvalds
Date: Tue Sep 03 2024 - 15:13:05 EST


On Tue, 3 Sept 2024 at 02:09, Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
>
> but with or without this fix __create_xol_area() also needs
>
> area->xol_mapping.mremap = NULL;

I think the whole thing needs to be zeroed out.

It was always horribly buggy. The close thing just made it more
*obviously* buggy, because closing a vma is a lot more common than
mremap'ing it.

Either use kzalloc(), or do a proper initializer something like this:

- area->xol_mapping.name = "[uprobes]";
- area->xol_mapping.fault = NULL;
- area->xol_mapping.pages = area->pages;
+ area->xol_mapping = (struct vm_special_mapping) {
+ .name = "[uprobes]",
+ .pages = area->pages,
+ .close = uprobe_clear_state,
+ };

which should initialize the struct vm_special_mapping fully.

Linus