Skip to content

Commit

Permalink
Merge pull request #71 from bytedance/update-profile-template
Browse files Browse the repository at this point in the history
feat: Add new rules to the profile templates
  • Loading branch information
Danny-Wei committed Apr 29, 2024
2 parents bd028d9 + dea87f4 commit 26c72ef
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
17 changes: 15 additions & 2 deletions internal/profile/apparmor/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ profile %s flags=(attach_disconnected,mediate_deleted) {
const runtimeDefaultTemplate = `
## == Managed by vArmor == ##
abi <abi/3.0>,
#include <tunables/global>
profile %s flags=(attach_disconnected,mediate_deleted) {
Expand All @@ -79,6 +80,10 @@ profile %s flags=(attach_disconnected,mediate_deleted) {
# host (privileged) processes may send signals to container processes.
signal (receive) peer=unconfined,
# runc may send signals to container processes.
signal (receive) peer=runc,
# crun may send signals to container processes.
signal (receive) peer=crun,
# container processes may send signals amongst themselves.
signal (send,receive) peer=%s,
Expand All @@ -103,9 +108,11 @@ profile %s flags=(attach_disconnected,mediate_deleted) {
deny /sys/fs/c[^g]*/** wklx,
deny /sys/fs/cg[^r]*/** wklx,
deny /sys/firmware/** rwklx,
deny /sys/devices/virtual/powercap/** rwklx,
deny /sys/kernel/security/** rwklx,
# suppress ptrace denials when using 'docker ps' or using 'ps' inside a container
# allow processes within the container to trace each other,
# provided all other LSM and yama setting allow it.
ptrace (trace,read,tracedby,readby) peer=%s,
%s
Expand All @@ -127,8 +134,13 @@ profile %s flags=(attach_disconnected,mediate_deleted) {
file,
umount,
# host (privileged) processes may send signals to container processes.
signal (receive) peer=unconfined,
# processes with child profile may receive signals from processes with parent profile
# runc may send signals to container processes.
signal (receive) peer=runc,
# crun may send signals to container processes.
signal (receive) peer=crun,
# processes with child profile may receive signals from processes with parent profile.
signal (receive) peer=%s,
# processes with child profile may send signals amongst themselves.
signal (send,receive) peer=%s,
Expand All @@ -150,6 +162,7 @@ profile %s flags=(attach_disconnected,mediate_deleted) {
deny /sys/fs/c[^g]*/** wklx,
deny /sys/fs/cg[^r]*/** wklx,
deny /sys/firmware/** rwklx,
deny /sys/devices/virtual/powercap/** rwklx,
deny /sys/kernel/security/** rwklx,
# processes with parent profile may ptrace processes with child profile, but not vice versa.
Expand Down
6 changes: 6 additions & 0 deletions internal/profile/bpf/bpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ func GenerateRuntimeDefaultProfile(bpfContent *varmor.BpfContent) error {
}
bpfContent.Files = append(bpfContent.Files, *fileContent)

fileContent, err = newBpfPathRule("/sys/devices/virtual/powercap/**", AaMayRead|AaMayWrite|AaMayAppend)
if err != nil {
return err
}
bpfContent.Files = append(bpfContent.Files, *fileContent)

fileContent, err = newBpfPathRule("/sys/kernel/security/**", AaMayRead|AaMayWrite|AaMayAppend)
if err != nil {
return err
Expand Down

0 comments on commit 26c72ef

Please sign in to comment.