libprocessgroup: UIDs in linux are unsigned
We missed two incorrect specifiers in the previous commit with this same title. We use the %d format specificier for uid_t, which maps to __kernel_uid32_t, which is unsigned. [1] This is undefined behavior which can lead to paths with negative UIDs when erroneously large values are passed for uid: E libprocessgroup: No such cgroup attribute: /sys/fs/cgroup/uid_-89846/cgroup.freeze Fix it with %u. [1] https://cs.android.com/search?q=typedef.*__kernel_uid32_t&ss=android%2Fplatform%2Fsuperproject%2Fmain Change-Id: Ica04b03526bd2e156f026a2797fe9912b259cd9f
This commit is contained in:
parent
428622bb7f
commit
aa6158b410
1 changed files with 2 additions and 2 deletions
|
@ -206,11 +206,11 @@ bool SetUserProfiles(uid_t uid, const std::vector<std::string>& profiles) {
|
|||
}
|
||||
|
||||
static std::string ConvertUidToPath(const char* cgroup, uid_t uid) {
|
||||
return StringPrintf("%s/uid_%d", cgroup, uid);
|
||||
return StringPrintf("%s/uid_%u", cgroup, uid);
|
||||
}
|
||||
|
||||
static std::string ConvertUidPidToPath(const char* cgroup, uid_t uid, int pid) {
|
||||
return StringPrintf("%s/uid_%d/pid_%d", cgroup, uid, pid);
|
||||
return StringPrintf("%s/uid_%u/pid_%d", cgroup, uid, pid);
|
||||
}
|
||||
|
||||
static int RemoveProcessGroup(const char* cgroup, uid_t uid, int pid, unsigned int retries) {
|
||||
|
|
Loading…
Reference in a new issue