diff options
| author | 2023-01-09 10:42:58 +0000 | |
|---|---|---|
| committer | 2023-01-09 10:42:58 +0000 | |
| commit | d5e8cb6d96535f812e23040993169fa85a271c40 (patch) | |
| tree | 161b265ad6055b369bfaf56fb001feaf0fdb1a03 | |
| parent | 9a310e7e8d73851fde5b1d1b75e6f64aad612cb5 (diff) | |
| parent | 9f8967f5efcac4acba5379d733b99b1a4d20b004 (diff) | |
Merge "Set CLOEXEC on socket inherited from init" am: 4cd0373251 am: f00fc84870 am: 9f8967f5ef
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2375739
Change-Id: Ic03d3391945c67d6259ddb53b9b8cf76a39d3fe2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | libs/binder/libbinder_rpc_unstable.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libs/binder/libbinder_rpc_unstable.cpp b/libs/binder/libbinder_rpc_unstable.cpp index 78dae4bd1f..e7943ddf2f 100644 --- a/libs/binder/libbinder_rpc_unstable.cpp +++ b/libs/binder/libbinder_rpc_unstable.cpp @@ -112,6 +112,13 @@ ARpcServer* ARpcServer_newInitUnixDomain(AIBinder* service, const char* name) { LOG(ERROR) << "Failed to get fd for the socket:" << name; return nullptr; } + // Control socket fds are inherited from init, so they don't have O_CLOEXEC set. + // But we don't want any child processes to inherit the socket we are running + // the server on, so attempt to set the flag now. + if (fcntl(fd, F_SETFD, FD_CLOEXEC) != 0) { + LOG(WARNING) << "Failed to set CLOEXEC on control socket with name " << name + << " error: " << errno; + } if (status_t status = server->setupRawSocketServer(std::move(fd)); status != OK) { LOG(ERROR) << "Failed to set up Unix Domain RPC server with name " << name << " error: " << statusToString(status).c_str(); |