Re: [PATCH] perf/x86/amd: check event before enable to avoid GPF

From: Ravi Bangoria
Date: Wed May 29 2024 - 23:37:56 EST


Hi George,

> Events can be deleted and the entry can be NULL.

Can you please also explain "how".

> Check event for NULL in amd_pmu_enable_all() before enable to avoid a GPF.
> This appears to be an AMD only issue.
>
> Syzkaller reported a GPF in amd_pmu_enable_all.

Can you please provide a bug report link? Also, any reproducer?

> @@ -760,7 +760,8 @@ static void amd_pmu_enable_all(int added)
> if (!test_bit(idx, cpuc->active_mask))
> continue;
>
> - amd_pmu_enable_event(cpuc->events[idx]);
> + if (cpuc->events[idx])
> + amd_pmu_enable_event(cpuc->events[idx]);

What if cpuc->events[idx] becomes NULL after if (cpuc->events[idx]) but
before amd_pmu_enable_event(cpuc->events[idx])?

Thanks,
Ravi