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

s390x cgroupv2 runc error #2316

Closed
ghost opened this issue Apr 15, 2020 · 19 comments
Closed

s390x cgroupv2 runc error #2316

ghost opened this issue Apr 15, 2020 · 19 comments

Comments

@ghost
Copy link

ghost commented Apr 15, 2020

@AkihiroSuda @giuseppe @kolyshkin

Using the latest upstream kernel and runc. s390x could not start runc with cgroupv2.

runc spec
runc run root

WARN[0001] signal: killed
ERRO[0001] container_linux.go:349: starting container process caused "process_linux.go:439: container init caused "process_linux.go:405: setting cgroup config for procHooks process caused \"error while setting cgroup v2: [can't load program:\\n github.com/cilium/ebpf.newProgramWithBTF\\n /root/go/pkg/mod/github.com/cilium/[email protected]/prog.go:151\\n - permission denied: 0: (69) r1 = *(u16 *)(r2 +0)\\nR2 !read_ok\\nprocessed 1 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0]\"""
container_linux.go:349: starting container process caused "process_linux.go:439: container init caused "process_linux.go:405: setting cgroup config for procHooks process caused \"error while setting cgroup v2: [can't load program:\\n github.com/cilium/ebpf.newProgramWithBTF\\n /root/go/pkg/mod/github.com/cilium/[email protected]/prog.go:151\\n - permission denied: 0: (69) r1 = *(u16 *)(r2 +0)\\nR2 !read_ok\\nprocessed 1 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0]\"""

@AkihiroSuda
Copy link
Member

Rootful or rootless?
Also make sure CONFIG_CGROUP_BPF=y CONFIG_CGROUP_DEVICE=y

@ghost
Copy link
Author

ghost commented Apr 15, 2020

Just root. Having all the configs. The thing is that it passed for all other arches here except s390x.

grep BPF linux/.config
CONFIG_CGROUP_BPF=y
CONFIG_BPF=y
CONFIG_BPF_SYSCALL=y

grep CGROUP linux/.config
CONFIG_CGROUPS=y
CONFIG_BLK_CGROUP=y
CONFIG_CGROUP_WRITEBACK=y
CONFIG_CGROUP_SCHED=y
CONFIG_CGROUP_PIDS=y
CONFIG_CGROUP_RDMA=y
CONFIG_CGROUP_FREEZER=y
CONFIG_CGROUP_HUGETLB=y
CONFIG_CGROUP_DEVICE=y
CONFIG_CGROUP_CPUACCT=y
CONFIG_CGROUP_PERF=y
CONFIG_CGROUP_BPF=y
CONFIG_CGROUP_DEBUG=y
CONFIG_SOCK_CGROUP_DATA=y

@AkihiroSuda
Copy link
Member

cc @estesp

@estesp
Copy link
Contributor

estesp commented Apr 15, 2020

@alicefr do you know who might be able to look into this? @CAILCA what distro is running on your s390x partition?

@ghost
Copy link
Author

ghost commented Apr 15, 2020

@alicefr do you know who might be able to look into this? @CAILCA what distro is running on your s390x partition?

RHEL 8.1+ but with the latest upstream kernel and runc.

@alicefr
Copy link

alicefr commented Apr 16, 2020

Hi @estesp , I can try to reproduce it on my system. @CAILCA can you please describe more in detail:
1- Which kernel have you used and how did you install it?
2- Which kernel parameters have you used?
3- Which runc version?
4- If you can paste the entire kernel config

@giuseppe
Copy link
Member

I think the issue is in the eBPF code.

runc probably needs the equivalent of: containers/crun@07bae05

@alicefr
Copy link

alicefr commented Apr 16, 2020

ouch @giuseppe good catch!I'll have a try

@alicefr
Copy link

alicefr commented Apr 16, 2020

I was able to reproduce the issue on a Fedora 31 with default kernel and upstream runc. I'll have a closer look

@alicefr
Copy link

alicefr commented Apr 16, 2020

@giuseppe I tried to apply the change you suggest:

git diff
diff --git a/libcontainer/cgroups/ebpf/devicefilter/devicefilter.go b/libcontainer/cgroups/ebpf/devicefilter/devicefilter.go
index 847ce8ef..18f7e4d1 100644
--- a/libcontainer/cgroups/ebpf/devicefilter/devicefilter.go
+++ b/libcontainer/cgroups/ebpf/devicefilter/devicefilter.go
@@ -49,7 +49,8 @@ func (p *program) init() {
        */
        // R2 <- type (lower 16 bit of u32 access_type at R1[0])
        p.insts = append(p.insts,
-               asm.LoadMem(asm.R2, asm.R1, 0, asm.Half))
+               asm.LoadMem(asm.R2, asm.R1, 0, asm.Word),
+               asm.And.Imm32(asm.R2, 0xFFFF))
 
        // R3 <- access (upper 16 bit of u32 access_type at R1[0])
        p.insts = append(p.insts,

but I still get the same behavior.

@giuseppe
Copy link
Member

Are you able to run a different eBPF program on Fedora (e.g. yum install -y bcc-tools && /usr/share/bcc/tools/execsnoop)?

On x86_64 I had to disable secure boot for eBPF to work

@alicefr
Copy link

alicefr commented Apr 17, 2020

@giuseppe yes, I'm able to execute it without any further configurations.

@alicefr
Copy link

alicefr commented Apr 17, 2020

strace output
strace-output.txt

@alicefr
Copy link

alicefr commented Apr 17, 2020

I also tried to run crun and that works without any problems. So, it must be an issue with runc/ebpf go library

@alicefr
Copy link

alicefr commented Apr 17, 2020

it is an issue in the ebpf library:
I run a test:

go test -run TestProgramRun
--- FAIL: TestProgramRun (0.00s)
    prog_test.go:50:     0: LdXMemW dst: r2 src: r1 off: 4 imm: 0
             1: LdXMemW dst: r1 src: r1 off: 0 imm: 0
             2: MovReg dst: r3 src: r1
             3: AddImm dst: r3 imm: 14
             4: JGTReg dst: r3 off: -1 src: r2 <out>
             5: StMemB dst: r1 src: r0 off: 0 imm: 222
             6: StMemB dst: r1 src: r0 off: 1 imm: 173
             7: StMemB dst: r1 src: r0 off: 2 imm: 190
             8: StMemB dst: r1 src: r0 off: 3 imm: 239
        out:
             9: LdImmDW dst: r0 imm: 42
            11: Exit
        
    prog_test.go:59: can't load program: permission denied: 0: (61) r1 = *(u32 *)(r2 +4)
        R2 !read_ok
        processed 1 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0
FAIL
exit status 1
FAIL    github.com/cilium/ebpf  0.001s
Collapse

@alicefr
Copy link

alicefr commented Apr 17, 2020

Open an issue in the ebpf repository cilium/ebpf#86

@alicefr
Copy link

alicefr commented Apr 24, 2020

So, we have a fix for runc. This requires a fix in the clium/ebpf library (a PR will follow) and this fix. This PR #2381 fixes the same issues as @giuseppe already reported and it is based on his work

@alicefr
Copy link

alicefr commented May 4, 2020

Ebpf PR to fix registers on s390x: cilium/ebpf#91

alicefr pushed a commit to alicefr/runc that referenced this issue May 8, 2020
Update ebpf to include PR cilium/ebpf#91.
The update is needed to fix opencontainers#2316.

Signed-off-by: Alice Frosi <[email protected]>
alicefr pushed a commit to alicefr/runc that referenced this issue May 8, 2020
Update ebpf to include PR cilium/ebpf#91.
The update is needed to fix opencontainers#2316.

Signed-off-by: Alice Frosi <[email protected]>
@alicefr
Copy link

alicefr commented May 8, 2020

cilium/ebpf#91 was merged. #2389 update the github.com/cilium/ebpf package

@cyphar cyphar closed this as completed in 828e4ad May 8, 2020
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 a pull request may close this issue.

4 participants