diff options
author | dcashman <dcashman@android.com> | 2016-02-23 12:24:00 -0800 |
---|---|---|
committer | Stephen Smalley <sds@tycho.nsa.gov> | 2016-02-24 10:05:14 -0500 |
commit | c7cf5d8aa061b9616bf9d5e91139ce4fb40f532c (patch) | |
tree | 7507cdd18dd07fdc4760d990a0ce0ac5dcafa751 /libselinux/src/procattr.c | |
parent | ece9a6db474a01e531a891b00c970cb191f8c85a (diff) | |
download | android_external_selinux-c7cf5d8aa061b9616bf9d5e91139ce4fb40f532c.tar.gz android_external_selinux-c7cf5d8aa061b9616bf9d5e91139ce4fb40f532c.tar.bz2 android_external_selinux-c7cf5d8aa061b9616bf9d5e91139ce4fb40f532c.zip |
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.
Signed-off-by: Daniel Cashman <dcashman@android.com>
Diffstat (limited to 'libselinux/src/procattr.c')
-rw-r--r-- | libselinux/src/procattr.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/libselinux/src/procattr.c b/libselinux/src/procattr.c index c20f003a..eee4612c 100644 --- a/libselinux/src/procattr.c +++ b/libselinux/src/procattr.c @@ -306,11 +306,21 @@ static int setprocattrcon(const char * context, #define getpidattr_def(fn, attr) \ int get##fn##_raw(pid_t pid, char **c) \ { \ - return getprocattrcon_raw(c, pid, #attr); \ + if (pid <= 0) { \ + errno = EINVAL; \ + return -1; \ + } else { \ + return getprocattrcon_raw(c, pid, #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) |