[cgroups2] Fix allow deny semantics for device access.

Currently, the EBPF program we generate has the behavior where the deny
list has no effect, as we will allow device access iff the device
matched with an allow entry.

Instead we want to grant access to a device iff it is in a cgroup's
allow list *and not in its deny list.*

This means that we need to change our existing logic, which exits on the
first match. It is not our desired behavior because the current EBPF
program construction logic puts the allow-device checks before the
deny-device checks, meaning that if a device is on both allow and deny
lists for a cgroup, it will be granted access.

This change revamps the EBPF program construction to now check both the
allow and deny list of a cgroup before determining whether access may be
granted. Specifically, if a device is matched with an entry inside the
allow list, we will also be checking if it matches with any entry on
the deny list, and deny the device's access if that is the case.

We also avoid generating specific parts of the EBPF program code to
avoid creating unreachable code, explanations with a diagram are
attached above the cgroups2::devices::DeviceProgram::build function.

Review: https://reviews.apache.org/r/75026/
5 files changed
tree: e1d1bceff4de124d934a64a97e650e48048ac017
  1. 3rdparty/
  2. bin/
  3. cmake/
  4. docs/
  5. include/
  6. m4/
  7. site/
  8. src/
  9. support/
  10. .asf.yaml
  11. .gitattributes
  12. bootstrap
  13. CHANGELOG
  14. CMakeLists.txt
  15. configure.ac
  16. Doxyfile
  17. LICENSE
  18. Makefile.am
  19. mesos.pc.in
  20. NOTICE
  21. README.md
README.md

Apache Mesos

Apache Mesos is a cluster manager that provides efficient resource isolation and sharing across distributed applications, or frameworks. It can run Hadoop, Jenkins, Spark, Aurora, and other frameworks on a dynamically shared pool of nodes.

Visit us at mesos.apache.org.

Mailing Lists

Documentation

Documentation is available in the docs/ directory. Additionally, a rendered HTML version can be found on the Mesos website's Documentation page.

Installation

Instructions are included on the Getting Started page.

License

Apache Mesos is licensed under the Apache License, Version 2.0.

For additional information, see the LICENSE and NOTICE files.