From ce66750cb68e8d61fa3d1ba94e496934c1eeae13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Thu, 14 Sep 2023 08:15:28 +0000 Subject: [PATCH] bpfloader: require 64-bit userspace on 6.2+ kernels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is safe as there are no LTS 6.2+ kernels yet. Test: TreeHugger Signed-off-by: Maciej Żenczykowski Change-Id: I2766ee9eb54017451a301b4d7dcf81368fb41723 --- bpfloader/BpfLoader.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/bpfloader/BpfLoader.cpp b/bpfloader/BpfLoader.cpp index f2318c1..99a2ab4 100644 --- a/bpfloader/BpfLoader.cpp +++ b/bpfloader/BpfLoader.cpp @@ -256,6 +256,30 @@ int main(int argc, char** argv) { return 1; } + if (android::bpf::isUserspace32bit() && android::bpf::isAtLeastKernelVersion(6, 2, 0)) { + /* Android 14/U should only launch on 64-bit kernels + * T launches on 5.10/5.15 + * U launches on 5.15/6.1 + * So >=5.16 implies isKernel64Bit() + * + * We thus added a test to V VTS which requires 5.16+ devices to use 64-bit kernels. + * + * Starting with Android V, which is the first to support a post 6.1 Linux Kernel, + * we also require 64-bit userspace. + * + * There are various known issues with 32-bit userspace talking to various + * kernel interfaces (especially CAP_NET_ADMIN ones) on a 64-bit kernel. + * Some of these have userspace or kernel workarounds/hacks. + * Some of them don't... + * We're going to be removing the hacks. + * + * Additionally the 32-bit kernel jit support is poor, + * and 32-bit userspace on 64-bit kernel bpf ringbuffer compatibility is broken. + */ + ALOGE("64-bit userspace required on 6.2+ kernels."); + return 1; + } + // Ensure we can determine the Android build type. if (!android::bpf::isEng() && !android::bpf::isUser() && !android::bpf::isUserdebug()) { ALOGE("Failed to determine the build type: got %s, want 'eng', 'user', or 'userdebug'",