From: Daniel Cashman <dcashman@android.com>
To: selinux@tycho.nsa.gov
Cc: nnk@google.com, jeffv@google.com, sds@tycho.nsa.gov
Subject: Re: [PATCH 2/2] libselinux: procattr: return einval for <= 0 pid args.
Date: Tue, 23 Feb 2016 12:29:51 -0800 [thread overview]
Message-ID: <56CCC13F.3060709@android.com> (raw)
In-Reply-To: <1456259040-13721-3-git-send-email-dcashman@android.com>
On 02/23/2016 12:24 PM, Daniel Cashman wrote:
> From: dcashman <dcashman@android.com>
>
> 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>
> ---
> libselinux/src/procattr.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/libselinux/src/procattr.c b/libselinux/src/procattr.c
> index c20f003..eee4612 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)
>
I need to point out explicitly that this change would, of course, break
the existing ABI and result in a change in behavior for applications
relying on getpidcon(0,) calls to be the same as getcon().
Thanks,
Dan
next prev parent reply other threads:[~2016-02-23 20:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-23 20:23 [PATCH 0/2] Return error on invalid pids for procattr funcs Daniel Cashman
2016-02-23 20:23 ` [PATCH 1/2] libselinux: procattr: return error on invalid pid_t input Daniel Cashman
2016-02-23 20:24 ` [PATCH 2/2] libselinux: procattr: return einval for <= 0 pid args Daniel Cashman
2016-02-23 20:29 ` Daniel Cashman [this message]
2016-02-23 21:22 ` Nick Kralevich
2016-02-29 17:38 ` Stephen Smalley
2016-02-24 14:49 ` getpidcon with pid == 0 (Was: Re: [PATCH 2/2] libselinux: procattr: return einval for <= 0 pid args.) Stephen Smalley
2016-02-24 15:25 ` Nick Kralevich
2016-02-24 15:32 ` Stephen Smalley
2016-02-24 16:47 ` Petr Lautrbach
2016-02-24 14:21 ` [PATCH 1/2] libselinux: procattr: return error on invalid pid_t input Stephen Smalley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56CCC13F.3060709@android.com \
--to=dcashman@android.com \
--cc=jeffv@google.com \
--cc=nnk@google.com \
--cc=sds@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.