Audit: send signal info if selinux is disabled

Audit will not respond to signal requests if selinux is disabled since it is
unable to translate the 0 sid from the sending process to a context.  This
patch just doesn't send the context info if there isn't any.

Signed-off-by: Eric Paris <eparis@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Eric Paris 2009-09-23 13:46:00 -04:00 committed by Al Viro
parent 44e51a1b78
commit 939cbf260c

View file

@ -855,18 +855,24 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
break; break;
} }
case AUDIT_SIGNAL_INFO: case AUDIT_SIGNAL_INFO:
len = 0;
if (audit_sig_sid) {
err = security_secid_to_secctx(audit_sig_sid, &ctx, &len); err = security_secid_to_secctx(audit_sig_sid, &ctx, &len);
if (err) if (err)
return err; return err;
}
sig_data = kmalloc(sizeof(*sig_data) + len, GFP_KERNEL); sig_data = kmalloc(sizeof(*sig_data) + len, GFP_KERNEL);
if (!sig_data) { if (!sig_data) {
if (audit_sig_sid)
security_release_secctx(ctx, len); security_release_secctx(ctx, len);
return -ENOMEM; return -ENOMEM;
} }
sig_data->uid = audit_sig_uid; sig_data->uid = audit_sig_uid;
sig_data->pid = audit_sig_pid; sig_data->pid = audit_sig_pid;
if (audit_sig_sid) {
memcpy(sig_data->ctx, ctx, len); memcpy(sig_data->ctx, ctx, len);
security_release_secctx(ctx, len); security_release_secctx(ctx, len);
}
audit_send_reply(NETLINK_CB(skb).pid, seq, AUDIT_SIGNAL_INFO, audit_send_reply(NETLINK_CB(skb).pid, seq, AUDIT_SIGNAL_INFO,
0, 0, sig_data, sizeof(*sig_data) + len); 0, 0, sig_data, sizeof(*sig_data) + len);
kfree(sig_data); kfree(sig_data);