From: "Serge E. Hallyn" <serue@us.ibm.com>
To: Oren Laadan <orenl@cs.columbia.edu>
Cc: Linux Containers <containers@lists.osdl.org>,
linux-security-module@vger.kernel.org,
SELinux <selinux@tycho.nsa.gov>,
Casey Schaufler <casey@schaufler-ca.com>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Stephen Smalley <sds@epoch.ncsc.mil>,
James Morris <jmorris@namei.org>,
David Howells <dhowells@redhat.com>,
Alexey Dobriyan <adobriyan@gmail.com>
Subject: [PATCH 1/1] mktree: accept the lsm_name field in header and add -k flag
Date: Fri, 28 Aug 2009 16:03:42 -0500 [thread overview]
Message-ID: <20090828210342.GB28048@us.ibm.com> (raw)
In-Reply-To: <20090828210208.GA28048@us.ibm.com>
[ This patch is against the user-space code for exploiting
c/r, at git://git.ncl.cs.columbia.edu/pub/git/user-cr.git ]
The checkpoint file header now has an 11-character string
containing the name of the active LSM, following the uts
info.
Also add a -k (--keeplsm) flag to tell mktree to set the
RESTART_KEEP_LSM flag to sys_restart().
Signed-off-by: Serge Hallyn <serue@us.ibm.com>
---
mktree.c | 22 ++++++++++++++++++++--
1 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/mktree.c b/mktree.c
index 63be82d..315f3a8 100644
--- a/mktree.c
+++ b/mktree.c
@@ -45,6 +45,7 @@ static char usage_str[] =
"\t -P,--no-pidns do not create a new pid namspace (default)\n"
"\t --pids restore original pids (default with --pidns)\n"
"\t -w,--wait wait for (root) task to termiate (default)\n"
+"\t -k,--keeplsm Try to recreate original LSM labels on all objects\n"
"\t --show-status show exit status of (root) task (implies -w)\n"
"\t --copy-status imitate exit status of (root) task (implies -w)\n"
"\t -W,--no-wait do not wait for (root) task to terminate\n"
@@ -259,6 +260,8 @@ struct args {
char *freezer;
};
+int keep_lsm;
+
static void usage(char *str)
{
fprintf(stderr, "%s", str);
@@ -273,6 +276,7 @@ static void parse_args(struct args *args, int argc, char *argv[])
{ "pidns-signal", required_argument, NULL, '4' },
{ "no-pidns", no_argument, NULL, 'P' },
{ "pids", no_argument, NULL, 3 },
+ { "keeplsm", no_argument, NULL, 'k' },
{ "wait", no_argument, NULL, 'w' },
{ "show-status", no_argument, NULL, 1 },
{ "copy-status", no_argument, NULL, 2 },
@@ -282,7 +286,7 @@ static void parse_args(struct args *args, int argc, char *argv[])
{ "debug", no_argument, NULL, 'd' },
{ NULL, 0, NULL, 0 }
};
- static char optc[] = "hdvpPwWF:";
+ static char optc[] = "hdvpPkwWF:";
int sig;
@@ -320,6 +324,9 @@ static void parse_args(struct args *args, int argc, char *argv[])
args->pids = 1;
args->pidns = 1; /* implied */
break;
+ case 'k':
+ keep_lsm = RESTART_KEEP_LSM;
+ break;
case 'w':
args->wait = 1;
break;
@@ -750,6 +757,7 @@ static int ckpt_coordinator(struct ckpt_ctx *ctx)
if (ctx->args->freezer)
flags |= RESTART_FROZEN;
+ flags |= keep_lsm;
ret = restart(root_pid, STDIN_FILENO, flags);
if (ret < 0) {
@@ -1309,7 +1317,7 @@ static int ckpt_make_tree(struct ckpt_ctx *ctx, struct task *task)
/* on success this doesn't return */
ckpt_dbg("about to call sys_restart()\n");
- ret = restart(0, STDIN_FILENO, 0);
+ ret = restart(0, STDIN_FILENO, keep_lsm);
if (ret < 0)
perror("task restore failed");
return ret;
@@ -1703,6 +1711,7 @@ static int ckpt_read_obj_buffer(struct ckpt_ctx *ctx, void *buf, int n)
* read/write the checkpoint image: similar to in-kernel code
*/
+#define SECURITY_NAME_MAX 10
static int ckpt_read_header(struct ckpt_ctx *ctx)
{
struct ckpt_hdr_header *h;
@@ -1736,6 +1745,11 @@ static int ckpt_read_header(struct ckpt_ctx *ctx)
if (ret < 0)
return ret;
+ ptr += ((struct ckpt_hdr *) ptr)->len;
+ ret = ckpt_read_obj_buffer(ctx, ptr, SECURITY_NAME_MAX + 1);
+ if (ret < 0)
+ return ret;
+
/* FIXME: skip version validation for now */
return 0;
@@ -1814,6 +1828,10 @@ static int ckpt_write_header(struct ckpt_ctx *ctx)
return ret;
ptr += ((struct ckpt_hdr *) ptr)->len;
ret = ckpt_write_obj(ctx, (struct ckpt_hdr *) ptr);
+ if (ret < 0)
+ return ret;
+ ptr += ((struct ckpt_hdr *) ptr)->len;
+ ret = ckpt_write_obj(ctx, (struct ckpt_hdr *) ptr);
return ret;
}
--
1.6.1.1
next prev parent reply other threads:[~2009-08-28 21:03 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-28 21:00 [PATCH 1/5] cr: define ckpt_debug if CONFIG_CHECKPOINT=n Serge E. Hallyn
2009-08-28 21:02 ` [PATCH 2/5] cr: checkpoint the active LSM and add RESTART_KEEP_LSM flag Serge E. Hallyn
2009-08-28 21:03 ` Serge E. Hallyn [this message]
2009-08-29 4:43 ` Casey Schaufler
2009-08-29 22:59 ` Serge E. Hallyn
2009-08-30 0:03 ` Casey Schaufler
2009-08-30 13:48 ` Serge E. Hallyn
2009-08-30 18:58 ` Casey Schaufler
2009-08-30 20:24 ` Serge E. Hallyn
2009-08-30 21:43 ` Casey Schaufler
2009-08-31 13:22 ` Serge E. Hallyn
2009-08-31 13:36 ` Serge E. Hallyn
2009-09-01 5:51 ` Casey Schaufler
[not found] ` <4A9ACBD4.4020804-iSGtlc1asvQWG2LlvL+J4A@public.gmane.org>
2009-09-01 12:29 ` Russell Coker
2009-09-02 16:36 ` Casey Schaufler
2009-09-02 18:55 ` Shaya Potter
2009-09-02 22:27 ` Casey Schaufler
2009-08-28 21:04 ` [PATCH 3/5] cr: add generic LSM c/r support Serge E. Hallyn
2009-08-29 4:30 ` Casey Schaufler
2009-08-29 22:41 ` Serge E. Hallyn
2009-08-29 23:40 ` Casey Schaufler
2009-08-30 13:58 ` Serge E. Hallyn
2009-08-30 19:03 ` Casey Schaufler
2009-08-30 20:26 ` Serge E. Hallyn
[not found] ` <4A9ACD0A.9050004-iSGtlc1asvQWG2LlvL+J4A@public.gmane.org>
2009-08-31 12:45 ` Stephen Smalley
2009-09-01 5:49 ` Casey Schaufler
2009-09-04 13:38 ` Serge E. Hallyn
2009-08-28 21:04 ` [PATCH 4/5] cr: add smack support to lsm c/r Serge E. Hallyn
2009-08-28 21:05 ` [PATCH 5/5] cr: add selinux support Serge E. Hallyn
-- strict thread matches above, loose matches on Subject: below --
2009-09-10 20:22 [PATCH 0/4] LSM checkpoint/restart: introduction Serge E. Hallyn
2009-09-10 20:23 ` [PATCH 1/1] mktree: accept the lsm_name field in header and add -k flag 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=20090828210342.GB28048@us.ibm.com \
--to=serue@us.ibm.com \
--cc=adobriyan@gmail.com \
--cc=casey@schaufler-ca.com \
--cc=containers@lists.osdl.org \
--cc=dhowells@redhat.com \
--cc=ebiederm@xmission.com \
--cc=jmorris@namei.org \
--cc=linux-security-module@vger.kernel.org \
--cc=orenl@cs.columbia.edu \
--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