Merge "libbinder: RPC reject excess threads" am: 153f30b938
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1785490
Change-Id: Ief018c2febf3da6bad6e2bf74988dd687d3b8927
diff --git a/libs/binder/RpcSession.cpp b/libs/binder/RpcSession.cpp
index 254b99c..66f31b8 100644
--- a/libs/binder/RpcSession.cpp
+++ b/libs/binder/RpcSession.cpp
@@ -629,6 +629,12 @@
sp<RpcSession::RpcConnection> RpcSession::assignIncomingConnectionToThisThread(unique_fd fd) {
std::lock_guard<std::mutex> _l(mMutex);
+ if (mIncomingConnections.size() >= mMaxThreads) {
+ ALOGE("Cannot add thread to session with %zu threads (max is set to %zu)",
+ mIncomingConnections.size(), mMaxThreads);
+ return nullptr;
+ }
+
// Don't accept any more connections, some have shutdown. Usually this
// happens when new connections are still being established as part of a
// very short-lived session which shuts down after it already started