0
0
mirror of https://github.com/ponces/treble_aosp.git synced 2025-04-22 20:45:46 +00:00
Files
treble_aosp/patches/trebledroid/platform_packages_modules_Connectivity/0008-Additional-bpf-prevent-crash.patch
2025-04-01 00:51:53 +00:00

65 lines
2.9 KiB
Diff

From 1ce5c31bcc421fc59432ace6e989678a9f37474b Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Thu, 17 Oct 2024 06:59:48 -0400
Subject: [PATCH 8/8] Additional bpf prevent-crash
---
framework/src/android/net/BpfNetMapsUtils.java | 9 ++++-----
.../src/com/android/server/net/NetworkStatsService.java | 3 ++-
service/src/com/android/server/BpfNetMaps.java | 1 +
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/framework/src/android/net/BpfNetMapsUtils.java b/framework/src/android/net/BpfNetMapsUtils.java
index 408294ce6d..287116a076 100644
--- a/framework/src/android/net/BpfNetMapsUtils.java
+++ b/framework/src/android/net/BpfNetMapsUtils.java
@@ -271,15 +271,14 @@ public class BpfNetMapsUtils {
return BLOCKED_REASON_NONE;
}
- final long uidRuleConfig;
- final long uidMatch;
+ long uidRuleConfig = 0;
+ long uidMatch = 0;
try {
uidRuleConfig = configurationMap.getValue(UID_RULES_CONFIGURATION_KEY).val;
final UidOwnerValue value = uidOwnerMap.getValue(new Struct.S32(uid));
uidMatch = (value != null) ? value.rule : 0L;
- } catch (ErrnoException e) {
- throw new ServiceSpecificException(e.errno,
- "Unable to get firewall chain status: " + Os.strerror(e.errno));
+ } catch (Throwable e) {
+ android.util.Log.e("BpfNetMapsUtils", "Unable to get firewall chain status");
}
final long blockingMatches = (uidRuleConfig & ~uidMatch & sMaskDropIfUnset)
| (uidRuleConfig & uidMatch & sMaskDropIfSet);
diff --git a/service-t/src/com/android/server/net/NetworkStatsService.java b/service-t/src/com/android/server/net/NetworkStatsService.java
index 01ba86cb35..8db8bab1d8 100644
--- a/service-t/src/com/android/server/net/NetworkStatsService.java
+++ b/service-t/src/com/android/server/net/NetworkStatsService.java
@@ -3391,7 +3391,8 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
try {
return mStatsFactory.readNetworkStatsDetail(uid, ifaces, tag);
} catch (IOException e) {
- throw new IllegalStateException(e);
+ android.util.Log.e("NetworkStatsService", "Failed grabbing network stats");
+ return new NetworkStats(1, 0);
}
}
diff --git a/service/src/com/android/server/BpfNetMaps.java b/service/src/com/android/server/BpfNetMaps.java
index 8c11e115cc..2f8fbab52f 100644
--- a/service/src/com/android/server/BpfNetMaps.java
+++ b/service/src/com/android/server/BpfNetMaps.java
@@ -839,6 +839,7 @@ public class BpfNetMaps {
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
public int getNetPermForUid(final int uid) {
final int appId = UserHandle.getAppId(uid);
+ if (sUidPermissionMap == null) return PERMISSION_INTERNET;
try {
// Key of uid permission map is appId
// TODO: Rename map name
--
2.43.0