github.com/skanehira/moby@v17.12.1-ce-rc2+incompatible/profiles/apparmor/template.go (about)

     1  // +build linux
     2  
     3  package 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  
    21    deny @{PROC}/* w,   # deny write for all files directly in /proc (not in a subdir)
    22    # deny write to files not in /proc/<number>/** or /proc/sys/**
    23    deny @{PROC}/{[^1-9],[^1-9][^0-9],[^1-9s][^0-9y][^0-9s],[^1-9][^0-9][^0-9][^0-9]*}/** w,
    24    deny @{PROC}/sys/[^k]** w,  # deny /proc/sys except /proc/sys/k* (effectively /proc/sys/kernel)
    25    deny @{PROC}/sys/kernel/{?,??,[^s][^h][^m]**} w,  # deny everything except shm* in /proc/sys/kernel/
    26    deny @{PROC}/sysrq-trigger rwklx,
    27    deny @{PROC}/kcore rwklx,
    28  
    29    deny mount,
    30  
    31    deny /sys/[^f]*/** wklx,
    32    deny /sys/f[^s]*/** wklx,
    33    deny /sys/fs/[^c]*/** wklx,
    34    deny /sys/fs/c[^g]*/** wklx,
    35    deny /sys/fs/cg[^r]*/** wklx,
    36    deny /sys/firmware/** rwklx,
    37    deny /sys/kernel/security/** rwklx,
    38  
    39  {{if ge .Version 208095}}
    40    # suppress ptrace denials when using 'docker ps' or using 'ps' inside a container
    41    ptrace (trace,read) peer={{.Name}},
    42  {{end}}
    43  }
    44  `