aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Lawrence <paullawrence@google.com>2023-07-17 17:36:04 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-07-17 17:36:04 +0000
commit6a53c1a805017d6ec367803c0f4c1df601827911 (patch)
tree6baba7328151044f116f8e1064bf572ec8d687e3
parentdd61d544457eb6ba1f16ffc7ec7c474882fe7d14 (diff)
parentaf594059f43953388c5e2c9c8058f813e1815532 (diff)
downloadbionic-6a53c1a805017d6ec367803c0f4c1df601827911.tar.gz
Revert "Fix deadlock caused by two-threaded property controls" am: d1076eb728 am: af594059f4
Original change: https://googleplex-android-review.googlesource.com/c/platform/bionic/+/24028888 Change-Id: I34cea5ef684642bbf904cac4bf32403afaae2d19 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--libc/bionic/system_property_set.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/libc/bionic/system_property_set.cpp b/libc/bionic/system_property_set.cpp
index 845ff27e6..bde0c1002 100644
--- a/libc/bionic/system_property_set.cpp
+++ b/libc/bionic/system_property_set.cpp
@@ -55,24 +55,16 @@ static const char* kServiceVersionPropertyName = "ro.property_service.version";
class PropertyServiceConnection {
public:
- PropertyServiceConnection(const char* name) : last_error_(0) {
+ PropertyServiceConnection() : last_error_(0) {
socket_.reset(::socket(AF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0));
if (socket_.get() == -1) {
last_error_ = errno;
return;
}
- // If we're trying to set "sys.powerctl" from a privileged process, use the special
- // socket. Because this socket is only accessible to privileged processes, it can't
- // be DoSed directly by malicious apps. (The shell user should be able to reboot,
- // though, so we don't just always use the special socket for "sys.powerctl".)
- // See b/262237198 for context
- const char* socket = property_service_socket;
- if (strcmp(name, "sys.powerctl") == 0 &&
- access(property_service_for_system_socket, W_OK) == 0) {
- socket = property_service_for_system_socket;
- }
-
+ const char* socket = access(property_service_for_system_socket, W_OK) == 0
+ ? property_service_for_system_socket
+ : property_service_socket;
const size_t namelen = strlen(socket);
sockaddr_un addr;
memset(&addr, 0, sizeof(addr));
@@ -189,7 +181,7 @@ struct prop_msg {
};
static int send_prop_msg(const prop_msg* msg) {
- PropertyServiceConnection connection(msg->name);
+ PropertyServiceConnection connection;
if (!connection.IsValid()) {
return connection.GetLastError();
}
@@ -282,7 +274,7 @@ int __system_property_set(const char* key, const char* value) {
// New protocol only allows long values for ro. properties only.
if (strlen(value) >= PROP_VALUE_MAX && strncmp(key, "ro.", 3) != 0) return -1;
// Use proper protocol
- PropertyServiceConnection connection(key);
+ PropertyServiceConnection connection;
if (!connection.IsValid()) {
errno = connection.GetLastError();
async_safe_format_log(