From: Dapeng Mi <dapeng1.mi@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Zide Chen <zide.chen@intel.com>,
Falcon Thomas <thomas.falcon@intel.com>,
Dapeng Mi <dapeng1.mi@intel.com>,
Xudong Hao <xudong.hao@intel.com>,
Dapeng Mi <dapeng1.mi@linux.intel.com>
Subject: [Patch v2 1/2] perf aslr: Add missing SIMD handling in aslr_tool__process_sample()
Date: Tue, 22 Sep 2026 09:05:30 +0800 [thread overview]
Message-ID: <20260922010531.1933320-1-dapeng1.mi@linux.intel.com> (raw)
Currently the SIMD register sampling is supported, but the corresponding
handling is missed in aslr_tool__process_sample(). This can break parsing
of the sample record.
Add the missing SIMD register handling in aslr_tool__process_sample().
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Reviewed-by: Ian Rogers <irogers@google.com>
---
V2: Add missed "#undef CHECK_SIMD" and fix typo in short log (Ian).
tools/perf/util/aslr.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/tools/perf/util/aslr.c b/tools/perf/util/aslr.c
index 027695d96779..697ac0d3d548 100644
--- a/tools/perf/util/aslr.c
+++ b/tools/perf/util/aslr.c
@@ -19,6 +19,7 @@
#include <internal/lib.h> /* page_size */
#include <linux/compiler.h>
#include <linux/zalloc.h>
+#include <linux/overflow.h>
#include <errno.h>
#include <inttypes.h>
#include <unistd.h>
@@ -992,6 +993,34 @@ static int aslr_tool__process_sample(const struct perf_tool *tool,
COPY_U64();
}
}
+
+#define CHECK_SIMD() \
+ do { \
+ if (abi & PERF_SAMPLE_REGS_ABI_SIMD) { \
+ u64 nr_vector, vec_qwords; \
+ u64 nr_pred, pred_qwords; \
+ u64 header_len, vec_len, pred_len, simd_len; \
+ if (CHECK_BOUNDS(nr + 4, nr + 4)) { \
+ ret = -EFAULT; \
+ goto out_put; \
+ } \
+ header_len = 4; \
+ nr_vector = in_array[i + nr]; \
+ vec_qwords = in_array[i + nr + 1]; \
+ nr_pred = in_array[i + nr + 2]; \
+ pred_qwords = in_array[i + nr + 3]; \
+ if (check_mul_overflow(nr_vector, vec_qwords, &vec_len) || \
+ check_mul_overflow(nr_pred, pred_qwords, &pred_len) || \
+ check_add_overflow(vec_len, pred_len, &simd_len) || \
+ check_add_overflow(header_len, simd_len, &simd_len) || \
+ check_add_overflow(nr, simd_len, &nr) || \
+ nr > max_i - i) { \
+ ret = -EFAULT; \
+ goto out_put; \
+ } \
+ } \
+ } while (0)
+
if (orig_sample_type & PERF_SAMPLE_REGS_USER) {
u64 abi;
@@ -1007,6 +1036,7 @@ static int aslr_tool__process_sample(const struct perf_tool *tool,
ret = -EFAULT;
goto out_put;
}
+ CHECK_SIMD();
i += nr;
}
}
@@ -1061,6 +1091,7 @@ static int aslr_tool__process_sample(const struct perf_tool *tool,
ret = -EFAULT;
goto out_put;
}
+ CHECK_SIMD();
i += nr;
}
}
@@ -1154,6 +1185,7 @@ static int aslr_tool__process_sample(const struct perf_tool *tool,
#undef CHECK_BOUNDS
#undef COPY_U64
#undef REMAP_U64
+#undef CHECK_SIMD
static int skipn(int fd, off_t n)
{
base-commit: 1c12f13c079c35a1e5ef2dd9e6aeea1810c58e87
--
2.34.1
next reply other threads:[~2026-09-22 1:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 1:05 Dapeng Mi [this message]
2026-09-22 1:05 ` [Patch v2 2/2] perf util: Explicitly include required headers Dapeng Mi
2026-09-22 1:16 ` sashiko-bot
2026-09-22 1:20 ` [Patch v2 1/2] perf aslr: Add missing SIMD handling in aslr_tool__process_sample() sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260922010531.1933320-1-dapeng1.mi@linux.intel.com \
--to=dapeng1.mi@linux.intel.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=dapeng1.mi@intel.com \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=thomas.falcon@intel.com \
--cc=xudong.hao@intel.com \
--cc=zide.chen@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.