lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 5 May 2020 14:31:44 +0200
From:   Joerg Roedel <jroedel@...e.de>
To:     Steven Rostedt <rostedt@...dmis.org>
Cc:     Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
        linux-kernel <linux-kernel@...r.kernel.org>,
        Ingo Molnar <mingo@...nel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Peter Zijlstra <peterz@...radead.org>,
        Borislav Petkov <bp@...en8.de>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Shile Zhang <shile.zhang@...ux.alibaba.com>,
        Andy Lutomirski <luto@...capital.net>,
        "Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        Tzvetomir Stoyanov <tz.stoyanov@...il.com>
Subject: [PATCH] tracing: Call vmalloc_sync_mappings() after alloc_percpu()

On Mon, May 04, 2020 at 03:10:06PM -0400, Steven Rostedt wrote:
> I'm fine with adding it to the tracing code (with that ridiculous
> comment! ;-)
> 
> I'll even tag is as stable, but again, it's uncertain what commit that it
> "fixes".

Okay, so here it is. It fixes the issue for me and doesn't cause any
lockdep splats on my machine. I am not sure how far this needs to be
backported via stable, so I didn't specify it. Same with a Fixes tag.
Oh, and I added your comment :-) (which makes up most of the added
lines, so feel free to change authorship to you).

Regards,

	Joerg

>From a265290761dc9d87d35892dc821fd0f5c99f8b34 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@...e.de>
Date: Tue, 5 May 2020 14:17:57 +0200
Subject: [PATCH] tracing: Call vmalloc_sync_mappings() after alloc_percpu()

Tracing code allocates percpu memory which is touched when trace events
happen. When the events happen in the page-fault handler and per-cpu
memory needs to be faulted in, the page-fault on per-cpu memory might
never complete.

Call vmalloc_sync_mappings() after allocating the runtime per-cpu
buffers to make sure they are mapped when the page-fault handler tries
to access them.

This is not a nice solution, but the best fix until the
vmalloc_sync_mappings/unmappings() interface can be ripped out of the
kernel.

Cc: stable@...r.kernel.org
Signed-off-by: Joerg Roedel <jroedel@...e.de>
---
 kernel/trace/trace.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 8d2b98812625..0fc56063fcca 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -8525,6 +8525,19 @@ static int allocate_trace_buffers(struct trace_array *tr, int size)
 	 */
 	allocate_snapshot = false;
 #endif
+
+	/*
+	 * Because of some magic with the way alloc_percpu() works on
+	 * x86_64, we need to synchronize the pgd of all the tables,
+	 * otherwise the trace events that happen in x86_64 page fault
+	 * handlers can't cope with accessing the chance that a
+	 * alloc_percpu()'d memory might be touched in the page fault trace
+	 * event. Oh, and we need to audit all alloc_percpu() and vmalloc()
+	 * calls in tracing, because something might get triggered within a
+	 * page fault trace event!
+	 */
+	vmalloc_sync_mappings();
+
 	return 0;
 }
 
-- 
2.12.3



Powered by blists - more mailing lists