Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6 months worth of security patches! #2

Open
wants to merge 4 commits into
base: 12.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions libs/gui/LayerState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,27 @@ void DisplayState::merge(const DisplayState& other) {
}
}

void DisplayState::sanitize(int32_t permissions) {
if (what & DisplayState::eLayerStackChanged) {
if (!(permissions & layer_state_t::Permission::ACCESS_SURFACE_FLINGER)) {
what &= ~DisplayState::eLayerStackChanged;
ALOGE("Stripped attempt to set eLayerStackChanged in sanitize");
}
}
if (what & DisplayState::eDisplayProjectionChanged) {
if (!(permissions & layer_state_t::Permission::ACCESS_SURFACE_FLINGER)) {
what &= ~DisplayState::eDisplayProjectionChanged;
ALOGE("Stripped attempt to set eDisplayProjectionChanged in sanitize");
}
}
if (what & DisplayState::eSurfaceChanged) {
if (!(permissions & layer_state_t::Permission::ACCESS_SURFACE_FLINGER)) {
what &= ~DisplayState::eSurfaceChanged;
ALOGE("Stripped attempt to set eSurfaceChanged in sanitize");
}
}
}

void layer_state_t::sanitize(int32_t permissions) {
// TODO: b/109894387
//
Expand Down
1 change: 1 addition & 0 deletions libs/gui/include/gui/LayerState.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ struct DisplayState {

DisplayState();
void merge(const DisplayState& other);
void sanitize(int32_t permissions);

uint32_t what;
sp<IBinder> token;
Expand Down
12 changes: 10 additions & 2 deletions libs/sensor/ISensorServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ class BpSensorServer : public BpInterface<ISensorServer>
v.setCapacity(n);
while (n) {
n--;
reply.read(s);
if(reply.read(s) != OK) {
ALOGE("Failed to read reply from getSensorList");
v.clear();
break;
}
v.add(s);
}
return v;
Expand All @@ -84,7 +88,11 @@ class BpSensorServer : public BpInterface<ISensorServer>
v.setCapacity(n);
while (n) {
n--;
reply.read(s);
if(reply.read(s) != OK) {
ALOGE("Failed to read reply from getDynamicSensorList");
v.clear();
break;
}
v.add(s);
}
return v;
Expand Down
6 changes: 6 additions & 0 deletions libs/sensor/Sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,13 @@ bool Sensor::unflattenString8(void const*& buffer, size_t& size, String8& output
return false;
}
outputString8.setTo(static_cast<char const*>(buffer), len);

if (size < FlattenableUtils::align<4>(len)) {
ALOGE("Malformed Sensor String8 field. Should be in a 4-byte aligned buffer but is not.");
return false;
}
FlattenableUtils::advance(buffer, size, FlattenableUtils::align<4>(len));

return true;
}

Expand Down
15 changes: 15 additions & 0 deletions libs/sensor/SensorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ SensorManager& SensorManager::getInstanceForPackage(const String16& packageName)
return *sensorManager;
}

void SensorManager::removeInstanceForPackage(const String16& packageName) {
Mutex::Autolock _l(sLock);
auto iterator = sPackageInstances.find(packageName);
if (iterator != sPackageInstances.end()) {
SensorManager* sensorManager = iterator->second;
delete sensorManager;
sPackageInstances.erase(iterator);
}
}

SensorManager::SensorManager(const String16& opPackageName)
: mSensorList(nullptr), mOpPackageName(opPackageName), mDirectConnectionHandle(1) {
Mutex::Autolock _l(mLock);
Expand Down Expand Up @@ -162,6 +172,11 @@ status_t SensorManager::assertStateLocked() {

mSensors = mSensorServer->getSensorList(mOpPackageName);
size_t count = mSensors.size();
if (count == 0) {
ALOGE("Failed to get Sensor list");
mSensorServer.clear();
return UNKNOWN_ERROR;
}
mSensorList =
static_cast<Sensor const**>(malloc(count * sizeof(Sensor*)));
LOG_ALWAYS_FATAL_IF(mSensorList == nullptr, "mSensorList NULL");
Expand Down
1 change: 1 addition & 0 deletions libs/sensor/include/sensor/SensorManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class SensorManager : public ASensorManager
{
public:
static SensorManager& getInstanceForPackage(const String16& packageName);
static void removeInstanceForPackage(const String16& packageName);
~SensorManager();

ssize_t getSensorList(Sensor const* const** list);
Expand Down
3 changes: 3 additions & 0 deletions services/sensorservice/hidl/SensorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ SensorManager::~SensorManager() {
if (mPollThread.joinable()) {
mPollThread.join();
}

::android::SensorManager::removeInstanceForPackage(
String16(ISensorManager::descriptor));
}

// Methods from ::android::frameworks::sensorservice::V1_0::ISensorManager follow.
Expand Down
9 changes: 5 additions & 4 deletions services/surfaceflinger/SurfaceFlinger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3502,7 +3502,7 @@ void SurfaceFlinger::flushTransactionQueues() {
// to prevent onHandleDestroyed from being called while the lock is held,
// we must keep a copy of the transactions (specifically the composer
// states) around outside the scope of the lock
std::vector<const TransactionState> transactions;
std::vector<TransactionState> transactions;
// Layer handles that have transactions with buffers that are ready to be applied.
std::unordered_set<sp<IBinder>, ISurfaceComposer::SpHash<IBinder>> bufferLayersReadyToPresent;
{
Expand Down Expand Up @@ -3566,7 +3566,7 @@ void SurfaceFlinger::flushTransactionQueues() {
}

// Now apply all transactions.
for (const auto& transaction : transactions) {
for (auto& transaction : transactions) {
applyTransactionState(transaction.frameTimelineInfo, transaction.states,
transaction.displays, transaction.flags,
transaction.inputWindowCommands, transaction.desiredPresentTime,
Expand Down Expand Up @@ -3786,7 +3786,7 @@ status_t SurfaceFlinger::setTransactionState(

void SurfaceFlinger::applyTransactionState(const FrameTimelineInfo& frameTimelineInfo,
const Vector<ComposerState>& states,
const Vector<DisplayState>& displays, uint32_t flags,
Vector<DisplayState>& displays, uint32_t flags,
const InputWindowCommands& inputWindowCommands,
const int64_t desiredPresentTime, bool isAutoTimestamp,
const client_cache_t& uncacheBuffer,
Expand All @@ -3795,7 +3795,8 @@ void SurfaceFlinger::applyTransactionState(const FrameTimelineInfo& frameTimelin
const std::vector<ListenerCallbacks>& listenerCallbacks,
int originPid, int originUid, uint64_t transactionId) {
uint32_t transactionFlags = 0;
for (const DisplayState& display : displays) {
for (DisplayState& display : displays) {
display.sanitize(permissions);
transactionFlags |= setDisplayStateLocked(display);
}

Expand Down
2 changes: 1 addition & 1 deletion services/surfaceflinger/SurfaceFlinger.h
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ class SurfaceFlinger : public BnSurfaceComposer,
* Transactions
*/
void applyTransactionState(const FrameTimelineInfo& info, const Vector<ComposerState>& state,
const Vector<DisplayState>& displays, uint32_t flags,
Vector<DisplayState>& displays, uint32_t flags,
const InputWindowCommands& inputWindowCommands,
const int64_t desiredPresentTime, bool isAutoTimestamp,
const client_cache_t& uncacheBuffer, const int64_t postTime,
Expand Down