commit | c1124eff5b778c516fd26b70aec86a40f1035d6d | [log] [tgz] |
---|---|---|
author | Maciej Żenczykowski <maze@google.com> | Sat Feb 19 22:03:23 2022 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Sat Feb 19 22:03:23 2022 +0000 |
tree | 00efbb8289c237ad3e3953a93100a23ea09a8fb6 | |
parent | 47f0797eb02c04da86120aafcf6b8ed6c4623902 [diff] | |
parent | dd5a31eb2d46ae30c9089a246f856cc60a1b5298 [diff] |
Merge "Fix system_server crash while iterating CookieTagMap" am: dd5a31eb2d Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1990333 Change-Id: I04bd616a62ba77219c0ae812d2337e474b1fe2c2
diff --git a/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsService.java b/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsService.java index eeb56d0..b193623 100644 --- a/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsService.java +++ b/packages/ConnectivityT/service/src/com/android/server/net/NetworkStatsService.java
@@ -1875,7 +1875,13 @@ private void deleteKernelTagData(int uid) { try { mCookieTagMap.forEach((key, value) -> { - if (value.uid == uid) { + // If SkDestroyListener deletes the socket tag while this code is running, + // forEach will either restart iteration from the beginning or return null, + // depending on when the deletion happens. + // If it returns null, continue iteration to delete the data and in fact it would + // just iterate from first key because BpfMap#getNextKey would return first key + // if the current key is not exist. + if (value != null && value.uid == uid) { try { mCookieTagMap.deleteEntry(key); } catch (ErrnoException e) {