From: Jiri Olsa <olsajiri@gmail.com>
To: ruowenq2@illinois.edu
Cc: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
andrii@kernel.org, jinghao7@illinois.edu, keescook@chromium.org,
Mimi Zohar <zohar@linux.ibm.com>,
Jinghao Jia <jinghao@linux.ibm.com>
Subject: Re: [PATCH bpf-next v3 1/1] samples/bpf: Add -fsanitize=bounds to userspace programs
Date: Wed, 27 Sep 2023 13:03:29 +0200 [thread overview]
Message-ID: <ZRQMASduySxE+TO2@krava> (raw)
In-Reply-To: <20230927045030.224548-2-ruowenq2@illinois.edu>
On Tue, Sep 26, 2023 at 11:50:30PM -0500, ruowenq2@illinois.edu wrote:
> 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,)
I haven't checked deeply, but could we use just cc-option? looks simpler
TPROGS_CFLAGS += $(call cc-option, -fsanitize=bounds)
jirka
>
> 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 11:03 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 ` [PATCH bpf-next v3 1/1] samples/bpf: Add -fsanitize=bounds to userspace programs ruowenq2
2023-09-27 11:03 ` Jiri Olsa [this message]
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=ZRQMASduySxE+TO2@krava \
--to=olsajiri@gmail.com \
--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=ruowenq2@illinois.edu \
--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