Revert "Fix deadlock caused by two-threaded property controls"
This reverts commit aeddfc4aaf
.
These fixes for b/262208935 introduced a race condition. We believe the
race is fixed by ag/23879563, but at this point in the release feel that
reverting the fixes and refixing in main is the better solution
Test: Builds, boots
Bug: 283202477
Bug: 288991737
Ignore-AOSP-First: Reverting CL only in internal
Change-Id: If7e9e5f99728c2f3a18b08346b4cf3449132f920
This commit is contained in:
parent
9908b1e3c8
commit
d1076eb728
1 changed files with 6 additions and 14 deletions
|
@ -55,24 +55,16 @@ static const char* kServiceVersionPropertyName = "ro.property_service.version";
|
||||||
|
|
||||||
class PropertyServiceConnection {
|
class PropertyServiceConnection {
|
||||||
public:
|
public:
|
||||||
PropertyServiceConnection(const char* name) : last_error_(0) {
|
PropertyServiceConnection() : last_error_(0) {
|
||||||
socket_.reset(::socket(AF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0));
|
socket_.reset(::socket(AF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0));
|
||||||
if (socket_.get() == -1) {
|
if (socket_.get() == -1) {
|
||||||
last_error_ = errno;
|
last_error_ = errno;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're trying to set "sys.powerctl" from a privileged process, use the special
|
const char* socket = access(property_service_for_system_socket, W_OK) == 0
|
||||||
// socket. Because this socket is only accessible to privileged processes, it can't
|
? property_service_for_system_socket
|
||||||
// be DoSed directly by malicious apps. (The shell user should be able to reboot,
|
: property_service_socket;
|
||||||
// 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 size_t namelen = strlen(socket);
|
const size_t namelen = strlen(socket);
|
||||||
sockaddr_un addr;
|
sockaddr_un addr;
|
||||||
memset(&addr, 0, sizeof(addr));
|
memset(&addr, 0, sizeof(addr));
|
||||||
|
@ -189,7 +181,7 @@ struct prop_msg {
|
||||||
};
|
};
|
||||||
|
|
||||||
static int send_prop_msg(const prop_msg* msg) {
|
static int send_prop_msg(const prop_msg* msg) {
|
||||||
PropertyServiceConnection connection(msg->name);
|
PropertyServiceConnection connection;
|
||||||
if (!connection.IsValid()) {
|
if (!connection.IsValid()) {
|
||||||
return connection.GetLastError();
|
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.
|
// New protocol only allows long values for ro. properties only.
|
||||||
if (strlen(value) >= PROP_VALUE_MAX && strncmp(key, "ro.", 3) != 0) return -1;
|
if (strlen(value) >= PROP_VALUE_MAX && strncmp(key, "ro.", 3) != 0) return -1;
|
||||||
// Use proper protocol
|
// Use proper protocol
|
||||||
PropertyServiceConnection connection(key);
|
PropertyServiceConnection connection;
|
||||||
if (!connection.IsValid()) {
|
if (!connection.IsValid()) {
|
||||||
errno = connection.GetLastError();
|
errno = connection.GetLastError();
|
||||||
async_safe_format_log(
|
async_safe_format_log(
|
||||||
|
|
Loading…
Reference in a new issue