[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z7ShgKYeSqpGUXGl@google.com>
Date: Tue, 18 Feb 2025 07:04:32 -0800
From: Sean Christopherson <seanjc@...gle.com>
To: Dapeng Mi <dapeng1.mi@...ux.intel.com>
Cc: Paolo Bonzini <pbonzini@...hat.com>, kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
Jim Mattson <jmattson@...gle.com>, Mingwei Zhang <mizhang@...gle.com>,
Xiong Zhang <xiong.y.zhang@...el.com>, Zhenyu Wang <zhenyuw@...ux.intel.com>,
Like Xu <like.xu.linux@...il.com>, Jinrong Liang <cloudliang@...cent.com>,
Yongwei Ma <yongwei.ma@...el.com>, Dapeng Mi <dapeng1.mi@...el.com>
Subject: Re: [kvm-unit-tests patch v6 07/18] x86: pmu: Fix potential out of
bound access for fixed events
On Tue, Feb 18, 2025, Dapeng Mi wrote:
>
> On 2/15/2025 5:07 AM, Sean Christopherson wrote:
> > On Sat, Sep 14, 2024, Dapeng Mi wrote:
> >> @@ -744,6 +753,12 @@ int main(int ac, char **av)
> >> printf("Fixed counters: %d\n", pmu.nr_fixed_counters);
> >> printf("Fixed counter width: %d\n", pmu.fixed_counter_width);
> >>
> >> + fixed_counters_num = MIN(pmu.nr_fixed_counters, ARRAY_SIZE(fixed_events));
> >> + if (pmu.nr_fixed_counters > ARRAY_SIZE(fixed_events))
> >> + report_info("Fixed counters number %d > defined fixed events %ld. "
> > Doesn't compile on 32-bit builds. Easiest thing is to cast ARRAY_SIZE, because
> > size_t is different between 32-bit and 64-bit.
>
> But ARRAY_SIZE() should return same value regardless of 32-bit or 64-bit,
> right?
Yep. The value is the same, but the type "returned" by sizeof() is different.
On 32-bit, it's an "unsigned int"; on 64-bit, it's an unsigned long. I.e. the
size of sizeof() is different (sorry, couldn't resist).
Powered by blists - more mailing lists