]> git.ipfire.org Git - thirdparty/linux.git/commit
perf machine: Use snprintf() for guestmount path construction
authorArnaldo Carvalho de Melo <acme@redhat.com>
Sat, 13 Jun 2026 16:59:39 +0000 (13:59 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 17 Jun 2026 12:21:03 +0000 (09:21 -0300)
commitfe63d3bca288c5bb983304efd5fc3a5ff3183403
tree98d4d90a698d425c5fb056c28d15965db5185c01
parent8a4506595857356fcef9f7aad3506593e9fabbbc
perf machine: Use snprintf() for guestmount path construction

machines__findnew() and machines__create_guest_kernel_maps() use
sprintf() to build paths by prepending symbol_conf.guestmount.
Both write into PATH_MAX stack buffers, but guestmount comes from
user configuration and is not length-checked.  A guestmount path
at or near PATH_MAX causes a stack buffer overflow.

Switch to snprintf() with sizeof() to prevent overflow.  The
subsequent access()/fopen() calls will fail on a truncated path.

Fixes: a1645ce12adb6c9c ("perf: 'perf kvm' tool for monitoring guest performance from host")
Reported-by: sashiko-bot <sashiko-bot@kernel.org>
Cc: Zhang, Yanmin <yanmin_zhang@linux.intel.com>
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/machine.c