From: Darrel Goeddel <dgoeddel@TrustedCS.com>
To: Stephen Smalley <sds@epoch.ncsc.mil>
Cc: "selinux@tycho.nsa.gov" <selinux@tycho.nsa.gov>,
Chad Hanson <chanson@tcs-sec.com>
Subject: Re: dynamic context transitions
Date: Mon, 29 Nov 2004 17:41:54 -0600 [thread overview]
Message-ID: <41ABB3C2.2090809@trustedcs.com> (raw)
In-Reply-To: <1101763456.2630.67.camel@moss-spartans.epoch.ncsc.mil>
Stephen Smalley wrote:
> Thanks. What about the case of a CLONE_VM w/o CLONE_THREAD (native
> Linux threads rather than POSIX threads)? Possibly a check on
> atomic_read(¤t->mm->mm_users)?
>
Good call. We could replace:
if (!thread_group_empty(p))
with:
if (atomic_read(&p->mm->mm_users) != 1)
or go with both:
if ((atomic_read(&p->mm->mm_users) != 1) ||
!thread_group_empty(p))
return -EPERM;
The check on mm_users also covers the case of a non-empty thread group since
CLONE_THREAD requires CLONE_SIGHAND which requires CLONE_VM which increments
mm_user. I wouldn't think that would be changing anytime soon, so we could just
go with the mm check. I am happy either way since they are currently
functionally equivalent. Anybody have a preference?
> Also, I know that we talked earlier about this issue, but even though
> ptracing should typically be covered by the ptrace check upon the exec
> that entered the domain that was allowed to perform the dynamic
> transition in the first place, I think we likely want to recheck ptrace
> status upon the dynamic transition as well for greater safety. The diff
> below relative to your patch should do it. See any problems with it for
> your intended usage?
>
> Index: linux-2.6/security/selinux/hooks.c
> ===================================================================
> RCS file: /nfshome/pal/CVS/linux-2.6/security/selinux/hooks.c,v
> retrieving revision 1.136
> diff -u -p -r1.136 hooks.c
> --- linux-2.6/security/selinux/hooks.c 29 Nov 2004 19:45:59 -0000 1.136
> +++ linux-2.6/security/selinux/hooks.c 29 Nov 2004 20:22:00 -0000
> @@ -4149,6 +4149,8 @@ static int selinux_setprocattr(struct ta
> else if (!strcmp(name, "fscreate"))
> tsec->create_sid = sid;
> else if (!strcmp(name, "current")) {
> + struct av_decision avd;
> +
> if (sid == 0)
> return -EINVAL;
>
> @@ -4162,7 +4164,24 @@ static int selinux_setprocattr(struct ta
> if (error)
> return error;
>
> - tsec->sid = sid;
> + /* Check for ptracing, and update the task SID if ok.
> + Otherwise, leave SID unchanged and fail. */
> + task_lock(current);
> + if (current->ptrace & PT_PTRACED) {
> + error = avc_has_perm_noaudit(tsec->ptrace_sid, sid,
> + SECCLASS_PROCESS,
> + PROCESS__PTRACE, &avd);
> + if (!error)
> + tsec->sid = sid;
> + task_unlock(current);
> + avc_audit(tsec->ptrace_sid, sid, SECCLASS_PROCESS,
> + PROCESS__PTRACE, &avd, error, NULL);
> + if (error)
> + return error;
> + } else {
> + tsec->sid = sid;
> + task_unlock(current);
> + }
> }
> else
> return -EINVAL;
>
That will work fine. It adds a safety net that will not cause a problem when
the tracer has been configured properly. Should we use "p" instead of "current"
for consistency? I would actually be in favor of converting uses of "p" past "p
!= current" in this function to "current" since the idea of messing with another
process seems like it will not be implemented.
--
Darrel
--
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:[~2004-11-29 23:41 UTC|newest]
Thread overview: 138+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-29 19:10 dynamic context transitions Darrel Goeddel
2004-10-29 21:18 ` Luke Kenneth Casson Leighton
2004-10-30 9:06 ` Luke Kenneth Casson Leighton
2004-11-01 13:20 ` Stephen Smalley
2004-11-01 14:10 ` Luke Kenneth Casson Leighton
2004-11-01 16:23 ` Darrel Goeddel
2004-11-01 16:39 ` Stephen Smalley
2004-11-01 18:45 ` Luke Kenneth Casson Leighton
2004-11-01 20:10 ` James Morris
2004-11-01 20:35 ` Luke Kenneth Casson Leighton
2004-11-01 20:25 ` Stephen Smalley
2004-11-01 21:00 ` Luke Kenneth Casson Leighton
2004-11-01 20:50 ` Stephen Smalley
2004-11-01 22:21 ` Luke Kenneth Casson Leighton
2004-11-08 14:42 ` Russell Coker
[not found] ` <1100395104.13794.12.camel@piglett.bartlett.house>
2004-11-14 11:15 ` Luke Kenneth Casson Leighton
[not found] ` <1100431351.13794.510.camel@piglett.bartlett.house>
[not found] ` <20041114162453.GN5031@lkcl.net>
[not found] ` <1100449615.30740.14.camel@localhost.localdomain>
2004-11-14 21:54 ` Luke Kenneth Casson Leighton
[not found] ` <20041201231224.GD5862@Favog.ubiqx.mn.org>
2004-12-02 1:46 ` Russell Coker
2004-11-08 14:39 ` Russell Coker
[not found] ` <20041203211212.GA5243@lkcl.net>
[not found] ` <16817.7759.874421.597181@samba.org>
2004-12-04 11:39 ` Russell Coker
2004-11-01 21:27 ` Karl MacMillan
2004-11-01 22:33 ` Luke Kenneth Casson Leighton
2004-11-02 0:25 ` Karl MacMillan
2004-11-02 13:43 ` Stephen Smalley
2004-11-02 14:16 ` Karl MacMillan
2004-11-02 14:19 ` Stephen Smalley
2004-11-03 20:21 ` Colin Walters
2004-11-25 19:48 ` Russell Coker
2004-11-25 21:35 ` Luke Kenneth Casson Leighton
2004-11-26 3:28 ` Russell Coker
2004-11-26 19:23 ` Valdis.Kletnieks
2004-11-26 18:58 ` Valdis.Kletnieks
2004-11-02 2:18 ` Colin Walters
2004-11-02 9:08 ` Luke Kenneth Casson Leighton
2004-11-02 13:59 ` Stephen Smalley
2004-11-02 14:59 ` Colin Walters
2004-11-01 16:45 ` Colin Walters
2004-11-01 18:23 ` Luke Kenneth Casson Leighton
2004-10-30 2:41 ` James Morris
2004-10-31 22:47 ` Frank Mayer
2004-11-01 13:37 ` Stephen Smalley
2004-11-02 1:03 ` Karl MacMillan
2004-11-02 15:33 ` Stephen Smalley
2004-11-02 17:39 ` Karl MacMillan
2004-11-02 18:02 ` Stephen Smalley
2004-11-02 21:33 ` Karl MacMillan
2004-11-03 13:53 ` Stephen Smalley
2004-11-03 15:08 ` Karl MacMillan
2004-11-25 20:12 ` Russell Coker
2004-11-03 17:53 ` Luke Kenneth Casson Leighton
2004-11-03 18:27 ` Luke Kenneth Casson Leighton
2004-11-01 15:51 ` Stephen Smalley
2004-11-01 16:56 ` Stephen Smalley
2004-11-01 21:44 ` Karl MacMillan
2004-11-12 18:42 ` Amy L Herzog
2004-11-15 14:07 ` Stephen Smalley
2004-11-19 13:48 ` Joshua D. Guttman
2004-11-19 14:33 ` Stephen Smalley
2004-11-19 16:29 ` Darrel Goeddel
2004-11-19 17:17 ` Stephen Smalley
2004-11-24 15:30 ` Darrel Goeddel
2004-11-24 15:31 ` Stephen Smalley
2004-11-29 14:54 ` Darrel Goeddel
2004-11-29 21:24 ` Stephen Smalley
2004-11-29 23:41 ` Darrel Goeddel [this message]
2004-11-30 12:58 ` Stephen Smalley
2004-11-30 15:14 ` Darrel Goeddel
2004-11-30 16:02 ` Stephen Smalley
2004-11-30 18:27 ` Stephen Smalley
2004-11-30 21:00 ` Stephen Smalley
2004-11-12 18:24 ` Stephen Smalley
2004-11-12 20:58 ` Valdis.Kletnieks
-- strict thread matches above, loose matches on Subject: below --
2004-11-01 14:11 Chad Hanson
2004-11-01 17:14 Chad Hanson
2004-11-01 20:04 ` Frank Mayer
2004-11-01 20:28 ` Stephen Smalley
2004-11-01 18:28 Chad Hanson
2004-11-01 20:47 ` Luke Kenneth Casson Leighton
2004-11-01 20:55 ` Stephen Smalley
2004-11-01 22:58 ` Luke Kenneth Casson Leighton
2004-11-02 13:47 ` Stephen Smalley
2004-11-02 14:06 ` Frank Mayer
2004-11-02 14:22 ` Stephen Smalley
2004-11-02 14:36 ` Frank Mayer
2004-11-03 18:47 ` Luke Kenneth Casson Leighton
2004-11-02 14:13 ` Frank Mayer
2004-11-03 15:38 ` Luke Kenneth Casson Leighton
2004-11-02 19:30 ` Valdis.Kletnieks
2004-11-03 15:55 ` Luke Kenneth Casson Leighton
2004-11-03 16:03 ` Stephen Smalley
2004-11-01 21:33 Chad Hanson
2004-11-02 13:31 ` Frank Mayer
2004-11-23 5:53 ` Russell Coker
2004-11-01 21:45 Chad Hanson
2004-11-02 15:25 Chad Hanson
2004-11-02 18:49 Chad Hanson
2004-11-02 21:34 ` Stephen Smalley
2004-11-02 22:06 ` Karl MacMillan
2004-11-03 15:36 Chad Hanson
2004-11-03 15:46 ` Karl MacMillan
2004-11-03 17:26 ` Luke Kenneth Casson Leighton
2004-11-04 16:50 ` Stephen Smalley
2004-11-04 17:25 ` Luke Kenneth Casson Leighton
2004-11-04 19:46 ` James Morris
2004-11-05 5:31 ` Colin Walters
2004-11-05 12:49 ` Stephen Smalley
2004-11-05 13:01 ` Frank Mayer
2004-11-05 13:13 ` Stephen Smalley
2004-11-05 15:55 ` Frank Mayer
2004-11-05 16:33 ` Luke Kenneth Casson Leighton
2004-11-05 16:41 ` Stephen Smalley
2004-11-05 17:07 ` Frank Mayer
2004-11-05 17:48 ` Stephen Smalley
2004-11-05 16:01 ` Colin Walters
2004-11-05 12:52 ` Frank Mayer
2004-11-05 13:11 ` Stephen Smalley
2004-11-05 15:04 ` Darrel Goeddel
2004-11-05 15:20 ` Stephen Smalley
2004-11-05 15:33 ` Karl MacMillan
2004-11-05 15:35 ` Stephen Smalley
2004-11-05 15:34 ` Darrel Goeddel
2004-11-05 16:01 ` Frank Mayer
2004-11-05 16:29 ` Luke Kenneth Casson Leighton
2004-11-05 16:44 ` Stephen Smalley
2004-11-03 18:00 Chad Hanson
2004-11-14 20:23 Luke Kenneth Casson Leighton
2004-11-15 13:25 ` Stephen Smalley
2004-11-15 14:34 ` Luke Kenneth Casson Leighton
2004-11-15 14:52 ` Stephen Smalley
2004-11-15 1:57 Luke Kenneth Casson Leighton
2004-11-15 13:29 ` Stephen Smalley
2005-02-15 21:34 Luke Kenneth Casson Leighton
2005-02-15 22:21 ` Darrel Goeddel
2005-02-15 22:56 ` Luke Kenneth Casson Leighton
2005-02-16 13:05 ` Stephen Smalley
2005-02-16 14:08 ` Luke Kenneth Casson Leighton
2005-02-16 14:00 ` Stephen Smalley
2005-02-16 15:19 ` Luke Kenneth Casson Leighton
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=41ABB3C2.2090809@trustedcs.com \
--to=dgoeddel@trustedcs.com \
--cc=chanson@tcs-sec.com \
--cc=sds@epoch.ncsc.mil \
--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.