Skip to contentSkip to conversation

c/r: Initialize msg_msg security pointer at restart.

PATCH In review Jose R. Santos 4 participants 5 messages Mar 30, 2011 – Apr 17, 2011 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 c/r: Initialize msg_msg security pointer at restart.

This small oversight was causing either crashes on free_msg() or restart failures under some message queue workloads.

---
 ipc/checkpoint_msg.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
ipc/checkpoint_msg.c +1 -0
index 0a19d1f..6fa2c8e 100644
@@ -233,6 +233,7 @@ static struct msg_msg *restore_msg_contents_one(struct ckpt_ctx *ctx, int *clen)
 		goto out;
 	}
 	msg->next = NULL;
+        msg->security = NULL;
 	pseg = &msg->next;
 
 	/* set default MAC attributes */
Signature · 1 line
1.7.1
#2 lore raw
In reply to a message not in the archive
Quoted 4 lines · Jose R. Santos

This small oversight was causing either crashes on free_msg() or restart failures under some message queue workloads.

What kernel is this?

Starting with the last line in your context, there is:

	/* set default MAC attributes */
	ret = security_msg_msg_alloc(msg);
	if (ret < 0)
		goto out;

which should take care of that. I don't know of an LSM which doesn't define msg_msg_alloc() but does define msg_msg_free(). Do you have a stack trace to show where it was getting freed?

Quoted 24 lines
CC Oren Laadan <[email protected]>
---
 ipc/checkpoint_msg.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
ipc/checkpoint_msg.c +1 -0
index 0a19d1f..6fa2c8e 100644
@@ -233,6 +233,7 @@ static struct msg_msg *restore_msg_contents_one(struct ckpt_ctx *ctx, int *clen)
 		goto out;
 	}
 	msg->next = NULL;
+        msg->security = NULL;
 	pseg = &msg->next;
 
 	/* set default MAC attributes */
Signature · 6 lines
1.7.1

_______________________________________________
Containers mailing list
Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linux-foundation.org/mailman/listinfo/containers

_______________________________________________
Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linux-foundation.org/mailman/listinfo/containers

#4 lore raw
In reply to a message not in the archive
Quoted 7 lines · On Wed, 30 Mar 2011 22:29:54 -0500 "Serge E. Hallyn"…
Quoted 4 lines · Jose R. Santos

This small oversight was causing either crashes on free_msg() or restart failures under some message queue workloads.

What kernel is this?

ckpt-v23-rc1

Quoted 11 lines

Starting with the last line in your context, there is:

	/* set default MAC attributes */
	ret = security_msg_msg_alloc(msg);
	if (ret < 0)
		goto out;

which should take care of that. I don't know of an LSM which doesn't define msg_msg_alloc() but does define msg_msg_free(). Do you have a stack trace to show where it was getting freed?

Sorry, should have put more details in the patch description. The problem here is that msg_msg_alloc() in not allocating anything and thus the msg->security just happens to have what ever random data that happens to be there after kmalloc was called for this msg. So the way this usually manifested was during the a second checkpoint/restart. For example:

run ./mq_test
checkpoint:
Saving the msg with SECURITY_NONE
restart:

	Restores the msg content but with msg->security set to
	something random (or 0x5a pattern if using DEBUG_SLAB)
second checkpoint:
	msg->security not NULL so we proceed in
	security_checkpoint_obj() to call security_msg_msg_checkpoint()

second restart:
All sorts of very weird, very different, hard to debug stuff happens afterwards. :)

Also, If you look at load_msg() in msgutil.c, the msg->security is also initialized to NULL _before_ calling security_msg_msg_alloc(). Hope this explains this fix better.

-JRS

Acked-by
#5 lore raw
Quoted 45 lines · Jose R. Santos
Quoted 7 lines · On Wed, 30 Mar 2011 22:29:54 -0500 "Serge E. Hallyn"…
Quoted 4 lines · Jose R. Santos

This small oversight was causing either crashes on free_msg() or restart failures under some message queue workloads.

What kernel is this?

ckpt-v23-rc1

Quoted 11 lines

Starting with the last line in your context, there is:

	/* set default MAC attributes */
	ret = security_msg_msg_alloc(msg);
	if (ret < 0)
		goto out;

which should take care of that. I don't know of an LSM which doesn't define msg_msg_alloc() but does define msg_msg_free(). Do you have a stack trace to show where it was getting freed?

Sorry, should have put more details in the patch description. The problem here is that msg_msg_alloc() in not allocating anything and thus the msg->security just happens to have what ever random data that happens to be there after kmalloc was called for this msg. So the way this usually manifested was during the a second checkpoint/restart. For example:

run ./mq_test
checkpoint:
Saving the msg with SECURITY_NONE
restart:

	Restores the msg content but with msg->security set to
	something random (or 0x5a pattern if using DEBUG_SLAB)
second checkpoint:
	msg->security not NULL so we proceed in
	security_checkpoint_obj() to call security_msg_msg_checkpoint()

second restart:
All sorts of very weird, very different, hard to debug stuff happens afterwards. :)

Quoted 5 lines

Also, If you look at load_msg() in msgutil.c, the msg->security is also initialized to NULL _before_ calling security_msg_msg_alloc(). Hope this explains this fix better.

-JRS

I see - thanks for the explanation.

Part of me would prefer to see the security hooks make sure that they set it, but that might thwart the people currently playing with LSM stacking, so your way is probably best.

thanks,
-serge

#6 lore raw
In reply to a message not in the archive

Jose,

Thanks for the patch - it's included in ckpt-v23-rc2.

Oren.

Quoted 21 lines · Jose R. Santos

This small oversight was causing either crashes on free_msg() or restart failures under some message queue workloads.

---
 ipc/checkpoint_msg.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
ipc/checkpoint_msg.c +1 -0
index 0a19d1f..6fa2c8e 100644
@@ -233,6 +233,7 @@ static struct msg_msg *restore_msg_contents_one(struct ckpt_ctx *ctx, int *clen)
 		goto out;
 	}
 	msg->next = NULL;
+        msg->security = NULL;
 	pseg = &msg->next;
 
 	/* set default MAC attributes */