From: Ravi Bangoria <hidden> Date: 2019-05-11 02:42:40
Add a check for sample_period value sent from userspace. Negative
value does not make sense. And in powerpc arch code this could cause
a recursive PMI leading to a hang (reported when running perf-fuzzer).
Signed-off-by: Ravi Bangoria <redacted>
---
kernel/events/core.c | 3 +++
1 file changed, 3 insertions(+)
From: Ravi Bangoria <hidden> Date: 2019-05-11 02:42:48
Consider a scenario where user creates two events:
1st event:
attr.sample_type |= PERF_SAMPLE_BRANCH_STACK;
attr.branch_sample_type = PERF_SAMPLE_BRANCH_ANY;
fd = perf_event_open(attr, 0, 1, -1, 0);
This sets cpuhw->bhrb_filter to 0 and returns valid fd.
2nd event:
attr.sample_type |= PERF_SAMPLE_BRANCH_STACK;
attr.branch_sample_type = PERF_SAMPLE_BRANCH_CALL;
fd = perf_event_open(attr, 0, 1, -1, 0);
It overrides cpuhw->bhrb_filter to -1 and returns with error.
Now if power_pmu_enable() gets called by any path other than
power_pmu_add(), ppmu->config_bhrb(-1) will set mmcra to -1.
Signed-off-by: Ravi Bangoria <redacted>
---
arch/powerpc/perf/core-book3s.c | 6 ++++--
arch/powerpc/perf/power8-pmu.c | 3 +++
arch/powerpc/perf/power9-pmu.c | 3 +++
3 files changed, 10 insertions(+), 2 deletions(-)
From: Ravi Bangoria <hidden> Date: 2019-05-11 02:47:32
On 5/11/19 8:12 AM, Ravi Bangoria wrote:
Consider a scenario where user creates two events:
1st event:
attr.sample_type |= PERF_SAMPLE_BRANCH_STACK;
attr.branch_sample_type = PERF_SAMPLE_BRANCH_ANY;
fd = perf_event_open(attr, 0, 1, -1, 0);
This sets cpuhw->bhrb_filter to 0 and returns valid fd.
2nd event:
attr.sample_type |= PERF_SAMPLE_BRANCH_STACK;
attr.branch_sample_type = PERF_SAMPLE_BRANCH_CALL;
fd = perf_event_open(attr, 0, 1, -1, 0);
It overrides cpuhw->bhrb_filter to -1 and returns with error.
Now if power_pmu_enable() gets called by any path other than
power_pmu_add(), ppmu->config_bhrb(-1) will set mmcra to -1.
Signed-off-by: Ravi Bangoria <redacted>
Consider a scenario where user creates two events:
1st event:
attr.sample_type |= PERF_SAMPLE_BRANCH_STACK;
attr.branch_sample_type = PERF_SAMPLE_BRANCH_ANY;
fd = perf_event_open(attr, 0, 1, -1, 0);
This sets cpuhw->bhrb_filter to 0 and returns valid fd.
2nd event:
attr.sample_type |= PERF_SAMPLE_BRANCH_STACK;
attr.branch_sample_type = PERF_SAMPLE_BRANCH_CALL;
fd = perf_event_open(attr, 0, 1, -1, 0);
It overrides cpuhw->bhrb_filter to -1 and returns with error.
Now if power_pmu_enable() gets called by any path other than
power_pmu_add(), ppmu->config_bhrb(-1) will set mmcra to -1.
From: Michael Ellerman <hidden> Date: 2019-05-25 00:54:51
On Sat, 2019-05-11 at 02:42:17 UTC, Ravi Bangoria wrote:
Consider a scenario where user creates two events:
1st event:
attr.sample_type |= PERF_SAMPLE_BRANCH_STACK;
attr.branch_sample_type = PERF_SAMPLE_BRANCH_ANY;
fd = perf_event_open(attr, 0, 1, -1, 0);
This sets cpuhw->bhrb_filter to 0 and returns valid fd.
2nd event:
attr.sample_type |= PERF_SAMPLE_BRANCH_STACK;
attr.branch_sample_type = PERF_SAMPLE_BRANCH_CALL;
fd = perf_event_open(attr, 0, 1, -1, 0);
It overrides cpuhw->bhrb_filter to -1 and returns with error.
Now if power_pmu_enable() gets called by any path other than
power_pmu_add(), ppmu->config_bhrb(-1) will set mmcra to -1.
Signed-off-by: Ravi Bangoria <redacted>
Reviewed-by: Madhavan Srinivasan <redacted>
From: Peter Zijlstra <peterz@infradead.org> Date: 2019-05-13 07:42:37
On Sat, May 11, 2019 at 08:12:16AM +0530, Ravi Bangoria wrote:
quoted hunk
Add a check for sample_period value sent from userspace. Negative
value does not make sense. And in powerpc arch code this could cause
a recursive PMI leading to a hang (reported when running perf-fuzzer).
Signed-off-by: Ravi Bangoria <redacted>
---
kernel/events/core.c | 3 +++
1 file changed, 3 insertions(+)
From: Peter Zijlstra <peterz@infradead.org> Date: 2019-05-13 08:56:45
On Mon, May 13, 2019 at 09:42:13AM +0200, Peter Zijlstra wrote:
On Sat, May 11, 2019 at 08:12:16AM +0530, Ravi Bangoria wrote:
quoted
Add a check for sample_period value sent from userspace. Negative
value does not make sense. And in powerpc arch code this could cause
a recursive PMI leading to a hang (reported when running perf-fuzzer).
Signed-off-by: Ravi Bangoria <redacted>
---
kernel/events/core.c | 3 +++
1 file changed, 3 insertions(+)
From: Ravi Bangoria <hidden> Date: 2019-05-13 10:07:16
On 5/13/19 2:26 PM, Peter Zijlstra wrote:
On Mon, May 13, 2019 at 09:42:13AM +0200, Peter Zijlstra wrote:
quoted
On Sat, May 11, 2019 at 08:12:16AM +0530, Ravi Bangoria wrote:
quoted
Add a check for sample_period value sent from userspace. Negative
value does not make sense. And in powerpc arch code this could cause
a recursive PMI leading to a hang (reported when running perf-fuzzer).
Signed-off-by: Ravi Bangoria <redacted>
---
kernel/events/core.c | 3 +++
1 file changed, 3 insertions(+)
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2019-05-28 09:50:42
Ravi Bangoria [off-list ref] writes:
On 5/13/19 2:26 PM, Peter Zijlstra wrote:
quoted
On Mon, May 13, 2019 at 09:42:13AM +0200, Peter Zijlstra wrote:
quoted
On Sat, May 11, 2019 at 08:12:16AM +0530, Ravi Bangoria wrote:
quoted
Add a check for sample_period value sent from userspace. Negative
value does not make sense. And in powerpc arch code this could cause
a recursive PMI leading to a hang (reported when running perf-fuzzer).
Signed-off-by: Ravi Bangoria <redacted>
---
kernel/events/core.c | 3 +++
1 file changed, 3 insertions(+)
From: Ravi Bangoria <hidden> Date: 2019-06-04 04:30:19
perf_event_open() limits the sample_period to 63 bits. See
commit 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 <redacted>
---
kernel/events/core.c | 3 +++
1 file changed, 3 insertions(+)
From: Ravi Bangoria <hidden> Date: 2019-06-17 08:38:44
Peter / mpe,
Is the v2 looks good? If so, can anyone of you please pick this up.
On 6/4/19 9:59 AM, Ravi Bangoria wrote:
quoted hunk
perf_event_open() limits the sample_period to 63 bits. See
commit 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 <redacted>
---
kernel/events/core.c | 3 +++
1 file changed, 3 insertions(+)
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2019-06-18 12:28:26
Ravi Bangoria [off-list ref] writes:
Peter / mpe,
Is the v2 looks good? If so, can anyone of you please pick this up.
I usually wouldn't take it, it's generic perf code. Unless
peter/ingo/acme tell me otherwise.
It's sort of a bug fix for 0819b2e30ccb, should it have a fixes and/or
stable tag?
Fixes: 0819b2e30ccb ("perf: Limit perf_event_attr::sample_period to 63 bits")
Cc: stable@vger.kernel.org # v3.15+
cheers
On 6/4/19 9:59 AM, Ravi Bangoria wrote:
quoted
perf_event_open() limits the sample_period to 63 bits. See
commit 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 <redacted>
---
kernel/events/core.c | 3 +++
1 file changed, 3 insertions(+)