From: Greg Kroah-Hartman <gregkh@linuxfoundation•org>
To: linux-kernel@vger•kernel.org
Cc: Sasha Levin <sashal@kernel•org>,
Ravi Bangoria <ravi.bangoria@linux•ibm.com>,
maddy@linux•vnet.ibm.com, acme@kernel•org,
Vince Weaver <vincent.weaver@maine•edu>,
"Peter Zijlstra \(Intel\)" <peterz@infradead•org>,
Greg Kroah-Hartman <gregkh@linuxfoundation•org>,
Linus Torvalds <torvalds@linux-foundation•org>,
linuxppc-dev@lists•ozlabs.org, stable@vger•kernel.org,
Arnaldo Carvalho de Melo <acme@redhat•com>,
Alexander Shishkin <alexander.shishkin@linux•intel.com>,
Stephane Eranian <eranian@google•com>,
Thomas Gleixner <tglx@linutronix•de>,
Jiri Olsa <jolsa@redhat•com>, Ingo Molnar <mingo@kernel•org>
Subject: [PATCH 4.14 243/343] perf/ioctl: Add check for the sample_period value
Date: Fri, 24 Jan 2020 10:31:01 +0100 [thread overview]
Message-ID: <20200124092952.083914150@linuxfoundation.org> (raw)
In-Reply-To: <20200124092919.490687572@linuxfoundation.org>
From: Ravi Bangoria <ravi.bangoria@linux•ibm.com>
[ Upstream commit 913a90bc5a3a06b1f04c337320e9aeee2328dd77 ]
perf_event_open() limits the sample_period to 63 bits. See:
0819b2e30ccb ("perf: Limit perf_event_attr::sample_period to 63 bits")
Make ioctl() consistent with it.
Also on PowerPC, negative sample_period could cause a recursive
PMIs leading to a hang (reported when running perf-fuzzer).
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux•ibm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead•org>
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: Peter Zijlstra <peterz@infradead•org>
Cc: Stephane Eranian <eranian@google•com>
Cc: Thomas Gleixner <tglx@linutronix•de>
Cc: Vince Weaver <vincent.weaver@maine•edu>
Cc: acme@kernel•org
Cc: linuxppc-dev@lists•ozlabs.org
Cc: maddy@linux•vnet.ibm.com
Cc: mpe@ellerman•id.au
Fixes: 0819b2e30ccb ("perf: Limit perf_event_attr::sample_period to 63 bits")
Link: https://lkml.kernel.org/r/20190604042953.914-1-ravi.bangoria@linux.ibm.com
Signed-off-by: Ingo Molnar <mingo@kernel•org>
Signed-off-by: Sasha Levin <sashal@kernel•org>
---
kernel/events/core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index ea4f3f7a0c6f3..2ac73b4cb8a93 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -4762,6 +4762,9 @@ static int perf_event_period(struct perf_event *event, u64 __user *arg)
if (perf_event_check_period(event, value))
return -EINVAL;
+ if (!event->attr.freq && (value & (1ULL << 63)))
+ return -EINVAL;
+
event_function_call(event, __perf_event_period, &value);
return 0;
--
2.20.1
parent reply other threads:[~2020-01-24 10:06 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20200124092919.490687572@linuxfoundation.org>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200124092952.083914150@linuxfoundation.org \
--to=gregkh@linuxfoundation$(echo .)org \
--cc=acme@kernel$(echo .)org \
--cc=acme@redhat$(echo .)com \
--cc=alexander.shishkin@linux$(echo .)intel.com \
--cc=eranian@google$(echo .)com \
--cc=jolsa@redhat$(echo .)com \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linuxppc-dev@lists$(echo .)ozlabs.org \
--cc=maddy@linux$(echo .)vnet.ibm.com \
--cc=mingo@kernel$(echo .)org \
--cc=peterz@infradead$(echo .)org \
--cc=ravi.bangoria@linux$(echo .)ibm.com \
--cc=sashal@kernel$(echo .)org \
--cc=stable@vger$(echo .)kernel.org \
--cc=tglx@linutronix$(echo .)de \
--cc=torvalds@linux-foundation$(echo .)org \
--cc=vincent.weaver@maine$(echo .)edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox