From 25e2622121288f92839210b0dd6f5e12c7fef13c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Thu, 20 Mar 2025 23:25:39 -0700 Subject: [PATCH] NetBpfLoad: 25Q2+ parse & verify config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test: TreeHugger Signed-off-by: Maciej Żenczykowski Change-Id: Ibe7560998655dfe36b5cc071a3405650ad684935 --- bpf/loader/NetBpfLoad.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bpf/loader/NetBpfLoad.cpp b/bpf/loader/NetBpfLoad.cpp index 4c47f83bbf..aca544aac6 100644 --- a/bpf/loader/NetBpfLoad.cpp +++ b/bpf/loader/NetBpfLoad.cpp @@ -1820,6 +1820,19 @@ static int doLoad(char** argv, char * const envp[]) { return 1; } + if (isAtLeast25Q2) { + FILE * f = fopen("/system/etc/init/netbpfload.rc", "re"); + if (!f) { + ALOGE("failure opening /system/etc/init/netbpfload.rc"); + return 1; + } + int y = -1, q = -1, a = -1, b = -1, c = -1; + int v = fscanf(f, "# %d %d %d %d %d #", &y, &q, &a, &b, &c); + ALOGI("detected %d of 5: %dQ%d api:%d.%d.%d", v, y, q, a, b, c); + fclose(f); + if (v != 5 || y != 2025 || q != 2 || a != 36 || b || c) return 1; + } + // Ensure we can determine the Android build type. if (!isEng() && !isUser() && !isUserdebug()) { ALOGE("Failed to determine the build type: got %s, want 'eng', 'user', or 'userdebug'",