Skip to content

Commit cba09e3

Browse files
committed
Merge tag 'perf-urgent-2025-12-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf event fixes from Ingo Molnar: - Fix NULL pointer dereference crash in the Intel PMU driver - Fix missing read event generation on task exit - Fix AMD uncore driver init error handling - Fix whitespace noise * tag 'perf-urgent-2025-12-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf/x86/intel: Fix NULL event dereference crash in handle_pmi_common() perf/core: Fix missing read event generation on task exit perf/x86/amd/uncore: Fix the return value of amd_uncore_df_event_init() on error perf/uprobes: Remove <space><Tab> whitespace noise
2 parents db01301 + 9415f74 commit cba09e3

4 files changed

Lines changed: 20 additions & 18 deletions

File tree

arch/x86/events/amd/uncore.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -656,14 +656,11 @@ static int amd_uncore_df_event_init(struct perf_event *event)
656656
struct hw_perf_event *hwc = &event->hw;
657657
int ret = amd_uncore_event_init(event);
658658

659-
if (ret || pmu_version < 2)
660-
return ret;
661-
662659
hwc->config = event->attr.config &
663660
(pmu_version >= 2 ? AMD64_PERFMON_V2_RAW_EVENT_MASK_NB :
664661
AMD64_RAW_EVENT_MASK_NB);
665662

666-
return 0;
663+
return ret;
667664
}
668665

669666
static int amd_uncore_df_add(struct perf_event *event, int flags)

arch/x86/events/intel/core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3378,6 +3378,9 @@ static int handle_pmi_common(struct pt_regs *regs, u64 status)
33783378

33793379
if (!test_bit(bit, cpuc->active_mask))
33803380
continue;
3381+
/* Event may have already been cleared: */
3382+
if (!event)
3383+
continue;
33813384

33823385
/*
33833386
* There may be unprocessed PEBS records in the PEBS buffer,

kernel/events/core.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2317,8 +2317,6 @@ static void perf_group_detach(struct perf_event *event)
23172317
perf_event__header_size(leader);
23182318
}
23192319

2320-
static void sync_child_event(struct perf_event *child_event);
2321-
23222320
static void perf_child_detach(struct perf_event *event)
23232321
{
23242322
struct perf_event *parent_event = event->parent;
@@ -2337,7 +2335,6 @@ static void perf_child_detach(struct perf_event *event)
23372335
lockdep_assert_held(&parent_event->child_mutex);
23382336
*/
23392337

2340-
sync_child_event(event);
23412338
list_del_init(&event->child_list);
23422339
}
23432340

@@ -4588,6 +4585,7 @@ static void perf_event_enable_on_exec(struct perf_event_context *ctx)
45884585
static void perf_remove_from_owner(struct perf_event *event);
45894586
static void perf_event_exit_event(struct perf_event *event,
45904587
struct perf_event_context *ctx,
4588+
struct task_struct *task,
45914589
bool revoke);
45924590

45934591
/*
@@ -4615,7 +4613,7 @@ static void perf_event_remove_on_exec(struct perf_event_context *ctx)
46154613

46164614
modified = true;
46174615

4618-
perf_event_exit_event(event, ctx, false);
4616+
perf_event_exit_event(event, ctx, ctx->task, false);
46194617
}
46204618

46214619
raw_spin_lock_irqsave(&ctx->lock, flags);
@@ -12518,7 +12516,7 @@ static void __pmu_detach_event(struct pmu *pmu, struct perf_event *event,
1251812516
/*
1251912517
* De-schedule the event and mark it REVOKED.
1252012518
*/
12521-
perf_event_exit_event(event, ctx, true);
12519+
perf_event_exit_event(event, ctx, ctx->task, true);
1252212520

1252312521
/*
1252412522
* All _free_event() bits that rely on event->pmu:
@@ -14075,14 +14073,13 @@ void perf_pmu_migrate_context(struct pmu *pmu, int src_cpu, int dst_cpu)
1407514073
}
1407614074
EXPORT_SYMBOL_GPL(perf_pmu_migrate_context);
1407714075

14078-
static void sync_child_event(struct perf_event *child_event)
14076+
static void sync_child_event(struct perf_event *child_event,
14077+
struct task_struct *task)
1407914078
{
1408014079
struct perf_event *parent_event = child_event->parent;
1408114080
u64 child_val;
1408214081

1408314082
if (child_event->attr.inherit_stat) {
14084-
struct task_struct *task = child_event->ctx->task;
14085-
1408614083
if (task && task != TASK_TOMBSTONE)
1408714084
perf_event_read_event(child_event, task);
1408814085
}
@@ -14101,7 +14098,9 @@ static void sync_child_event(struct perf_event *child_event)
1410114098

1410214099
static void
1410314100
perf_event_exit_event(struct perf_event *event,
14104-
struct perf_event_context *ctx, bool revoke)
14101+
struct perf_event_context *ctx,
14102+
struct task_struct *task,
14103+
bool revoke)
1410514104
{
1410614105
struct perf_event *parent_event = event->parent;
1410714106
unsigned long detach_flags = DETACH_EXIT;
@@ -14124,6 +14123,9 @@ perf_event_exit_event(struct perf_event *event,
1412414123
mutex_lock(&parent_event->child_mutex);
1412514124
/* PERF_ATTACH_ITRACE might be set concurrently */
1412614125
attach_state = READ_ONCE(event->attach_state);
14126+
14127+
if (attach_state & PERF_ATTACH_CHILD)
14128+
sync_child_event(event, task);
1412714129
}
1412814130

1412914131
if (revoke)
@@ -14215,7 +14217,7 @@ static void perf_event_exit_task_context(struct task_struct *task, bool exit)
1421514217
perf_event_task(task, ctx, 0);
1421614218

1421714219
list_for_each_entry_safe(child_event, next, &ctx->event_list, event_entry)
14218-
perf_event_exit_event(child_event, ctx, false);
14220+
perf_event_exit_event(child_event, ctx, exit ? task : NULL, false);
1421914221

1422014222
mutex_unlock(&ctx->mutex);
1422114223

kernel/events/uprobes.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ struct uprobe {
7979
* The generic code assumes that it has two members of unknown type
8080
* owned by the arch-specific code:
8181
*
82-
* insn - copy_insn() saves the original instruction here for
82+
* insn - copy_insn() saves the original instruction here for
8383
* arch_uprobe_analyze_insn().
8484
*
8585
* ixol - potentially modified instruction to execute out of
@@ -107,16 +107,16 @@ static LIST_HEAD(delayed_uprobe_list);
107107
* allocated.
108108
*/
109109
struct xol_area {
110-
wait_queue_head_t wq; /* if all slots are busy */
111-
unsigned long *bitmap; /* 0 = free slot */
110+
wait_queue_head_t wq; /* if all slots are busy */
111+
unsigned long *bitmap; /* 0 = free slot */
112112

113113
struct page *page;
114114
/*
115115
* We keep the vma's vm_start rather than a pointer to the vma
116116
* itself. The probed process or a naughty kernel module could make
117117
* the vma go away, and we must handle that reasonably gracefully.
118118
*/
119-
unsigned long vaddr; /* Page(s) of instruction slots */
119+
unsigned long vaddr; /* Page(s) of instruction slots */
120120
};
121121

122122
static void uprobe_warn(struct task_struct *t, const char *msg)

0 commit comments

Comments
 (0)