summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author 张倞诚 <a591951062@gmail.com> 2024-03-20 08:40:41 +0000
committer 张倞诚 <a591951062@gmail.com> 2024-05-15 16:03:11 +0000
commita7d6c67474741bcf1c7dda5cc80a06210e549c7b (patch)
tree3515d7a9e8729acc72808b7780c9df2b64c9f8fd
parent3ff587dd766b0f870d2bb25ef97d45efa29f851f (diff)
Fix incorrect gid config leads to process/system cannot start.
We found that if the system application misconfigures the gid in the permissions, -1 will be added to the application's gid list, which will cause the application process or system startup to fail, so consider adding a check to prevent this unexpected situation. Change-Id: Ic3133067285ecfd9310b4bca56ff402180e7c2aa
-rw-r--r--services/core/java/com/android/server/SystemConfig.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/SystemConfig.java b/services/core/java/com/android/server/SystemConfig.java
index 79620cff2b24..1c1190fde049 100644
--- a/services/core/java/com/android/server/SystemConfig.java
+++ b/services/core/java/com/android/server/SystemConfig.java
@@ -1638,7 +1638,13 @@ public class SystemConfig {
String gidStr = parser.getAttributeValue(null, "gid");
if (gidStr != null) {
int gid = Process.getGidForName(gidStr);
- perm.gids = appendInt(perm.gids, gid);
+ if (gid != -1) {
+ perm.gids = appendInt(perm.gids, gid);
+ } else {
+ Slog.w(TAG, "<group> with unknown gid \""
+ + gidStr + " for permission " + name + " in "
+ + parser.getPositionDescription());
+ }
} else {
Slog.w(TAG, "<group> without gid at "
+ parser.getPositionDescription());