From: "Serge E. Hallyn" <serue@us.ibm.com>
To: Stephen Smalley <sds@epoch.ncsc.mil>
Cc: Linux Containers <containers@lists.osdl.org>,
linux-security-module@vger.kernel.org,
SELinux <selinux@tycho.nsa.gov>,
Alexey Dobriyan <adobriyan@gmail.com>,
Casey Schaufler <casey@schaufler-ca.com>,
Andrew Morgan <morgan@kernel.org>
Subject: Re: [PATCH 1/1] cr: lsm: restore LSM contexts for ipc objects
Date: Wed, 24 Jun 2009 17:07:36 -0500 [thread overview]
Message-ID: <20090624220736.GA21134@us.ibm.com> (raw)
In-Reply-To: <1245849008.9669.13.camel@moss-pluto.epoch.ncsc.mil>
Quoting Stephen Smalley (sds@epoch.ncsc.mil):
> On Tue, 2009-06-23 at 14:57 -0500, Serge E. Hallyn wrote:
> > Quoting Serge E. Hallyn (serue@us.ibm.com):
> > > Quoting Stephen Smalley (sds@epoch.ncsc.mil):
> > > > On Fri, 2009-06-19 at 20:32 -0500, Serge E. Hallyn wrote:
> > > > > diff --git a/ipc/checkpoint_msg.c b/ipc/checkpoint_msg.c
> > > > > index 51385b0..ca55339 100644
> > > > > --- a/ipc/checkpoint_msg.c
> > > > > +++ b/ipc/checkpoint_msg.c
> > > > <snip>
> > > > > @@ -175,11 +183,26 @@ static int load_ipc_msg_hdr(struct ckpt_ctx *ctx,
> > > > > struct msg_queue *msq)
> > > > > {
> > > > > int ret = 0;
> > > > > + int secid = 0;
> > > > >
> > > > > ret = restore_load_ipc_perms(&h->perms, &msq->q_perm);
> > > > > if (ret < 0)
> > > > > return ret;
> > > > >
> > > > > + if (h->perms.secref) {
> > > > > + struct sec_store *s;
> > > > > + s = ckpt_obj_fetch(ctx, h->perms.secref, CKPT_OBJ_SECURITY);
> > > > > + if (IS_ERR(s))
> > > > > + return PTR_ERR(s);
> > > > > + secid = s->secid;
> > > > > + }
> > > > > + ret = security_msg_queue_alloc(msq);
> > > > > + if (ret)
> > > > > + return ret;
> > > > > + ret = security_msg_queue_restore(msq, secid);
> > > > > + if (ret < 0)
> > > > > + return ret;
> > > >
> > > > I don't think you want to call security_msg_queue_alloc() here, as that
> > > > both allocates the security struct and performs the create check. So I
> > > > would just call the _restore() function, and let it internally call
> > > > ipc_alloc_security() to allocate the struct but then apply its own
> > > > distinct restore check. Likewise for the rest of them.
> > >
> > > Ok, will change that.
> >
> > Hmm, but that means that if there is some new LSM which allocates memory
> > in security_msg_queue_alloc(), but which does not define
> > security_msg_queue_restore() (for some stupid reason), it'll end up
> > causing a bug.
> >
> > It's something we can certainly catch through code review, but do we
> > want to set such a scenario up at all?
> >
> > Speaking just for SELinux, the security_msg_queue_alloc() hook would
> > return -EPERM only if the task calling sys_restart() wasn't allowed
> > to create a msg queue with its own type, right? Is that something
> > which is often disallowed?
>
> Certainly some program domains lack permission to create ipc objects.
> The ipc _alloc hooks are unusual in that they combine both allocation
> and create checking unlike the rest of the object alloc hooks. I think
> that was discussed at the time, but people didn't want two different
> hook calls at the same call site.
Oh, no. I wasn't thinking right.
The objects are actually restored through calls to do_shmget() etc,
so that security_xyz_alloc() already gets called.
So I think we'll just leave it as is right now, acknowledging that
it might become problematic if we want to confine a restart_t domain
to be able to restore but not alloc any ipcs. The actual ramifications
of that still somewhat escape me, but I do prefer having the common
helpers used whenever possible to recreate objects.
thanks,
-serge
next prev parent reply other threads:[~2009-06-24 22:07 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-20 1:32 [PATCH 1/1] cr: lsm: restore LSM contexts for ipc objects Serge E. Hallyn
2009-06-22 5:37 ` James Morris
2009-06-22 16:25 ` Serge E. Hallyn
[not found] ` <20090620013216.GA4435-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-06-22 14:47 ` Stephen Smalley
2009-06-22 17:50 ` Serge E. Hallyn
2009-06-22 18:23 ` Stephen Smalley
2009-06-23 3:10 ` Casey Schaufler
2009-06-23 17:55 ` Stephen Smalley
2009-06-23 18:18 ` Serge E. Hallyn
2009-06-23 19:57 ` Serge E. Hallyn
2009-06-24 13:10 ` Stephen Smalley
2009-06-24 22:07 ` Serge E. Hallyn [this message]
2009-06-25 12:34 ` Stephen Smalley
2009-06-25 12:59 ` Serge E. Hallyn
2009-06-25 14:06 ` Stephen Smalley
2009-06-25 4:21 ` Oren Laadan
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=20090624220736.GA21134@us.ibm.com \
--to=serue@us.ibm.com \
--cc=adobriyan@gmail.com \
--cc=casey@schaufler-ca.com \
--cc=containers@lists.osdl.org \
--cc=linux-security-module@vger.kernel.org \
--cc=morgan@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox