From 40344e81ba28b0ac50578d3b77e4c20f417da1b6 Mon Sep 17 00:00:00 2001 From: Coleman Kane Date: Thu, 4 Nov 2021 21:43:55 -0400 Subject: [PATCH 1/2] Add -fno-stack-protector to epbf programs when compiling The ebpf programs aren't getting linked against the extra run-time helpers, so they don't have access to extended features like stack protection. This was causing a build error that is fixed by adding -fno-stack-protector to the compilation line. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2cc3cda..abd1bcf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -510,7 +510,7 @@ set(CLANG_INCLUDES # function to make ebpf programs function(build_ebpf ebpfsrc) add_custom_command(OUTPUT ${ebpfsrc}.o - COMMAND "${CLANG}" -nostdinc -isystem `gcc -print-file-name=include` ${CLANG_INCLUDES} ${CLANG_DEFINES} -O2 ${CLANG_OPTIONS} -emit-llvm -c "${CMAKE_SOURCE_DIR}/ebpfKern/${ebpfsrc}.c" -o -| "${LLC}" -march=bpf -filetype=obj -o "${ebpfsrc}.o" + COMMAND "${CLANG}" -nostdinc -isystem `gcc -print-file-name=include` ${CLANG_INCLUDES} ${CLANG_DEFINES} -O2 ${CLANG_OPTIONS} -emit-llvm -fno-stack-protector -c "${CMAKE_SOURCE_DIR}/ebpfKern/${ebpfsrc}.c" -o -| "${LLC}" -march=bpf -filetype=obj -o "${ebpfsrc}.o" COMMENT "Building EBPF object ${ebpfsrc}.o" DEPENDS ebpfKern/${ebpfsrc}.c ${EBPF_DEPENDS} ) From af2769b69e14e4831cf8223bb8546699efb08142 Mon Sep 17 00:00:00 2001 From: Coleman Kane Date: Thu, 4 Nov 2021 21:47:39 -0400 Subject: [PATCH 2/2] Initialize the "empty" array to all zeroes, to quell a compiler warning. --- networkTracker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/networkTracker.cpp b/networkTracker.cpp index b1829f9..261c294 100644 --- a/networkTracker.cpp +++ b/networkTracker.cpp @@ -866,7 +866,7 @@ extern "C" bool NetworkTrackerSeenAccept(NetworkTracker *n, bool IPv4, const BYT return false; } - BYTE empty[16]; + BYTE empty[16] = {0}; AddrAndPort d(empty, IPv4, 0); if (n->SeenAccept(AddrAndPort(sourceAddr, IPv4, sourcePort), &d)) {