mirror of
https://github.com/SELinuxProject/selinux
synced 2024-12-28 00:42:07 +00:00
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>
This commit is contained in:
parent
ece9a6db47
commit
c7cf5d8aa0
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user