2013/2/6 Stephen Smalley <sds@xxxxxxxxxxxxx>:On 02/06/2013 10:21 AM, Tommi Rantala wrote:
2013/2/6 Stephen Smalley <sds@xxxxxxxxxxxxx>:
On 02/06/2013 07:56 AM, Tommi Rantala wrote:
Hello,
I'm hitting an oops in selinux_msg_queue_msgrcv() when fuzzing with
Trinity as the root user (in a qemu VM):
NULL msg->security at that point is a bug in the ipc subsystem; SELinux
is
just the messenger. Normally msg->security is set for every allocated
msg
by load_msg() -> security_msg_msg_alloc() ->
selinux_msg_msg_alloc_security(), and freed/cleared upon free_msg() ->
security_msg_msg_free() -> selinux_msg_msg_free_security(). Looking
around,
I see copy_msg() introduced for checkpoint-restore initializes
dst->security
to NULL but never sets it properly?
I am indeed building with CONFIG_CHECKPOINT_RESTORE=y, so your
analysis seems to be correct.
(cc originator of the bug)
If I am reading this correctly, then when the copy msg was created, a msg
security struct was already allocated
(prepare_copy->load_msg->security_msg_msg_alloc). So having copy_msg()
clear dst->security is also a memory leak in addition to leading to this
oops. Attached is a possible, un-tested fix.
I can still reproduce the exact same oops with the patch applied. I
also wanted to be sure that copy_msg() is called, so I added a warning
there, but that never gets triggered. So I suppose the problem is not
actually related to CONFIG_CHECKPOINT_RESTORE.