1. 19 Feb, 2021 2 commits
    • apparmor: prefer /proc/.../attr/apparmor/current over legacy interface · 47f4914d
      Aleksa Sarai authored
      It turns out that since Linux 5.1 there are now per-LSM subdirectories
      for major LSMs, which users are recommended to use over the "legacy"
      top-level /proc/$pid/attr/... files[1]:
      
      > Process attributes associated with “major” security modules should be
      > accessed and maintained using the special files in /proc/.../attr. A
      > security module may maintain a module specific subdirectory there,
      > named after the module. /proc/.../attr/smack is provided by the Smack
      > security module and contains all its special files. The files directly
      > in /proc/.../attr remain as legacy interfaces for modules that provide
      > subdirectories.
      
      AppArmor has had such a directory since Linux 5.8[2], and it turns out
      that with certain CONFIG_LSM configurations you can end up with AppArmor
      files not being accessible from the legacy interface. Arch Linux
      recently added BPF as one of the enabled LSM in their configuration, and
      this broke runc[3] and LXC.
      
      The solution is to first try to use /proc/$pid/attr/apparmor/current and
      fall back to /proc/$pid/attr/current if the former is not available.
      
      [1]: https://www.kernel.org/doc/html/latest/admin-guide/LSM/index.html
      [2]: Linux 5.8 ; commit 6413f852ce08 ("apparmor: add proc subdir to attrs")
      [3]: https://github.com/opencontainers/runc/issues/2801Signed-off-by: 's avatarAleksa Sarai <cyphar@cyphar.com>
    • apparmor: clean up apparmor_process_label_get · 301a5f8e
      Aleksa Sarai authored
      Rather than open-coding file reading and retry semantics and
      implementing the path generation logic separately to
      apparmor_process_label_fd_get, refactor the logic so that it looks
      closer to the pidfd version.
      
      This will make it easier to implement the two-step handling for
      /proc/self/attr/apparmor/current and makes this code slightly less
      confusing.
      Signed-off-by: 's avatarAleksa Sarai <cyphar@cyphar.com>
  2. 18 Feb, 2021 35 commits
  3. 17 Feb, 2021 3 commits