public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] uprobes: use kzalloc to allocate xol area
@ 2024-09-03 10:23 Sven Schnelle
  2024-09-03 12:46 ` Oleg Nesterov
  2024-09-04 11:58 ` [tip: perf/urgent] uprobes: Use " tip-bot2 for Sven Schnelle
  0 siblings, 2 replies; 4+ messages in thread
From: Sven Schnelle @ 2024-09-03 10:23 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, Liang, Kan, Masami Hiramatsu,
	Oleg Nesterov
  Cc: linux-perf-users, linux-kernel, linux-trace-kernel

To prevent unitialized members, use kzalloc to allocate
the xol area.

Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
---
 kernel/events/uprobes.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 73cc47708679..50d7949be2b1 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1489,7 +1489,7 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
 	struct xol_area *area;
 	void *insns;
 
-	area = kmalloc(sizeof(*area), GFP_KERNEL);
+	area = kzalloc(sizeof(*area), GFP_KERNEL);
 	if (unlikely(!area))
 		goto out;
 
@@ -1499,7 +1499,6 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
 		goto free_area;
 
 	area->xol_mapping.name = "[uprobes]";
-	area->xol_mapping.fault = NULL;
 	area->xol_mapping.pages = area->pages;
 	area->pages[0] = alloc_page(GFP_HIGHUSER);
 	if (!area->pages[0])
-- 
2.43.0


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

* Re: [PATCH] uprobes: use kzalloc to allocate xol area
  2024-09-03 10:23 [PATCH] uprobes: use kzalloc to allocate xol area Sven Schnelle
@ 2024-09-03 12:46 ` Oleg Nesterov
  2024-09-03 13:19   ` Peter Zijlstra
  2024-09-04 11:58 ` [tip: perf/urgent] uprobes: Use " tip-bot2 for Sven Schnelle
  1 sibling, 1 reply; 4+ messages in thread
From: Oleg Nesterov @ 2024-09-03 12:46 UTC (permalink / raw)
  To: Sven Schnelle
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, Liang, Kan, Masami Hiramatsu,
	linux-perf-users, linux-kernel, linux-trace-kernel

On 09/03, Sven Schnelle wrote:
>
> To prevent unitialized members, use kzalloc to allocate
> the xol area.
>
> Signed-off-by: Sven Schnelle <svens@linux.ibm.com>

Acked-by: Oleg Nesterov <oleg@redhat.com>

and since this looks easily exploitable, I'd sugest

Cc: stable@vger.kernel.org
Fixes: b059a453b1cf1 ("x86/vdso: Add mremap hook to vm_special_mapping")

> ---
>  kernel/events/uprobes.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
> index 73cc47708679..50d7949be2b1 100644
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
> @@ -1489,7 +1489,7 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
>  	struct xol_area *area;
>  	void *insns;
>  
> -	area = kmalloc(sizeof(*area), GFP_KERNEL);
> +	area = kzalloc(sizeof(*area), GFP_KERNEL);
>  	if (unlikely(!area))
>  		goto out;
>  
> @@ -1499,7 +1499,6 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
>  		goto free_area;
>  
>  	area->xol_mapping.name = "[uprobes]";
> -	area->xol_mapping.fault = NULL;
>  	area->xol_mapping.pages = area->pages;
>  	area->pages[0] = alloc_page(GFP_HIGHUSER);
>  	if (!area->pages[0])
> -- 
> 2.43.0
> 


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

* Re: [PATCH] uprobes: use kzalloc to allocate xol area
  2024-09-03 12:46 ` Oleg Nesterov
@ 2024-09-03 13:19   ` Peter Zijlstra
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Zijlstra @ 2024-09-03 13:19 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Sven Schnelle, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, Liang, Kan, Masami Hiramatsu,
	linux-perf-users, linux-kernel, linux-trace-kernel

On Tue, Sep 03, 2024 at 02:46:07PM +0200, Oleg Nesterov wrote:
> On 09/03, Sven Schnelle wrote:
> >
> > To prevent unitialized members, use kzalloc to allocate
> > the xol area.
> >
> > Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
> 
> Acked-by: Oleg Nesterov <oleg@redhat.com>
> 
> and since this looks easily exploitable, I'd sugest
> 
> Cc: stable@vger.kernel.org
> Fixes: b059a453b1cf1 ("x86/vdso: Add mremap hook to vm_special_mapping")

Thanks, will queue in perf/urgent

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

* [tip: perf/urgent] uprobes: Use kzalloc to allocate xol area
  2024-09-03 10:23 [PATCH] uprobes: use kzalloc to allocate xol area Sven Schnelle
  2024-09-03 12:46 ` Oleg Nesterov
@ 2024-09-04 11:58 ` tip-bot2 for Sven Schnelle
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot2 for Sven Schnelle @ 2024-09-04 11:58 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Sven Schnelle, Peter Zijlstra (Intel), Oleg Nesterov, x86,
	linux-kernel

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     e240b0fde52f33670d1336697c22d90a4fe33c84
Gitweb:        https://git.kernel.org/tip/e240b0fde52f33670d1336697c22d90a4fe33c84
Author:        Sven Schnelle <svens@linux.ibm.com>
AuthorDate:    Tue, 03 Sep 2024 12:23:12 +02:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 03 Sep 2024 16:54:02 +02:00

uprobes: Use kzalloc to allocate xol area

To prevent unitialized members, use kzalloc to allocate
the xol area.

Fixes: b059a453b1cf1 ("x86/vdso: Add mremap hook to vm_special_mapping")
Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Link: https://lore.kernel.org/r/20240903102313.3402529-1-svens@linux.ibm.com
---
 kernel/events/uprobes.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 73cc477..50d7949 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1489,7 +1489,7 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
 	struct xol_area *area;
 	void *insns;
 
-	area = kmalloc(sizeof(*area), GFP_KERNEL);
+	area = kzalloc(sizeof(*area), GFP_KERNEL);
 	if (unlikely(!area))
 		goto out;
 
@@ -1499,7 +1499,6 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
 		goto free_area;
 
 	area->xol_mapping.name = "[uprobes]";
-	area->xol_mapping.fault = NULL;
 	area->xol_mapping.pages = area->pages;
 	area->pages[0] = alloc_page(GFP_HIGHUSER);
 	if (!area->pages[0])

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

end of thread, other threads:[~2024-09-04 11:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-03 10:23 [PATCH] uprobes: use kzalloc to allocate xol area Sven Schnelle
2024-09-03 12:46 ` Oleg Nesterov
2024-09-03 13:19   ` Peter Zijlstra
2024-09-04 11:58 ` [tip: perf/urgent] uprobes: Use " tip-bot2 for Sven Schnelle

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