[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240911094401.GA19080@redhat.com>
Date: Wed, 11 Sep 2024 11:44:25 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Sven Schnelle <svens@...ux.ibm.com>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: Michael Ellerman <mpe@...erman.id.au>,
Masami Hiramatsu <mhiramat@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>, Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
"Liang, Kan" <kan.liang@...ux.intel.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org
Subject: Re: [PATCH] uprobes: use vm_special_mapping close() functionality
On 09/03, Sven Schnelle wrote:
>
> +static void uprobe_clear_state(const struct vm_special_mapping *sm, struct vm_area_struct *vma)
> +{
> + struct xol_area *area = container_of(vma->vm_private_data, struct xol_area, xol_mapping);
> +
> + mutex_lock(&delayed_uprobe_lock);
> + delayed_uprobe_remove(NULL, vma->vm_mm);
> + mutex_unlock(&delayed_uprobe_lock);
> +
> + if (!area)
> + return;
> +
> + put_page(area->pages[0]);
> + kfree(area->bitmap);
> + kfree(area);
> +}
> +
> static struct xol_area *__create_xol_area(unsigned long vaddr)
> {
> struct mm_struct *mm = current->mm;
> @@ -1481,6 +1500,7 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
>
> area->xol_mapping.name = "[uprobes]";
> area->xol_mapping.fault = NULL;
> + area->xol_mapping.close = uprobe_clear_state;
Ah, no, we can't do this :/
A malicious application can munmap() its "[uprobes]" vma and free
area/pages/bitmap. If this application hits the uprobe breakpoint after
that it will use the freed memory.
And no, "mm->uprobes_state.xol_area = NULL" in uprobe_clear_state() won't
help. Say, another thread can sleep on area.wq when munmap() is called.
Sorry, I should have realized that immediately, but I didn't :/
Andrew, this is uprobes-use-vm_special_mapping-close-functionality.patch
in mm-stable
Oleg.
Powered by blists - more mailing lists