Fix transaction sanitization am: f1ad68a1a9
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/27325518
Change-Id: Ibc95ad2617e5ee972e5c6491f8fca8432181fd56
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index f4f4bcc..e5b3ec4 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -4518,7 +4518,7 @@
const int originPid = ipc->getCallingPid();
const int originUid = ipc->getCallingUid();
uint32_t permissions = LayerStatePermissions::getTransactionPermissions(originPid, originUid);
- for (auto composerState : states) {
+ for (auto& composerState : states) {
composerState.state.sanitize(permissions);
}
diff --git a/services/surfaceflinger/tests/Credentials_test.cpp b/services/surfaceflinger/tests/Credentials_test.cpp
index 69e9a16..2d18166 100644
--- a/services/surfaceflinger/tests/Credentials_test.cpp
+++ b/services/surfaceflinger/tests/Credentials_test.cpp
@@ -401,8 +401,13 @@
.apply();
}
- // Called from non privileged process
- Transaction().setTrustedOverlay(surfaceControl, true);
+ // Attempt to set a trusted overlay from a non-privileged process. This should fail silently.
+ {
+ UIDFaker f{AID_BIN};
+ Transaction().setTrustedOverlay(surfaceControl, true).apply(/*synchronous=*/true);
+ }
+
+ // Verify that the layer was not made a trusted overlay.
{
UIDFaker f(AID_SYSTEM);
auto windowIsPresentAndNotTrusted = [&](const std::vector<WindowInfo>& windowInfos) {
@@ -413,12 +418,14 @@
}
return !foundWindowInfo->inputConfig.test(WindowInfo::InputConfig::TRUSTED_OVERLAY);
};
- windowInfosListenerUtils.waitForWindowInfosPredicate(windowIsPresentAndNotTrusted);
+ ASSERT_TRUE(
+ windowInfosListenerUtils.waitForWindowInfosPredicate(windowIsPresentAndNotTrusted));
}
+ // Verify that privileged processes are able to set trusted overlays.
{
UIDFaker f(AID_SYSTEM);
- Transaction().setTrustedOverlay(surfaceControl, true);
+ Transaction().setTrustedOverlay(surfaceControl, true).apply(/*synchronous=*/true);
auto windowIsPresentAndTrusted = [&](const std::vector<WindowInfo>& windowInfos) {
auto foundWindowInfo =
WindowInfosListenerUtils::findMatchingWindowInfo(windowInfo, windowInfos);
@@ -427,7 +434,8 @@
}
return foundWindowInfo->inputConfig.test(WindowInfo::InputConfig::TRUSTED_OVERLAY);
};
- windowInfosListenerUtils.waitForWindowInfosPredicate(windowIsPresentAndTrusted);
+ ASSERT_TRUE(
+ windowInfosListenerUtils.waitForWindowInfosPredicate(windowIsPresentAndTrusted));
}
}