From c2dd01c73922bd4c01a114c4b2199c677c953fdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Fri, 1 Sep 2023 21:02:36 +0000 Subject: [PATCH] BpfHandler: U requires 4.14+, V requires 4.19+ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test: TreeHugger Signed-off-by: Maciej Żenczykowski Change-Id: I3f6440dfe3eb71fbe845eb70c0a6c53110f8d46f --- netd/BpfHandler.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/netd/BpfHandler.cpp b/netd/BpfHandler.cpp index 73feee41d1..fc680d9712 100644 --- a/netd/BpfHandler.cpp +++ b/netd/BpfHandler.cpp @@ -76,6 +76,19 @@ static Status checkProgramAccessible(const char* programPath) { } static Status initPrograms(const char* cg2_path) { + // This code was mainlined in T, so this should be trivially satisfied. + if (!modules::sdklevel::IsAtLeastT()) abort(); + + // S requires eBPF support which was only added in 4.9, so this should be satisfied. + if (!bpf::isAtLeastKernelVersion(4, 9, 0)) abort(); + + // U bumps the kernel requirement up to 4.14 + if (modules::sdklevel::IsAtLeastU() && !bpf::isAtLeastKernelVersion(4, 14, 0)) abort(); + + // V bumps the kernel requirement up to 4.19 + if (modules::sdklevel::IsAtLeastV() && !bpf::isAtLeastKernelVersion(4, 19, 0)) abort(); + + // U mandates this mount point (though it should also be the case on T) if (modules::sdklevel::IsAtLeastU() && !!strcmp(cg2_path, "/sys/fs/cgroup")) abort(); unique_fd cg_fd(open(cg2_path, O_DIRECTORY | O_RDONLY | O_CLOEXEC));