Re: [PATCH 5/5] perf arm-spe: Reject zero nr_cpu in metadata to prevent division by zero

Namhyung Kim <[email protected]>
Newsgroups org.kernel.vger.linux-kernel,org.kernel.vger.linux-perf-users
Message-ID <[email protected]>
On Mon, Aug 03, 2026 at 04:02:22PM -0300, Arnaldo Carvalho de Melo wrote:
> On Mon, Aug 03, 2026 at 09:46:49PM +0300, Adrian Hunter wrote:
> > On 27/07/2026 19:17, Arnaldo Carvalho de Melo wrote:
> > > From: Arnaldo Carvalho de Melo <[email protected]>
> > > 
> > > arm_spe__alloc_metadata() reads nr_cpu from the auxtrace_info priv
> > > array without validation.  When a crafted perf.data provides nr_cpu=0,
> > > the per_cpu_sz calculation divides by zero:
> > > 
> > >   per_cpu_sz = (metadata_size - (hdr_sz * sizeof(u64))) / (*nr_cpu);
> > > 
> > > Reject nr_cpu <= 0 early, before the division.  The caller already
> > > treats NULL return with metadata_ver != 1 as a parse failure.
> > > 
> > > Fixes: e52abceb4b6c2723 ("perf arm-spe: Dump metadata with version 2")
> > 
> > git blame shows 7842a4b6ff698 "perf arm-spe: Support metadata version 2"
> > for the relevant lines
> 
> That is right, Namhyung, can you please fix this Fixme tag while merging?

Sure, will do!

Thanks,
Namhyung
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.