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

ebpf cgroupdev program: fix device permission check issue #229

Closed
wants to merge 4 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/nvcgo/internal/cgroup/ebpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ func (p *program) appendDevice(dev specs.LinuxDeviceCgroup, labelPrefix string)
}
if hasAccess {
p.insts = append(p.insts,
// if (R3 & bpfAccess == 0 /* use R2 as a temp var */) goto next
asm.Mov.Reg32(asm.R2, asm.R3),
asm.And.Imm32(asm.R2, bpfAccess),
asm.JEq.Imm(asm.R2, 0, nextBlockSym),
// if (R3 & bpfAccess != R3 /* use R6 as a temp var */) goto next
Copy link
Member

Choose a reason for hiding this comment

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

Let's use R1 to align with the crun and runc implementations

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

asm.Mov.Reg32(asm.R6, asm.R3),
asm.And.Imm32(asm.R6, bpfAccess),
asm.JNE.Reg32(asm.R6, asm.R3, nextBlockSym),
)
}
if hasMajor {
Expand Down