Home Home > GIT Browse > stable
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2019-02-12 22:18:26 +0100
committerJiri Slaby <jslaby@suse.cz>2019-02-12 22:21:31 +0100
commit3eea580e6beb07e5ecdae946f1c682e155d1d5e6 (patch)
treee4b4bd55fbf1a5c10ba5e5954c540354a1e7898b
parenta5e94d69278bf756435c5114e342a2cac89e7d72 (diff)
perf/core: Don't WARN() for impossible ring-buffer sizes
-rw-r--r--patches.kernel.org/4.20.8-337-perf-core-Don-t-WARN-for-impossible-ring-buffe.patch60
-rw-r--r--series.conf1
2 files changed, 61 insertions, 0 deletions
diff --git a/patches.kernel.org/4.20.8-337-perf-core-Don-t-WARN-for-impossible-ring-buffe.patch b/patches.kernel.org/4.20.8-337-perf-core-Don-t-WARN-for-impossible-ring-buffe.patch
new file mode 100644
index 0000000000..8f088796e6
--- /dev/null
+++ b/patches.kernel.org/4.20.8-337-perf-core-Don-t-WARN-for-impossible-ring-buffe.patch
@@ -0,0 +1,60 @@
+From: Mark Rutland <mark.rutland@arm.com>
+Date: Thu, 10 Jan 2019 14:27:45 +0000
+Subject: [PATCH] perf/core: Don't WARN() for impossible ring-buffer sizes
+References: bnc#1012628
+Patch-mainline: 4.20.8
+Git-commit: 9dff0aa95a324e262ffb03f425d00e4751f3294e
+
+commit 9dff0aa95a324e262ffb03f425d00e4751f3294e upstream.
+
+The perf tool uses /proc/sys/kernel/perf_event_mlock_kb to determine how
+large its ringbuffer mmap should be. This can be configured to arbitrary
+values, which can be larger than the maximum possible allocation from
+kmalloc.
+
+When this is configured to a suitably large value (e.g. thanks to the
+perf fuzzer), attempting to use perf record triggers a WARN_ON_ONCE() in
+__alloc_pages_nodemask():
+
+ WARNING: CPU: 2 PID: 5666 at mm/page_alloc.c:4511 __alloc_pages_nodemask+0x3f8/0xbc8
+
+Let's avoid this by checking that the requested allocation is possible
+before calling kzalloc.
+
+Reported-by: Julien Thierry <julien.thierry@arm.com>
+Signed-off-by: Mark Rutland <mark.rutland@arm.com>
+Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+Reviewed-by: Julien Thierry <julien.thierry@arm.com>
+Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
+Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
+Cc: Jiri Olsa <jolsa@redhat.com>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Cc: <stable@vger.kernel.org>
+Link: https://lkml.kernel.org/r/20190110142745.25495-1-mark.rutland@arm.com
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Jiri Slaby <jslaby@suse.cz>
+---
+ kernel/events/ring_buffer.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
+index 4a9937076331..309ef5a64af5 100644
+--- a/kernel/events/ring_buffer.c
++++ b/kernel/events/ring_buffer.c
+@@ -734,6 +734,9 @@ struct ring_buffer *rb_alloc(int nr_pages, long watermark, int cpu, int flags)
+ size = sizeof(struct ring_buffer);
+ size += nr_pages * sizeof(void *);
+
++ if (order_base_2(size) >= MAX_ORDER)
++ goto fail;
++
+ rb = kzalloc(size, GFP_KERNEL);
+ if (!rb)
+ goto fail;
+--
+2.20.1
+
diff --git a/series.conf b/series.conf
index 93cdf9e13d..33cba94c68 100644
--- a/series.conf
+++ b/series.conf
@@ -1073,6 +1073,7 @@
patches.kernel.org/4.20.8-334-perf-x86-intel-uncore-Add-Node-ID-mask.patch
patches.kernel.org/4.20.8-335-perf-x86-intel-Delay-memory-deallocation-until.patch
patches.kernel.org/4.20.8-336-x86-MCE-Initialize-mce.bank-in-the-case-of-a-f.patch
+ patches.kernel.org/4.20.8-337-perf-core-Don-t-WARN-for-impossible-ring-buffe.patch
########################################################
# Build fixes that apply to the vanilla kernel too.