diff options
author | T.J. Mercier <tjmercier@google.com> | 2024-04-18 16:05:56 +0000 |
---|---|---|
committer | T.J. Mercier <tjmercier@google.com> | 2024-04-18 16:18:22 +0000 |
commit | 7d9d171e4ed5121c249a724898c96f7fba8ac760 (patch) | |
tree | 64e0df6ad388becd5bd5bf1bd5f5ba939a1329b0 | |
parent | 29e30f25b4f1efd639182eff8b9e7c5a49cf0ae6 (diff) | |
download | core-7d9d171e4ed5121c249a724898c96f7fba8ac760.tar.gz |
libprocessgroup: Check validity of uid and pid arguments for createProcessGroup
killProcessGroup already checks for validity of the uid and pid input
arguments. Also add this checking to createProcessGroup.
Bug: 333261173
Change-Id: Ie74b9c2716978cb5eb434af12e27945e29af876e
-rw-r--r-- | libprocessgroup/processgroup.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libprocessgroup/processgroup.cpp b/libprocessgroup/processgroup.cpp index 7c555708e..44d8e441d 100644 --- a/libprocessgroup/processgroup.cpp +++ b/libprocessgroup/processgroup.cpp @@ -695,6 +695,15 @@ static int createProcessGroupInternal(uid_t uid, pid_t initialPid, std::string c } int createProcessGroup(uid_t uid, pid_t initialPid, bool memControl) { + if (uid < 0) { + LOG(ERROR) << __func__ << ": invalid UID " << uid; + return -1; + } + if (initialPid <= 0) { + LOG(ERROR) << __func__ << ": invalid PID " << initialPid; + return -1; + } + if (memControl && !UsePerAppMemcg()) { LOG(ERROR) << "service memory controls are used without per-process memory cgroup support"; return -EINVAL; |