From: "Serge E. Hallyn" <serue@us.ibm.com>
To: Oren Laadan <orenl@cs.columbia.edu>
Cc: Linux Containers <containers@lists.osdl.org>,
Alexey Dobriyan <adobriyan@gmail.com>,
David Howells <dhowells@redhat.com>,
linux-security-module@vger.kernel.org,
Andrew Morgan <morgan@kernel.org>
Subject: [PATCH 5/8] cr: ipc: reset kern_ipc_perms
Date: Mon, 1 Jun 2009 17:22:15 -0500 [thread overview]
Message-ID: <20090601222215.GE29460@us.ibm.com> (raw)
In-Reply-To: <20090601222119.GB29164@us.ibm.com>
Reset the checkpointed uid and gid info on ipc objects.
Right now, we return -EPERM if the user calling sys_restart() isn't
allowed to create an object with the checkpointed uid. We may prefer
to simply use the caller's uid in that case - but that could lead to
subtle userspace bugs? Unsure, so going for the stricter behavior.
TODO: restore kern_ipc_perms->security.
Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>
---
ipc/checkpoint.c | 33 +++++++++++++++++++++++++++++++--
1 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/ipc/checkpoint.c b/ipc/checkpoint.c
index f621226..bc77743 100644
--- a/ipc/checkpoint.c
+++ b/ipc/checkpoint.c
@@ -119,6 +119,26 @@ int checkpoint_ipc_ns(struct ckpt_ctx *ctx, struct ipc_namespace *ipc_ns)
* Restart
*/
+/*
+ * check whether current task may create ipc object with
+ * checkpointed uids and gids.
+ * Return 1 if ok, 0 if not.
+ */
+static int validate_created_perms(struct ckpt_hdr_ipc_perms *h)
+{
+ const struct cred *cred = current_cred();
+ uid_t uid = cred->uid, euid = cred->euid;
+
+ /* actually I don't know - is CAP_IPC_OWNER the right one? */
+ if (((h->uid != uid && h->uid == euid) ||
+ (h->cuid != uid && h->cuid != euid) ||
+ !in_group_p(h->cgid) ||
+ !in_group_p(h->gid)) &&
+ !capable(CAP_IPC_OWNER))
+ return 0;
+ return 1;
+}
+
int restore_load_ipc_perms(struct ckpt_hdr_ipc_perms *h,
struct kern_ipc_perm *perm)
{
@@ -139,14 +159,23 @@ int restore_load_ipc_perms(struct ckpt_hdr_ipc_perms *h,
perm->id = h->id;
perm->key = h->key;
-#if 0 /* FIX: requires security checks */
+
+ if (!validate_created_perms(h))
+ return -EPERM;
perm->uid = h->uid;
perm->gid = h->gid;
perm->cuid = h->cuid;
perm->cgid = h->cgid;
-#endif
perm->mode = h->mode;
perm->seq = h->seq;
+ /*
+ * Todo: restore perm->security.
+ * At the moment it gets set by security_x_alloc() called through
+ * ipcget()->ipcget_public()->ops-.getnew (->nequeue for instance)
+ * We will want to ask the LSM to consider resetting the
+ * checkpointed ->security, based on current_security(),
+ * the checkpointed ->security, and the checkpoint file context.
+ */
return 0;
}
--
1.6.1
next prev parent reply other threads:[~2009-06-01 22:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-01 22:21 [PATCH 0/8] Credentials c/r: introduction Serge E. Hallyn
2009-06-01 22:21 ` [PATCH 1/8] cred: #include init.h in cred.h Serge E. Hallyn
2009-06-01 22:21 ` [PATCH 2/8] groups: move code to kernel/groups.c Serge E. Hallyn
2009-06-01 22:21 ` [PATCH 3/8] cr: break out new_user_ns() Serge E. Hallyn
2009-06-01 22:22 ` [PATCH 4/8] cr: split core function out of some set*{u,g}id functions Serge E. Hallyn
2009-06-01 22:22 ` Serge E. Hallyn [this message]
2009-06-01 22:22 ` [PATCH 6/8] cr: capabilities: define checkpoint and restore fns Serge E. Hallyn
2009-06-01 22:22 ` [PATCH 7/8] cr: checkpoint and restore task credentials Serge E. Hallyn
2009-06-01 22:22 ` [PATCH 8/8] cr: restore file->f_cred 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=20090601222215.GE29460@us.ibm.com \
--to=serue@us.ibm.com \
--cc=adobriyan@gmail.com \
--cc=containers@lists.osdl.org \
--cc=dhowells@redhat.com \
--cc=linux-security-module@vger.kernel.org \
--cc=morgan@kernel.org \
--cc=orenl@cs.columbia.edu \
/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