Re: [PATCH v6 01/10] perf hists browser: Increase MAX_OPTIONS to prevent stack buffer overflow
From: Ian Rogers
Date: Wed Jul 22 2026 - 12:57:15 EST
On Sun, Jul 19, 2026 at 9:45 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
>
> On Thu, Jul 16, 2026 at 12:23:42AM -0700, Ian Rogers wrote:
> > In evsel__hists_browse(), the 'options' and 'actions' arrays are
> > statically allocated on the stack with a size of MAX_OPTIONS (16).
> > Further down, the function sequentially calls several add_*_opt()
> > functions, which increment nr_options without bounds checking.
> >
> > Depending on the context (e.g., branch mode, scripting, annotations),
> > the sum of added options can theoretically exceed 16 (potentially
> > reaching up to ~19). This could lead to a stack buffer overflow.
> >
> > Increase MAX_OPTIONS to 32 to safely accommodate the maximum possible
> > number of options without risking an overflow.
>
> Applied patch 1 to 6 (except 4) to perf-tools-next, thanks!
Thanks Namhyung. That's the main part of the fix. I'll try to follow
up on the rest (patch 4) asap.
Ian
> Best regards,
> Namhyung
>