From: Joshua Brindle <method@manicmethod.com>
To: Mark Nelson <markn@au1.ibm.com>
Cc: containers@lists.linux-foundation.org,
linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov,
menage@google.com, Stephen Smalley <sds@tycho.nsa.gov>,
James Morris <jmorris@namei.org>,
"Serge E. Hallyn" <serue@us.ibm.com>
Subject: Re: [PATCH 2/2] hijack: update task_alloc_security
Date: Tue, 27 Nov 2007 00:52:21 -0500 [thread overview]
Message-ID: <474BB095.8080302@manicmethod.com> (raw)
In-Reply-To: <474B7A51.3080300@au1.ibm.com>
Mark Nelson wrote:
> Subject: [PATCH 2/2] hijack: update task_alloc_security
>
> Update task_alloc_security() to take the hijacked task as a second
> argument.
>
> For the selinux version, refuse permission if hijack_src!=current,
> since we have no idea what the proper behavior is. Even if we
> assume that the resulting child should be in the hijacked task's
> domain, depending on the policy that may not be enough information
> since init_t executing /bin/bash could result in a different domain
> than login_t executing /bin/bash.
>
>
This means its basically not possible to hijack tasks with SELinux
right? It would be a shame if this weren't useful to people running SELinux.
It seems to me (I may be wrong, I'm sure someone will let me know if I
am) that the right way to handle this with SELinux is to check to see if
the current task (caller of sys_hijack) has permission to ptrace (or
some other permission deemed suitable, perhaps a new one) and if so copy
the security blob pointer from the hijacked task to the new one (we
don't want tranquility problems).
From your paragraph above it seems like you were thinking there should
be a transition at hijack time but we don't automatically transition
anywhere except exec.
Anyway, I just don't think you should completely disable this for
SELinux users.
> Signed-off-by: Serge Hallyn <serue@us.ibm.com>
> Signed-off-by: Mark Nelson <markn@au1.ibm.com>
> ---
> include/linux/security.h | 12 +++++++++---
> kernel/fork.c | 2 +-
> security/dummy.c | 3 ++-
> security/security.c | 4 ++--
> security/selinux/hooks.c | 6 +++++-
> 5 files changed, 19 insertions(+), 8 deletions(-)
>
> Index: upstream/include/linux/security.h
> ===================================================================
> --- upstream.orig/include/linux/security.h
> +++ upstream/include/linux/security.h
> @@ -545,9 +545,13 @@ struct request_sock;
> * Return 0 if permission is granted.
> * @task_alloc_security:
> * @p contains the task_struct for child process.
> + * @task contains the task_struct for process to be hijacked
> * Allocate and attach a security structure to the p->security field. The
> * security field is initialized to NULL when the task structure is
> * allocated.
> + * @task will usually be current. If it is not equal to current, then
> + * a sys_hijack system call is going on, and current is asking for a
> + * child to be created in the context of the hijack src, @task.
> * Return 0 if operation was successful.
> * @task_free_security:
> * @p contains the task_struct for process.
> @@ -1301,7 +1305,8 @@ struct security_operations {
> int (*dentry_open) (struct file *file);
>
> int (*task_create) (unsigned long clone_flags);
> - int (*task_alloc_security) (struct task_struct * p);
> + int (*task_alloc_security) (struct task_struct *p,
> + struct task_struct *task);
> void (*task_free_security) (struct task_struct * p);
> int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
> int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ ,
> @@ -1549,7 +1554,7 @@ int security_file_send_sigiotask(struct
> int security_file_receive(struct file *file);
> int security_dentry_open(struct file *file);
> int security_task_create(unsigned long clone_flags);
> -int security_task_alloc(struct task_struct *p);
> +int security_task_alloc(struct task_struct *p, struct task_struct *task);
> void security_task_free(struct task_struct *p);
> int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, int flags);
> int security_task_post_setuid(uid_t old_ruid, uid_t old_euid,
> @@ -2021,7 +2026,8 @@ static inline int security_task_create (
> return 0;
> }
>
> -static inline int security_task_alloc (struct task_struct *p)
> +static inline int security_task_alloc(struct task_struct *p,
> + struct task_struct *task)
> {
> return 0;
> }
> Index: upstream/kernel/fork.c
> ===================================================================
> --- upstream.orig/kernel/fork.c
> +++ upstream/kernel/fork.c
> @@ -1177,7 +1177,7 @@ static struct task_struct *copy_process(
> /* Perform scheduler related setup. Assign this task to a CPU. */
> sched_fork(p, clone_flags);
>
> - if ((retval = security_task_alloc(p)))
> + if ((retval = security_task_alloc(p, task)))
> goto bad_fork_cleanup_policy;
> if ((retval = audit_alloc(p)))
> goto bad_fork_cleanup_security;
> Index: upstream/security/dummy.c
> ===================================================================
> --- upstream.orig/security/dummy.c
> +++ upstream/security/dummy.c
> @@ -475,7 +475,8 @@ static int dummy_task_create (unsigned l
> return 0;
> }
>
> -static int dummy_task_alloc_security (struct task_struct *p)
> +static int dummy_task_alloc_security(struct task_struct *p,
> + struct task_struct *task)
> {
> return 0;
> }
> Index: upstream/security/security.c
> ===================================================================
> --- upstream.orig/security/security.c
> +++ upstream/security/security.c
> @@ -568,9 +568,9 @@ int security_task_create(unsigned long c
> return security_ops->task_create(clone_flags);
> }
>
> -int security_task_alloc(struct task_struct *p)
> +int security_task_alloc(struct task_struct *p, struct task_struct *task)
> {
> - return security_ops->task_alloc_security(p);
> + return security_ops->task_alloc_security(p, task);
> }
>
> void security_task_free(struct task_struct *p)
> Index: upstream/security/selinux/hooks.c
> ===================================================================
> --- upstream.orig/security/selinux/hooks.c
> +++ upstream/security/selinux/hooks.c
> @@ -2788,11 +2788,15 @@ static int selinux_task_create(unsigned
> return task_has_perm(current, current, PROCESS__FORK);
> }
>
> -static int selinux_task_alloc_security(struct task_struct *tsk)
> +static int selinux_task_alloc_security(struct task_struct *tsk,
> + struct task_struct *hijack_src)
> {
> struct task_security_struct *tsec1, *tsec2;
> int rc;
>
> + if (hijack_src != current)
> + return -EPERM;
> +
> tsec1 = current->security;
>
> rc = task_alloc_security(tsk);
> -
> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
next prev parent reply other threads:[~2007-11-27 5:52 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-27 1:54 [PATCH 1/2] namespaces: introduce sys_hijack (v10) Mark Nelson
[not found] ` <474B7A51.3080300@au1.ibm.com>
[not found] ` <474B7A51.3080300-8fk3Idey6ehBDgjK7y7TUQ@public.gmane.org>
2007-11-27 5:04 ` [PATCH 2/2] hijack: update task_alloc_security Casey Schaufler
2007-11-27 5:52 ` Joshua Brindle
2007-11-27 5:04 ` Casey Schaufler
[not found] ` <820903.72193.qm-ua+PKVt9nRSvuULXzWHTWIglqE1Y4D90QQ4Iyu8u01E@public.gmane.org>
2007-11-27 16:01 ` Serge E. Hallyn
2007-11-27 16:01 ` Serge E. Hallyn
[not found] ` <20071127160127.GC32362-6s5zFf/epYLPQpwDFJZrxKsjOiXwFzmk@public.gmane.org>
2007-11-28 5:53 ` Crispin Cowan
[not found] ` <474D026B.3090306-RL8T2ARnKKfZw9hOtrW0rA@public.gmane.org>
2007-11-28 14:57 ` Serge E. Hallyn
2007-11-28 14:57 ` Serge E. Hallyn
2007-11-27 5:52 ` Joshua Brindle [this message]
[not found] ` <474BB095.8080302-PzTJMJMxY2mwxnkjfAeQoA@public.gmane.org>
2007-11-27 14:36 ` Stephen Smalley
2007-11-27 14:36 ` Stephen Smalley
[not found] ` <1196174188.3925.32.camel-/ugcdrsPCSfIm9DtXLC9OUVfdvkotuLY+aIohriVLy8@public.gmane.org>
2007-11-27 15:43 ` Serge E. Hallyn
2007-11-27 15:43 ` Serge E. Hallyn
[not found] ` <20071127154356.GA32362-6s5zFf/epYLPQpwDFJZrxKsjOiXwFzmk@public.gmane.org>
2007-11-28 5:50 ` Crispin Cowan
[not found] ` <474D0188.2040600-RL8T2ARnKKfZw9hOtrW0rA@public.gmane.org>
2007-11-28 14:54 ` Serge E. Hallyn
2007-11-28 14:54 ` Serge E. Hallyn
[not found] ` <20071128145422.GC3820-6s5zFf/epYLPQpwDFJZrxKsjOiXwFzmk@public.gmane.org>
2007-11-29 4:21 ` Crispin Cowan
[not found] ` <474E3E4E.3060908@crispincowan.com>
[not found] ` <474E3E4E.3060908-RL8T2ARnKKfZw9hOtrW0rA@public.gmane.org>
2007-11-29 15:38 ` Serge E. Hallyn
2007-11-29 15:38 ` Serge E. Hallyn
[not found] ` <20071129153815.GA8140-6s5zFf/epYLPQpwDFJZrxKsjOiXwFzmk@public.gmane.org>
2007-12-02 1:07 ` Crispin Cowan
[not found] ` <47520568.6030108@crispincowan.com>
[not found] ` <47520568.6030108-RL8T2ARnKKfZw9hOtrW0rA@public.gmane.org>
2007-12-03 14:50 ` Serge E. Hallyn
2007-12-03 14:50 ` Serge E. Hallyn
[not found] ` <20071203145012.GB9008-6s5zFf/epYLPQpwDFJZrxKsjOiXwFzmk@public.gmane.org>
2007-12-03 19:43 ` Crispin Cowan
[not found] ` <474B78CB.5070607-8fk3Idey6ehBDgjK7y7TUQ@public.gmane.org>
2007-11-27 2:00 ` Mark Nelson
2007-11-27 6:58 ` [PATCH 1/2] namespaces: introduce sys_hijack (v10) Crispin Cowan
[not found] ` <474BC017.6060801@crispincowan.com>
[not found] ` <474BC017.6060801-RL8T2ARnKKfZw9hOtrW0rA@public.gmane.org>
2007-11-27 16:11 ` Serge E. Hallyn
2007-11-27 16:11 ` Serge E. Hallyn
2007-11-27 18:09 ` Stephen Smalley
2007-11-27 22:38 ` Serge E. Hallyn
2007-11-27 22:54 ` Casey Schaufler
[not found] ` <85084.30222.qm-9MnE1aMSM06vuULXzWHTWIglqE1Y4D90QQ4Iyu8u01E@public.gmane.org>
2007-11-28 14:25 ` Serge E. Hallyn
2007-11-28 14:25 ` Serge E. Hallyn
[not found] ` <20071127223829.GA21753-6s5zFf/epYLPQpwDFJZrxKsjOiXwFzmk@public.gmane.org>
2007-11-27 22:54 ` Casey Schaufler
2007-11-28 15:00 ` Stephen Smalley
2007-11-28 15:00 ` Stephen Smalley
2007-11-28 15:23 ` Serge E. Hallyn
[not found] ` <20071128152359.GA4756-6s5zFf/epYLPQpwDFJZrxKsjOiXwFzmk@public.gmane.org>
2007-11-30 2:08 ` Mark Nelson
[not found] ` <474F70B3.5020006-8fk3Idey6ehBDgjK7y7TUQ@public.gmane.org>
2007-11-30 2:10 ` Paul Menage
2007-11-30 2:37 ` Eric W. Biederman
2007-11-30 2:37 ` Eric W. Biederman
[not found] ` <m1wss0a27g.fsf-T1Yj925okcoyDheHMi7gv2pdwda3JcWeAL8bYrjMMd8@public.gmane.org>
2007-11-30 14:50 ` Serge E. Hallyn
2007-11-30 14:50 ` Serge E. Hallyn
2007-11-30 22:09 ` Eric W. Biederman
[not found] ` <20071130145016.GE6250-6s5zFf/epYLPQpwDFJZrxKsjOiXwFzmk@public.gmane.org>
2007-11-30 22:09 ` Eric W. Biederman
[not found] ` <6599ad830711291810m463833ack452c375b552c627e@mail.gmail.com>
[not found] ` <6599ad830711291810m463833ack452c375b552c627e-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-11-30 14:50 ` Serge E. Hallyn
2007-11-30 14:50 ` Serge E. Hallyn
[not found] ` <1196262054.13820.23.camel-/ugcdrsPCSfIm9DtXLC9OUVfdvkotuLY+aIohriVLy8@public.gmane.org>
2007-11-28 15:23 ` Serge E. Hallyn
[not found] ` <1196186964.3925.129.camel-/ugcdrsPCSfIm9DtXLC9OUVfdvkotuLY+aIohriVLy8@public.gmane.org>
2007-11-27 22:38 ` Serge E. Hallyn
[not found] ` <20071127161132.GD32362-6s5zFf/epYLPQpwDFJZrxKsjOiXwFzmk@public.gmane.org>
2007-11-27 18:09 ` Stephen Smalley
-- strict thread matches above, loose matches on Subject: below --
2007-11-27 11:08 [PATCH 2/2] hijack: update task_alloc_security Rodrigo Rubira Branco (BSDaemon)
[not found] ` <20071127130831.595B58BD1A-09+wY+MuxUVrAyPhmWpK8Qh0onu2mTI+@public.gmane.org>
2007-11-27 15:50 ` Serge E. Hallyn
2007-11-27 17:05 Serge E. Hallyn
2007-11-27 17:05 Serge E. Hallyn
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=474BB095.8080302@manicmethod.com \
--to=method@manicmethod.com \
--cc=containers@lists.linux-foundation.org \
--cc=jmorris@namei.org \
--cc=linux-security-module@vger.kernel.org \
--cc=markn@au1.ibm.com \
--cc=menage@google.com \
--cc=sds@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
--cc=serue@us.ibm.com \
/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.