Skip to content

Commit 4ad79c8

Browse files
benhor01willdeacon
authored andcommitted
arm_mpam: Fix null pointer dereference when restoring bandwidth counters
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: 41e8a14 ("arm_mpam: Track bandwidth counter state for power management") Signed-off-by: Ben Horgan <ben.horgan@arm.com> Reviewed-by: James Morse <james.morse@arm.com> Signed-off-by: James Morse <james.morse@arm.com> Signed-off-by: Will Deacon <will@kernel.org>
1 parent d499e96 commit 4ad79c8

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/resctrl/mpam_devices.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,7 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid,
14281428
static int mpam_restore_mbwu_state(void *_ris)
14291429
{
14301430
int i;
1431+
u64 val;
14311432
struct mon_read mwbu_arg;
14321433
struct mpam_msc_ris *ris = _ris;
14331434
struct mpam_class *class = ris->vmsc->comp->class;
@@ -1437,6 +1438,7 @@ static int mpam_restore_mbwu_state(void *_ris)
14371438
mwbu_arg.ris = ris;
14381439
mwbu_arg.ctx = &ris->mbwu_state[i].cfg;
14391440
mwbu_arg.type = mpam_msmon_choose_counter(class);
1441+
mwbu_arg.val = &val;
14401442

14411443
__ris_msmon_read(&mwbu_arg);
14421444
}

0 commit comments

Comments
 (0)