-
Notifications
You must be signed in to change notification settings - Fork 102
Open
Description
Sample code snippet https://docs.ebpf.io/linux/program-type/BPF_PROG_TYPE_LSM/
It would be more beginner friendly if that sample had includes.
For example I have tried
#include <linux/types.h> // Defines __u32, __u64, etc.
#include <linux/errno.h> // Kernel error codes (EPERM, etc.)
#include <bpf/bpf_helpers.h> // eBPF helper functions
#include <linux/lsm_hooks.h> // LSM hooks
And I have no idea what do I still have missing.
I also have this Makefile:
KERNEL_SRC := /usr/src/linux-source-6.1
COMMON_HEADERS := /usr/src/linux-headers-$(shell uname -r | sed 's/-amd64/-common/')
# Hardcoding the path to the 'asm' directory that contains 'barrier.h'
ASM_PATH := /usr/src/linux-source-6.1/arch/x86/include/asm
# Include the architecture-specific kernel headers for x86_64 explicitly
CFLAGS := -D__KERNEL__ -D__TARGET_ARCH_x86_64 \
-I$(KERNEL_SRC)/include \
-I$(KERNEL_SRC)/include/uapi \
-I$(KERNEL_SRC)/include/generated/uapi \
-I$(COMMON_HEADERS)/include \
-I$(KERNEL_SRC)/arch/x86/include/generated \
-I$(ASM_PATH) \
-I$(COMMON_HEADERS)/include/asm-generic \
-I/usr/include/bpf
# Path for object file
all: prevent_socket.o
prevent_socket.o: prevent_socket.c
clang $(CFLAGS) -target bpf -g -O2 -c $< -o $@
clean:
rm -f prevent_socket.o
But it keeps saying:
/usr/src/linux-source-6.1/include/linux/list.h:11:10: fatal error: 'asm/barrier.h' file not found
#include <asm/barrier.h>
Although I have file /usr/src/linux-source-6.1/arch/x86/include/asm/barrier.h
Also it seems to me that this sample is a bit misleading. Under usage section it talks about allowing socket syscall but mprotect_audit does not seem to be sockets related when looking at it's name.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels