All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Serge E. Hallyn" <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: Nathan Lynch <ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org>
Cc: Linux Containers <containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org>
Subject: Re: selinux prevents msgrcv on restore message queues?
Date: Tue, 2 Mar 2010 19:19:41 -0600	[thread overview]
Message-ID: <20100303011941.GA10429@us.ibm.com> (raw)
In-Reply-To: <20100303004727.GA8272-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

Quoting Serge E. Hallyn (serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org):
> Quoting Nathan Lynch (ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org):
> > Hi,
> > 
> > With ckpt-v19-rc3 the test-mq.sh testcase in cr_tests fails when SELinux
> > is enabled on my test system (64-bit powerpc kernel).  The testcase
> > sleeps in do_msgrcv after restart and never wakes up.  When SELinux is
> > disabled, the messages are received and the testcase passes.
> > 
> > I've established that the messages are being restored during restart --
> > msgctl(IPC_STAT) shows one message in each queue before calling msgrcv.
> > Adding the IPC_NOWAIT flag to the msgrcv calls gets ENOMSG, however.
> > 
> > I managed to narrow this down to security_msg_queue_msgrcv ->
> > selinux_msg_queue_msgrcv.  avc_has_perm(SECCLASS_MSG, MSG__RECEIVE) gets
> > -EACCESS, so I guess something is going awry in selinux restore hooks?
> > 
> > Any ideas?
> 
> Hmm, wait.  security_msg_msg_alloc() is being called after
> security_msg_msg_restore.  That may not be what is causing
> your troubles, but it's certainly not right.

Can you try the following patch?

Also, to actually restore the LSM labels you need to add -k to your
restart flags, but without the -k you should get a sane default
security label.

From 6609b9d71312c6641bdceaaa97bbbf2f809b6ade Mon Sep 17 00:00:00 2001
From: Serge E. Hallyn <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Date: Tue, 2 Mar 2010 13:13:36 -0600
Subject: [PATCH 1/1] always security_msg_alloc before security_msg_restore

Signed-off-by: Serge E. Hallyn <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
 ipc/checkpoint_msg.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/ipc/checkpoint_msg.c b/ipc/checkpoint_msg.c
index 0155c20..594580f 100644
--- a/ipc/checkpoint_msg.c
+++ b/ipc/checkpoint_msg.c
@@ -231,6 +231,12 @@ static struct msg_msg *restore_msg_contents_one(struct ckpt_ctx *ctx, int *clen)
 	msg->next = NULL;
 	pseg = &msg->next;
 
+	/* set default MAC attributes */
+	ret = security_msg_msg_alloc(msg);
+	if (ret < 0)
+		goto out;
+
+	/* if requested and allowed, reset checkpointed MAC attributes */
 	ret = security_restore_obj(ctx, (void *) msg, CKPT_SECURITY_MSG_MSG,
 				   h->sec_ref);
 	if (ret < 0)
@@ -261,7 +267,6 @@ static struct msg_msg *restore_msg_contents_one(struct ckpt_ctx *ctx, int *clen)
 	msg->m_type = h->m_type;
 	msg->m_ts = h->m_ts;
 	*clen = h->m_ts;
-	ret = security_msg_msg_alloc(msg);
  out:
 	if (ret < 0 && msg) {
 		free_msg(msg);
-- 
1.6.0.6

  parent reply	other threads:[~2010-03-03  1:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-02 21:36 selinux prevents msgrcv on restore message queues? Nathan Lynch
     [not found] ` <1267565774.11828.15.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-03-03  0:47   ` Serge E. Hallyn
     [not found]     ` <20100303004727.GA8272-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-03  1:19       ` Serge E. Hallyn [this message]
     [not found]         ` <20100303011941.GA10429-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-03 18:04           ` Nathan Lynch
     [not found]             ` <1267639445.11828.19.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-03-03 19:49               ` Serge E. Hallyn
     [not found]                 ` <20100303194910.GC12379-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-03 21:56                   ` Nathan Lynch
     [not found]                     ` <1267653386.3559.9.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-03-03 23:44                       ` Serge E. Hallyn
     [not found]                         ` <20100303234448.GA27869-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-03-04  0:16                           ` Nathan Lynch
     [not found]                             ` <1267661777.3559.11.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-03-04  3:05                               ` Serge E. Hallyn
2010-03-04 15:05                                 ` Serge E. Hallyn
2010-03-04 15: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=20100303011941.GA10429@us.ibm.com \
    --to=serue-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
    --cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
    --cc=ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org \
    /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.