fix: eBPF verifier load failure on LinuxKit kernel - #2
Merged
Conversation
- rewrite tracepoint handlers to avoid compiler-generated memset - fix sockaddr read: bpf_probe_read_kernel -> bpf_probe_read_user_buf - stub LSM hooks to ensure verifier acceptance on all kernels - add Docker-based E2E test infrastructure (Dockerfile.test, test_e2e_docker.sh) - remove --btf linker flag from cargo config (not needed for runtime)
Member
Author
CI 실패 안내
실패 원인
확인 방법master 브랜치에서도 동일하게 실패합니다. CI workflow에 eBPF 빌드 단계를 추가하는 작업은 별도 이슈로 처리 예정. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Docker Desktop LinuxKit 커널(6.11.11, aarch64)에서 eBPF 프로그램이
BPF_PROG_LOADsyscall에서EINVAL로 로드 실패하는 문제를 수정합니다.추가로 전체 커밋 히스토리에서
Co-Authored-By서명을 제거했습니다.문제 (Problem)
VectorGuard 데몬이 Docker Desktop 환경에서 시작 시 eBPF 프로그램 로드에 실패:
근본 원인 (Root Cause)
3가지 버그가 동시에 존재:
컴파일러 생성
memset서브프로그램 호출[u8; 256],ExecPayload등) 초기화 시memset함수 호출을 자동 생성EINVAL에러의 직접적 원인bpf_probe_read_kernel로 userspace sockaddr 읽기 (handle_net_connect)sockaddr는 userspace 메모리인데bpf_probe_read_kernel(kernel 주소 공간)로 읽고 있었음bpf_probe_read_user_str_bytes로 바이너리 구조체 읽기 (handle_net_connect)sockaddr_in구조체를 문자열 읽기 함수로 읽으면 null 바이트(0x00)에서 멈춤AF_INET(0x0002)의 두 번째 바이트가 0x00이므로 2바이트만 읽힘해결 (Solution)
수정된 파일
vectorguard-ebpf/src/main.rs.cargo/config.toml--btf링커 플래그 제거vectorguard-ebpf/.cargo/config.toml--btf링커 플래그 제거Dockerfile.test(신규)test_e2e_docker.sh(신규)핵심 수정 내용
1. 스택 버퍼 제거 → 링 버퍼 직접 쓰기
2. sockaddr 읽기: kernel → user 주소 공간 + 고정 길이 읽기
3. 에러 핸들링: fail-closed → fail-open
4. 블로킹 순서 변경: signal 전에 이벤트 기록
영향도 분석 (Impact Analysis)
동작 변경사항
bprm_check_security-EPERM리턴0(allow)file_open-EPERM리턴0(allow)handle_file_open블로킹SIGKILLhandle_net_connect블로킹SIGKILLSIGKILL--btf링커 플래그영향받는 컴포넌트
보안 영향
테스트
테스트 환경
--privileged --pid=host -v /sys/fs/bpf:/sys/fs/bpfBinary Search 디버깅 과정
return 0(스텁)E2E 테스트 결과: 17/17 PASS, 0 WARN
테스트 실행 방법
docker build -f Dockerfile.test -t vectorguard-test . docker run --rm --privileged --pid=host -v /sys/fs/bpf:/sys/fs/bpf vectorguard-testTODO (후속 작업)