[PATCH bpf 1/3] samples/bpf: Add -fsanitize=bounds to userspace programs

Jinghao Jia
2023-08-18T16:47:07Z

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.

Suggested-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Jinghao Jia <jinghao@linux.ibm.com>
---
samples/bpf/Makefile | 1 +
1 file changed, 1 insertion(+)

diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 595b98d825ce..340972ed1582 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -193,6 +193,7 @@ endif
TPROGS_CFLAGS += -Wall -O2
TPROGS_CFLAGS += -Wmissing-prototypes
TPROGS_CFLAGS += -Wstrict-prototypes
+TPROGS_CFLAGS += -fsanitize=bounds

TPROGS_CFLAGS += -I$(objtree)/usr/include
TPROGS_CFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
--
2.41.0