Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 41e8a14950e1 ("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>

authored by

Ben Horgan and committed by
Will Deacon
4ad79c87 d499e962

+2
+2
drivers/resctrl/mpam_devices.c
··· 1428 1428 static int mpam_restore_mbwu_state(void *_ris) 1429 1429 { 1430 1430 int i; 1431 + u64 val; 1431 1432 struct mon_read mwbu_arg; 1432 1433 struct mpam_msc_ris *ris = _ris; 1433 1434 struct mpam_class *class = ris->vmsc->comp->class; ··· 1438 1437 mwbu_arg.ris = ris; 1439 1438 mwbu_arg.ctx = &ris->mbwu_state[i].cfg; 1440 1439 mwbu_arg.type = mpam_msmon_choose_counter(class); 1440 + mwbu_arg.val = &val; 1441 1441 1442 1442 __ris_msmon_read(&mwbu_arg); 1443 1443 }