From 8b868f3dd030c1df799afca6636e5041ac5e190d Mon Sep 17 00:00:00 2001 From: Serhei Makarov Date: Mon, 13 May 2019 14:55:30 -0400 Subject: [PATCH] stapbpf fix for GCC9 :: use ((nonstring)) attr for map key buffers Newer gcc9 raises suspicions on copying BPF_MAXSTRINGLEN to BPF_MAXSTRINGLEN_PLUS sized buffer. Tentative fix, worth reviewing these issues further. * stapbpf/bpfinterp.cxx (map_get_next_key): add __attribute__ ((nonstring)) to signal how buffers will be used. --- stapbpf/bpfinterp.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/stapbpf/bpfinterp.cxx b/stapbpf/bpfinterp.cxx index c6773ea9f..148143060 100644 --- a/stapbpf/bpfinterp.cxx +++ b/stapbpf/bpfinterp.cxx @@ -112,8 +112,10 @@ map_get_next_key(int fd_idx, int64_t key, int64_t next_key, // with a single map during execution of nested foreach loops. if (!key && is_str) { - // XXX: BPF_MAXSTRINGLEN+1 to avoid coverity warning - char k[BPF_MAXSTRINGLEN_PLUS], n[BPF_MAXSTRINGLEN_PLUS]; + // XXX: BPF_MAXSTRINGLEN+1 to placate coverity, + // ((nonstring)) to placate gcc9 warnings. Worth reviewing. + char k[BPF_MAXSTRINGLEN_PLUS] __attribute__ ((nonstring)), + n[BPF_MAXSTRINGLEN_PLUS] __attribute__ ((nonstring)); std::set s; int rc = bpf_get_next_key(fd, 0, as_ptr(n)); -- 2.43.5