SurfaceFlinger: lock mStateLock when modifying allowed configs
mAllowedDisplayConfigs should be protected by mStateLock when changing
it from the main thread in setAllowedDisplayConfigsInternal() as it is
being read by Binder threads in getAllowedDisplayConfigs().
Test: call setAllowedDisplayConfigs() and getAllowedDisplayConfigs()
from backdoor using different threads.
Bug: 142850581
Change-Id: I569e75968aea676c96fbc648140ac49a165ffb69
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 0e33f10..ef9a598 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -5452,7 +5452,7 @@
return NO_ERROR;
}
- postMessageSync(new LambdaMessage([&]() NO_THREAD_SAFETY_ANALYSIS {
+ postMessageSync(new LambdaMessage([&]() {
const auto display = getDisplayDeviceLocked(displayToken);
if (!display) {
ALOGE("Attempt to set allowed display configs for invalid display token %p",
@@ -5460,6 +5460,7 @@
} else if (display->isVirtual()) {
ALOGW("Attempt to set allowed display configs for virtual display");
} else {
+ Mutex::Autolock lock(mStateLock);
setAllowedDisplayConfigsInternal(display, allowedConfigs);
}
}));