When an MSC supporting memory bandwidth monitoring is brought offline and
then online, mpam_restore_mbwu_state() calls __ris_msmon_read() via ipi to
restore the configuration of the bandwidth counters. It doesn't care about
the value read, mbwu_arg.val, and doesn't set it leading to a null pointer
dereference when __ris_msmon_read() adds to it. This results in a kernel
oops with a call trace such as:
Call trace:
__ris_msmon_read+0x19c/0x64c (P)
mpam_restore_mbwu_state+0xa0/0xe8
smp_call_on_cpu_callback+0x1c/0x38
process_one_work+0x154/0x4b4
worker_thread+0x188/0x310
kthread+0x11c/0x130
ret_from_fork+0x10/0x20
Provide a local variable for val to avoid __ris_msmon_read() dereferencing
a null pointer when adding to val.
Fixes: 41e8a14950e1 ("arm_mpam: Track bandwidth counter state for power management")
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
drivers/resctrl/mpam_devices.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index 1eebc2602187..0666be6b0e88 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -1428,6 +1428,7 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid,
static int mpam_restore_mbwu_state(void *_ris)
{
int i;
+ u64 val;
struct mon_read mwbu_arg;
struct mpam_msc_ris *ris = _ris;
struct mpam_class *class = ris->vmsc->comp->class;
@@ -1437,6 +1438,7 @@ static int mpam_restore_mbwu_state(void *_ris)
mwbu_arg.ris = ris;
mwbu_arg.ctx = &ris->mbwu_state[i].cfg;
mwbu_arg.type = mpam_msmon_choose_counter(class);
+ mwbu_arg.val = &val;
__ris_msmon_read(&mwbu_arg);
}
--
2.43.0
Hi Ben,
On 27/02/2026 11:03, Ben Horgan wrote:
> When an MSC supporting memory bandwidth monitoring is brought offline and
> then online, mpam_restore_mbwu_state() calls __ris_msmon_read() via ipi to
> restore the configuration of the bandwidth counters. It doesn't care about
> the value read, mbwu_arg.val, and doesn't set it leading to a null pointer
If we're lucky! If its not NULL, it'll take it as a pointer and go corrupt
something else.
> dereference when __ris_msmon_read() adds to it. This results in a kernel
> oops with a call trace such as:
>
> Call trace:
> __ris_msmon_read+0x19c/0x64c (P)
> mpam_restore_mbwu_state+0xa0/0xe8
> smp_call_on_cpu_callback+0x1c/0x38
> process_one_work+0x154/0x4b4
> worker_thread+0x188/0x310
> kthread+0x11c/0x130
> ret_from_fork+0x10/0x20
>
> Provide a local variable for val to avoid __ris_msmon_read() dereferencing
> a null pointer when adding to val.
> diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
> index 1eebc2602187..0666be6b0e88 100644
> --- a/drivers/resctrl/mpam_devices.c
> +++ b/drivers/resctrl/mpam_devices.c
> @@ -1428,6 +1428,7 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid,
> static int mpam_restore_mbwu_state(void *_ris)
> {
> int i;
> + u64 val;
> struct mon_read mwbu_arg;
> struct mpam_msc_ris *ris = _ris;
> struct mpam_class *class = ris->vmsc->comp->class;
> @@ -1437,6 +1438,7 @@ static int mpam_restore_mbwu_state(void *_ris)
> mwbu_arg.ris = ris;
> mwbu_arg.ctx = &ris->mbwu_state[i].cfg;
> mwbu_arg.type = mpam_msmon_choose_counter(class);
> + mwbu_arg.val = &val;
>
> __ris_msmon_read(&mwbu_arg);
> }
Reviewed-by: James Morse <james.morse@arm.com>
Thanks for catching this!
James
© 2016 - 2026 Red Hat, Inc.