Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 43ab18e6 authored by dianlujitao's avatar dianlujitao Committed by Luca Stefani
Browse files

adb_root: Add mutex to binder interface

 * Binder IPC is not implemented in a thread-safe manner, add mutex to
   avoid possible race.

Change-Id: I37cdca33d519b0fc960960272790d1f55874e2e2
parent 2b525c22
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -58,6 +58,8 @@ binder::Status ADBRootService::setEnabled(bool enabled) {
    if (uid != AID_SYSTEM) {
        return SecurityException("Caller must be system");
    }

    AutoMutex _l(lock_);
    enabled_ = enabled;
    WriteStringToFile(std::to_string(enabled), kStoragePath + kEnabled);
    return binder::Status::ok();
@@ -68,6 +70,8 @@ binder::Status ADBRootService::getEnabled(bool* _aidl_return) {
    if (uid != AID_SYSTEM && uid != AID_SHELL) {
        return SecurityException("Caller must be system or shell");
    }

    AutoMutex _l(lock_);
    *_aidl_return = enabled_;
    return binder::Status::ok();
}
+1 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ class ADBRootService : public BinderService<ADBRootService>, public BnADBRootSer
    static char const* getServiceName() { return "adbroot_service"; }
  private:
    bool enabled_;
    Mutex lock_;
};

}  // namespace adbroot