Re: [PATCH v6 01/10] perf hists browser: Increase MAX_OPTIONS to prevent stack buffer overflow

From: Namhyung Kim

Date: Mon Jul 20 2026 - 00:45:48 EST


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!

Best regards,
Namhyung