summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2023-08-21 10:40:09 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2023-08-21 10:49:31 -0300
commit7d9642311b6d9d319a6948581244561d2a0890a1 (patch)
tree09e7bbf99f86f01ec312a9defa668c8148ba0f99
parent262b54b6c9396823ab06df46a1be475c44b28b5f (diff)
downloadlinux-stable-7d9642311b6d9d319a6948581244561d2a0890a1.tar.gz
linux-stable-7d9642311b6d9d319a6948581244561d2a0890a1.tar.bz2
linux-stable-7d9642311b6d9d319a6948581244561d2a0890a1.zip
perf bpf augmented_raw_syscalls: Add an assert to make sure sizeof(augmented_arg->value) is a power of two.
Similar to what was done in the previous cset for sizeof(saddr), we need to make sure sizeof(augmented_arg->value) is a power of two to do bounds checking using &=: augmented_len &= sizeof(augmented_arg->value) - 1; Suggested-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/lkml/ZONrPo0NSqdbXiGx@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c b/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c
index 43549b63b433..90ce22f9c1a9 100644
--- a/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c
+++ b/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c
@@ -160,6 +160,7 @@ unsigned int augmented_arg__read_str(struct augmented_arg *augmented_arg, const
*/
if (string_len > 0) {
augmented_len -= sizeof(augmented_arg->value) - string_len;
+ _Static_assert(is_power_of_2(sizeof(augmented_arg->value)), "sizeof(augmented_arg->value) needs to be a power of two");
augmented_len &= sizeof(augmented_arg->value) - 1;
augmented_arg->size = string_len;
} else {