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

.rodata: map create: read- and write-only maps not supported (requires >= v5.2) #39

Closed
cfc4n opened this issue Apr 20, 2022 · 0 comments · Fixed by #40
Closed

.rodata: map create: read- and write-only maps not supported (requires >= v5.2) #39

cfc4n opened this issue Apr 20, 2022 · 0 comments · Fixed by #40

Comments

@cfc4n
Copy link
Member

cfc4n commented Apr 20, 2022

Describe the bug
cant load ebpf bytecode with cilium/ebpf library on linux kernel 4.18.0 while global variable used in kernel code.

To Reproduce

  1. git clone https://github.com/ehids/ecapture
  2. cd ecapture
  3. make nocore
  4. ./bin/ecapture tls
./bin/ecapture tls
loading objects: field UretprobeBashReadline: program uretprobe_bash_readline: map .rodata: map create: read- and write-only maps not supported (requires >= v5.2)

** DEBUG**

const volatile u64 target_pid declaration at
https://github.com/ehids/ecapture/blob/0787e297de3c9c78ea13fbc7aacc7d68b88ac367/kern/common.h#L23-L28

used at
https://github.com/ehids/ecapture/blob/0787e297de3c9c78ea13fbc7aacc7d68b88ac367/kern/openssl_kern.c#L157-L160

const volatile u64 target_pid = 0;

Expected behavior
It works with global variable in ebpf kernel function on linux kernel 4.18.

Additional context
seems like a cilium/ebpf bug ref cilium/ebpf#628 .

cfc4n added a commit that referenced this issue Apr 20, 2022
…ted (requires >= v5.2)

1,global variable declaration will compile to .rodata/.bss section in ELF file.
2, haveMapMutabilityModifiers function will create ARRAY type ebpf map with BPF_F_RDONLY_PROG flag to detect system support in syscalls.go .
3. so need to remove global variable on kernel version less than 5.2 via haveMapMutabilityModifiers in cilium/ebpf/syscalls.go
4. more info cilium/ebpf@f5942f5

Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
@cfc4n cfc4n closed this as completed in #40 Apr 21, 2022
cfc4n added a commit that referenced this issue Apr 21, 2022
* : Fix #39 .rodata: map create: read- and write-only maps not supported (requires >= v5.2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant