From: James Morse <james.morse@arm.com>
To: Ben Horgan <ben.horgan@arm.com>
Cc: reinette.chatre@intel.com, fenghuay@nvidia.com, gshan@redhat.com,
zengheng4@huawei.com, jonathan.cameron@huawei.com,
tan.shaopeng@jp.fujitsu.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 1/2] arm_mpam: Fix null pointer dereference when restoring bandwidth counters
Date: Fri, 6 Mar 2026 18:24:02 +0000 [thread overview]
Message-ID: <400840f3-4a0e-4da7-993b-c4341c3955ac@arm.com> (raw)
In-Reply-To: <20260227110314.4038066-2-ben.horgan@arm.com>
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
next prev parent reply other threads:[~2026-03-06 18:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-27 11:03 [PATCH v1 0/2] arm_mpam: A couple of fixes on v7.0-rc1 Ben Horgan
2026-02-27 11:03 ` [PATCH v1 1/2] arm_mpam: Fix null pointer dereference when restoring bandwidth counters Ben Horgan
2026-03-06 18:24 ` James Morse [this message]
2026-02-27 11:03 ` [PATCH v1 2/2] arm_mpam: Disable preemption when making accesses to fake MSC in kunit test Ben Horgan
2026-03-06 18:24 ` James Morse
2026-03-19 0:56 ` [PATCH v1 0/2] arm_mpam: A couple of fixes on v7.0-rc1 Tan, Shaopeng/譚 紹鵬
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=400840f3-4a0e-4da7-993b-c4341c3955ac@arm.com \
--to=james.morse@arm.com \
--cc=ben.horgan@arm.com \
--cc=fenghuay@nvidia.com \
--cc=gshan@redhat.com \
--cc=jonathan.cameron@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=reinette.chatre@intel.com \
--cc=tan.shaopeng@jp.fujitsu.com \
--cc=zengheng4@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®