On Tue, Jan 19, 2021 at 10:11:16AM +0100, Borislav Petkov wrote: > On Tue, Jan 19, 2021 at 01:19:42PM +0800, Feng Tang wrote: > > Sorry, after testing on more platforms, the following is needed to fix > > a potential array overflow ((a full patch with fix is also attached) > > > > diff --git a/tools/arch/x86/kcpuid/kcpuid.c b/tools/arch/x86/kcpuid/kcpuid.c > > index 3ea607b..bf68335 100644 > > --- a/tools/arch/x86/kcpuid/kcpuid.c > > +++ b/tools/arch/x86/kcpuid/kcpuid.c > > @@ -329,7 +329,8 @@ static int parse_line(char *line) > > range = leafs_basic; > > > > index &= 0x7FFFFFFF; > > - if ((int)index > range->nr) > > + /* range->nr equals to max index plus 1 */ > > + if ((int)index >= range->nr) > > That comment is basically repeating the code. What it should do is > explain *why* that test is being done or not be there at all. Right! So this is better? /* Skip line parsing for non-existing indexes */
Thanks, Feng > -- > Regards/Gruss, > Boris. > > https://people.kernel.org/tglx/notes-about-netiquette