summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-04-18 19:09:18 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-04-18 19:09:18 +0000
commitb45c8ad05be4f1800fbb0b752a416896b802e93e (patch)
treecdcd78070b26f297a73443ad2bdccb5b62662509
parenta078141ec8b073fd90796b98bd501f2a3a41e12c (diff)
parent7d9d171e4ed5121c249a724898c96f7fba8ac760 (diff)
downloadcore-b45c8ad05be4f1800fbb0b752a416896b802e93e.tar.gz
Merge changes Ie74b9c27,If2224475 into main
* changes: libprocessgroup: Check validity of uid and pid arguments for createProcessGroup Revert "libprocessgroup: Check validity of uid and pid arguments"
-rw-r--r--libprocessgroup/processgroup.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/libprocessgroup/processgroup.cpp b/libprocessgroup/processgroup.cpp
index 8df2805d9..387c104ff 100644
--- a/libprocessgroup/processgroup.cpp
+++ b/libprocessgroup/processgroup.cpp
@@ -520,8 +520,14 @@ static populated_status cgroupIsPopulated(int events_fd) {
static int KillProcessGroup(
uid_t uid, pid_t initialPid, int signal, bool once = false,
std::chrono::steady_clock::time_point until = std::chrono::steady_clock::now() + 2200ms) {
- CHECK_GE(uid, 0);
- CHECK_GT(initialPid, 0);
+ if (uid < 0) {
+ LOG(ERROR) << __func__ << ": invalid UID " << uid;
+ return -1;
+ }
+ if (initialPid <= 0) {
+ LOG(ERROR) << __func__ << ": invalid PID " << initialPid;
+ return -1;
+ }
// Always attempt to send a kill signal to at least the initialPid, at least once, regardless of
// whether its cgroup exists or not. This should only be necessary if a bug results in the
@@ -681,8 +687,14 @@ static int createProcessGroupInternal(uid_t uid, pid_t initialPid, std::string c
}
int createProcessGroup(uid_t uid, pid_t initialPid, bool memControl) {
- CHECK_GE(uid, 0);
- CHECK_GT(initialPid, 0);
+ 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";