Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(program): add program LSM suport #42

Merged
merged 5 commits into from
Jan 22, 2024
Merged

feat(program): add program LSM suport #42

merged 5 commits into from
Jan 22, 2024

Conversation

xlango
Copy link
Contributor

@xlango xlango commented Jan 8, 2024

1.Added support for lsm ebpf program loading
2.Add test cases examples/programs/lsm

Copy link
Member

@cfc4n cfc4n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

低版本内核中,请跳过编译、加载、执行。

examples/programs/lsm/Makefile Show resolved Hide resolved
Copy link
Member

@cfc4n cfc4n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

单元测试报错了,请修复一下。

image

Copy link
Member

@cfc4n cfc4n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test failed.

make
mkdir -p ebpf/bin
clang -D__KERNEL__ -D__ASM_SYSREG_H \
	-DKERNEL_GE_5_7 \
	-Wno-unused-value \
	-Wno-pointer-sign \
	-Wno-compare-distinct-pointer-types \
	-Wunused \
	-Wall \
	-Werror \
	-I/lib/modules/$(uname -r)/build/include \
	-I/lib/modules/$(uname -r)/build/include/uapi \
	-I/lib/modules/$(uname -r)/build/include/generated/uapi \
	-I/lib/modules/$(uname -r)/build/arch/x86/include \
	-I/lib/modules/$(uname -r)/build/arch/x86/include/uapi \
	-I/lib/modules/$(uname -r)/build/arch/x86/include/generated \
	-O2 -emit-llvm \
	ebpf/main.c \
	-c -o - | llc -march=bpf -filetype=obj -o ebpf/bin/probe.o
go run github.com/shuLhan/go-bindata/cmd/go-bindata -pkg main -prefix "ebpf/bin" -o "probe.go" "ebpf/bin/probe.o"
go build -o bin/main .
sudo bin/main
INFO[0000] initializing manager
INFO[0000] cat /boot/config-$(uname -r) | grep BPF_LSM
INFO[0000] Linux kernel supports CONFIG_BPF_LSM=y
FATA[0003] error:1 error occurred:
	* error:error:create raw tracepoint: not supported , couldn's activate lsm lsm/path_mkdir, matchFuncName:lsm_path_mkdir, {UID:MyLSMPathMkdirHook, EbpfFuncName:lsm_path_mkdir}

, probes activation validation failed
make: *** [Makefile:59: run] Error 1
$uname -a
Linux vm-ubuntu-arm64 5.15.0-78-generic #85-Ubuntu SMP Fri Jul 7 15:29:30 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux

Copy link
Member

@cfc4n cfc4n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

还需要稍微调整一下,谢谢。

examples/programs/lsm/main.go Show resolved Hide resolved
@cfc4n cfc4n self-assigned this Jan 21, 2024
@cfc4n cfc4n linked an issue Jan 21, 2024 that may be closed by this pull request
Copy link
Member

@cfc4n cfc4n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cfc4n cfc4n merged commit 239558c into gojue:master Jan 22, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

无法加载LSM类型的ebpf
2 participants