From: ruowenq2@illinois.edu
To: bpf@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
jinghao7@illinois.edu, keescook@chromium.org,
Ruowen Qin <ruowenq2@illinois.edu>,
Mimi Zohar <zohar@linux.ibm.com>,
Jinghao Jia <jinghao@linux.ibm.com>
Subject: [PATCH bpf-next v3 1/1] samples/bpf: Add -fsanitize=bounds to userspace programs
Date: Tue, 26 Sep 2023 23:50:30 -0500 [thread overview]
Message-ID: <20230927045030.224548-2-ruowenq2@illinois.edu> (raw)
In-Reply-To: <20230927045030.224548-1-ruowenq2@illinois.edu>
From: Ruowen Qin <ruowenq2@illinois.edu>
The sanitizer flag, which is supported by both clang and gcc, would make
it easier to debug array index out-of-bounds problems in these programs.
Make the Makfile smarter to detect ubsan support from the compiler and
add the '-fsanitize=bounds' accordingly.
Suggested-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Jinghao Jia <jinghao@linux.ibm.com>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Signed-off-by: Ruowen Qin <ruowenq2@illinois.edu>
---
samples/bpf/Makefile | 3 +++
1 file changed, 3 insertions(+)
diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 6c707ebcebb9..90af76fa9dd8 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -169,6 +169,9 @@ endif
TPROGS_CFLAGS += -Wall -O2
TPROGS_CFLAGS += -Wmissing-prototypes
TPROGS_CFLAGS += -Wstrict-prototypes
+TPROGS_CFLAGS += $(call try-run,\
+ printf "int main() { return 0; }" |\
+ $(CC) -Werror -fsanitize=bounds -x c - -o "$$TMP",-fsanitize=bounds,)
TPROGS_CFLAGS += -I$(objtree)/usr/include
TPROGS_CFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
--
2.42.0
next prev parent reply other threads:[~2023-09-27 5:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-27 4:50 [PATCH bpf-next v3 0/1] samples/bpf: syscall_tp_user: Refactor and fix array index out-of-bounds bug ruowenq2
2023-09-27 4:50 ` ruowenq2 [this message]
2023-09-27 11:03 ` [PATCH bpf-next v3 1/1] samples/bpf: Add -fsanitize=bounds to userspace programs Jiri Olsa
2023-09-27 23:19 ` ruowenq2
2023-09-28 8:15 ` Jiri Olsa
2023-09-28 9:19 ` Jinghao Jia
2023-09-28 14:03 ` Jiri Olsa
2023-09-28 16:40 ` [PATCH bpf-next v3 0/1] samples/bpf: syscall_tp_user: Refactor and fix array index out-of-bounds bug patchwork-bot+netdevbpf
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=20230927045030.224548-2-ruowenq2@illinois.edu \
--to=ruowenq2@illinois.edu \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jinghao7@illinois.edu \
--cc=jinghao@linux.ibm.com \
--cc=keescook@chromium.org \
--cc=zohar@linux.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox