github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/profiles/apparmor/template.go (about)

     1  // +build linux
     2  
     3  package apparmor // import "github.com/demonoid81/moby/profiles/apparmor"
     4  
     5  // baseTemplate defines the default apparmor profile for containers.
     6  const baseTemplate = `
     7  {{range $value := .Imports}}
     8  {{$value}}
     9  {{end}}
    10  
    11  profile {{.Name}} flags=(attach_disconnected,mediate_deleted) {
    12  {{range $value := .InnerImports}}
    13    {{$value}}
    14  {{end}}
    15  
    16    network,
    17    capability,
    18    file,
    19    umount,
    20  {{if ge .Version 208096}}
    21  {{/* Allow 'docker kill' to actually send signals to container processes. */}}
    22    signal (receive) peer={{.DaemonProfile}},
    23  {{/* Allow container processes to send signals amongst themselves. */}}
    24    signal (send,receive) peer={{.Name}},
    25  {{end}}
    26  
    27    deny @{PROC}/* w,   # deny write for all files directly in /proc (not in a subdir)
    28    # deny write to files not in /proc/<number>/** or /proc/sys/**
    29    deny @{PROC}/{[^1-9],[^1-9][^0-9],[^1-9s][^0-9y][^0-9s],[^1-9][^0-9][^0-9][^0-9]*}/** w,
    30    deny @{PROC}/sys/[^k]** w,  # deny /proc/sys except /proc/sys/k* (effectively /proc/sys/kernel)
    31    deny @{PROC}/sys/kernel/{?,??,[^s][^h][^m]**} w,  # deny everything except shm* in /proc/sys/kernel/
    32    deny @{PROC}/sysrq-trigger rwklx,
    33    deny @{PROC}/kcore rwklx,
    34  
    35    deny mount,
    36  
    37    deny /sys/[^f]*/** wklx,
    38    deny /sys/f[^s]*/** wklx,
    39    deny /sys/fs/[^c]*/** wklx,
    40    deny /sys/fs/c[^g]*/** wklx,
    41    deny /sys/fs/cg[^r]*/** wklx,
    42    deny /sys/firmware/** rwklx,
    43    deny /sys/kernel/security/** rwklx,
    44  
    45  {{if ge .Version 208095}}
    46    # suppress ptrace denials when using 'docker ps' or using 'ps' inside a container
    47    ptrace (trace,read,tracedby,readby) peer={{.Name}},
    48  {{end}}
    49  }
    50  `