Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fixes from Ingo Molnar: "Two fixes on the kernel side: fix an over-eager condition that failed larger perf ring-buffer sizes, plus fix crashes in the Intel BTS code for a corner case, found by fuzzing" * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf/core: Fix impossible ring-buffer sizes warning perf/x86: Add check_period PMU callback
This commit is contained in:
@@ -4963,6 +4963,11 @@ static void __perf_event_period(struct perf_event *event,
|
||||
}
|
||||
}
|
||||
|
||||
static int perf_event_check_period(struct perf_event *event, u64 value)
|
||||
{
|
||||
return event->pmu->check_period(event, value);
|
||||
}
|
||||
|
||||
static int perf_event_period(struct perf_event *event, u64 __user *arg)
|
||||
{
|
||||
u64 value;
|
||||
@@ -4979,6 +4984,9 @@ static int perf_event_period(struct perf_event *event, u64 __user *arg)
|
||||
if (event->attr.freq && value > sysctl_perf_event_sample_rate)
|
||||
return -EINVAL;
|
||||
|
||||
if (perf_event_check_period(event, value))
|
||||
return -EINVAL;
|
||||
|
||||
event_function_call(event, __perf_event_period, &value);
|
||||
|
||||
return 0;
|
||||
@@ -9391,6 +9399,11 @@ static int perf_pmu_nop_int(struct pmu *pmu)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int perf_event_nop_int(struct perf_event *event, u64 value)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static DEFINE_PER_CPU(unsigned int, nop_txn_flags);
|
||||
|
||||
static void perf_pmu_start_txn(struct pmu *pmu, unsigned int flags)
|
||||
@@ -9691,6 +9704,9 @@ got_cpu_context:
|
||||
pmu->pmu_disable = perf_pmu_nop_void;
|
||||
}
|
||||
|
||||
if (!pmu->check_period)
|
||||
pmu->check_period = perf_event_nop_int;
|
||||
|
||||
if (!pmu->event_idx)
|
||||
pmu->event_idx = perf_event_idx_default;
|
||||
|
||||
|
||||
@@ -734,7 +734,7 @@ 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)
|
||||
if (order_base_2(size) >= PAGE_SHIFT+MAX_ORDER)
|
||||
goto fail;
|
||||
|
||||
rb = kzalloc(size, GFP_KERNEL);
|
||||
|
||||
Reference in New Issue
Block a user