diff options
author | dcashman <dcashman@google.com> | 2016-02-29 12:57:54 -0800 |
---|---|---|
committer | dcashman <dcashman@google.com> | 2016-02-29 13:55:44 -0800 |
commit | cdc89940cc87d795157b4090a7b9ef5ada14e829 (patch) | |
tree | e7391e243d000656520dc6e376426085b4cdecb1 | |
parent | 034c53e93a736f8b6f9aac90938ef65ffcaac9da (diff) | |
download | libselinux-cdc89940cc87d795157b4090a7b9ef5ada14e829.tar.gz |
BACKPORT: libselinux: procattr: return einval for <= 0 pid args.
getpidcon documentation does not specify that a pid of 0 refers to the
current process, and getcon exists specifically to provide this
functionality, and getpidcon(getpid()) would provide it as well.
Disallow pid values <= 0 that may lead to unintended behavior in
userspace object managers.
(from upstream commit: c7cf5d8aa061b9616bf9d5e91139ce4fb40f532c)
Signed-off-by: Daniel Cashman <dcashman@android.com>
AOSP Bug: 200617
Bug: 271114815
Change-Id: If8ce0b9aea8f001f5c42911f2fccb2edfe9ded38
-rw-r--r-- | src/procattr.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/procattr.c b/src/procattr.c index a55465a..74c0012 100644 --- a/src/procattr.c +++ b/src/procattr.c @@ -139,7 +139,12 @@ static int setprocattrcon(const char * context, #define getpidattr_def(fn, attr) \ int get##fn(pid_t pid, char **c) \ { \ - return getprocattrcon(c, pid, #attr); \ + if (pid <= 0) { \ + errno = EINVAL; \ + return -1; \ + } else { \ + return getprocattrcon(c, pid, #attr); \ + } \ } all_selfattr_def(con, current) |