66f14e4ae9
The current docker-default AppArmor profile intends to block write access to everything in `/proc`, except for `/proc/<pid>` and `/proc/sys/kernel/shm*`. Currently the rules block access to everything in `/proc/sys`, and do not successfully allow access to `/proc/sys/kernel/shm*`. Specifically, a path like /proc/sys/kernel/shmmax matches this part of the pattern: deny @{PROC}/{[^1-9][^0-9][^0-9][^0-9]* }/** w, /proc / s y s / kernel /shmmax This patch updates the rule so that it works as intended. Closes #39791 Signed-off-by: Phil Sphicas <phil.sphicas@att.com>
59 lines
2 KiB
Go
59 lines
2 KiB
Go
//go:build linux
|
|
// +build linux
|
|
|
|
package apparmor // import "github.com/docker/docker/profiles/apparmor"
|
|
|
|
// NOTE: This profile is replicated in containerd and libpod. If you make a
|
|
// change to this profile, please make follow-up PRs to those projects so
|
|
// that these rules can be synchronised (because any issue with this
|
|
// profile will likely affect libpod and containerd).
|
|
// TODO: Move this to a common project so we can maintain it in one spot.
|
|
|
|
// baseTemplate defines the default apparmor profile for containers.
|
|
const baseTemplate = `
|
|
{{range $value := .Imports}}
|
|
{{$value}}
|
|
{{end}}
|
|
|
|
profile {{.Name}} flags=(attach_disconnected,mediate_deleted) {
|
|
{{range $value := .InnerImports}}
|
|
{{$value}}
|
|
{{end}}
|
|
|
|
network,
|
|
capability,
|
|
file,
|
|
umount,
|
|
{{if ge .Version 208096}}
|
|
# Host (privileged) processes may send signals to container processes.
|
|
signal (receive) peer=unconfined,
|
|
# dockerd may send signals to container processes (for "docker kill").
|
|
signal (receive) peer={{.DaemonProfile}},
|
|
# Container processes may send signals amongst themselves.
|
|
signal (send,receive) peer={{.Name}},
|
|
{{end}}
|
|
|
|
deny @{PROC}/* w, # deny write for all files directly in /proc (not in a subdir)
|
|
# deny write to files not in /proc/<number>/** or /proc/sys/**
|
|
deny @{PROC}/{[^1-9],[^1-9][^0-9],[^1-9s][^0-9y][^0-9s],[^1-9][^0-9][^0-9][^0-9/]*}/** w,
|
|
deny @{PROC}/sys/[^k]** w, # deny /proc/sys except /proc/sys/k* (effectively /proc/sys/kernel)
|
|
deny @{PROC}/sys/kernel/{?,??,[^s][^h][^m]**} w, # deny everything except shm* in /proc/sys/kernel/
|
|
deny @{PROC}/sysrq-trigger rwklx,
|
|
deny @{PROC}/kcore rwklx,
|
|
|
|
deny mount,
|
|
|
|
deny /sys/[^f]*/** wklx,
|
|
deny /sys/f[^s]*/** wklx,
|
|
deny /sys/fs/[^c]*/** wklx,
|
|
deny /sys/fs/c[^g]*/** wklx,
|
|
deny /sys/fs/cg[^r]*/** wklx,
|
|
deny /sys/firmware/** rwklx,
|
|
deny /sys/kernel/security/** rwklx,
|
|
|
|
{{if ge .Version 208095}}
|
|
# suppress ptrace denials when using 'docker ps' or using 'ps' inside a container
|
|
ptrace (trace,read,tracedby,readby) peer={{.Name}},
|
|
{{end}}
|
|
}
|
|
`
|