From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8BC70346E55 for ; Fri, 6 Mar 2026 18:24:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772821448; cv=none; b=KvuXn0cIrOQdSOF0TJszV51cgEHtQVtHkai4ebJ5kQXjKsMwm2GjD0aX50TzB/4IvEYHzo9mJ/Km1lWLe+uq5lUO9mThtfM6rBcRRRw9y+pMgqN/+yJA2YmrAOhdF2LeNvmkpbhShxpo3YEYPt5Yu8+HWApCjxnvaQ+MPenGF84= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772821448; c=relaxed/simple; bh=6IwcAzJ7I2wj+nVPHxGrBfqBNFD91euMXr3BVdug8L0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=MS2dPzDgoo7qZD8B0/s3+mjSAULFbgjE92597ZozmQtRp6T+Q7zE0uCCWfLBfZJ2xJwWBpYHpycZUApzPNQ1GOyzIPBcCtE9m1ViyZr8l9lcJrbcMeUfelZkYOv1FBLa1pr/kDb9BrszvE7yehaWLEziie9m76E1SLBRg1TOGzg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 66EA1497; Fri, 6 Mar 2026 10:23:59 -0800 (PST) Received: from [10.1.196.96] (eglon.cambridge.arm.com [10.1.196.96]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9F5F63F7BD; Fri, 6 Mar 2026 10:24:04 -0800 (PST) Message-ID: <400840f3-4a0e-4da7-993b-c4341c3955ac@arm.com> Date: Fri, 6 Mar 2026 18:24:02 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 1/2] arm_mpam: Fix null pointer dereference when restoring bandwidth counters To: Ben Horgan 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 References: <20260227110314.4038066-1-ben.horgan@arm.com> <20260227110314.4038066-2-ben.horgan@arm.com> Content-Language: en-GB From: James Morse In-Reply-To: <20260227110314.4038066-2-ben.horgan@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 Thanks for catching this! James