From: Alexander Viro Subject: [PATCH 2/4] make AUDIT_SIGNAL_INFO return string form of context Date: Fri, 19 May 2006 17:32:47 -0400 Message-ID: <200605192132.k4JLWlGb008852@devserv.devel.redhat.com> Return-path: Received: from devserv.devel.redhat.com (devserv.devel.redhat.com [172.16.58.1]) by int-mx1.corp.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id k4JLWlKK024015 for ; Fri, 19 May 2006 17:32:47 -0400 Received: from devserv.devel.redhat.com (localhost.localdomain [127.0.0.1]) by devserv.devel.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id k4JLWl9V008865 for ; Fri, 19 May 2006 17:32:47 -0400 Received: (from aviro@localhost) by devserv.devel.redhat.com (8.12.11.20060308/8.12.11/Submit) id k4JLWlGb008852 for linux-audit@redhat.com; Fri, 19 May 2006 17:32:47 -0400 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com To: linux-audit@redhat.com List-Id: linux-audit@redhat.com Incremental to returning sid in AUDIT_SIGNAL_INFO (and correcting it); will fold on next rebase. Signed-off-by: Al Viro --- include/linux/audit.h | 2 +- kernel/audit.c | 31 +++++++++++++++++++------------ 2 files changed, 20 insertions(+), 13 deletions(-) 419d00e6e54bfbcd91c2f72bb99d215ba45a717f diff --git a/include/linux/audit.h b/include/linux/audit.h index cfa1902..4a9f7c4 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -280,7 +280,7 @@ #ifdef __KERNEL__ struct audit_sig_info { uid_t uid; pid_t pid; - __u32 sid; + char ctx[0]; }; struct audit_buffer; diff --git a/kernel/audit.c b/kernel/audit.c index a300b1e..b834b2e 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -484,7 +484,9 @@ static int audit_receive_msg(struct sk_b struct audit_buffer *ab; u16 msg_type = nlh->nlmsg_type; uid_t loginuid; /* loginuid of sender */ - struct audit_sig_info sig_data; + struct audit_sig_info *sig_data; + char *ctx; + u32 len; err = audit_netlink_ok(NETLINK_CB(skb).eff_cap, msg_type); if (err) @@ -536,12 +538,9 @@ static int audit_receive_msg(struct sk_b if (status_get->mask & AUDIT_STATUS_PID) { int old = audit_pid; if (sid) { - char *ctx = NULL; - u32 len; - int rc; - if ((rc = selinux_ctxid_to_string( + if ((err = selinux_ctxid_to_string( sid, &ctx, &len))) - return rc; + return err; else audit_log(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE, @@ -577,8 +576,6 @@ static int audit_receive_msg(struct sk_b "user pid=%d uid=%u auid=%u", pid, uid, loginuid); if (sid) { - char *ctx = NULL; - u32 len; if (selinux_ctxid_to_string( sid, &ctx, &len)) { audit_log_format(ab, @@ -617,11 +614,21 @@ static int audit_receive_msg(struct sk_b loginuid, sid); break; case AUDIT_SIGNAL_INFO: - sig_data.uid = audit_sig_uid; - sig_data.pid = audit_sig_pid; - sig_data.sid = audit_sig_sid; + err = selinux_ctxid_to_string(audit_sig_sid, &ctx, &len); + if (err) + return err; + sig_data = kmalloc(sizeof(*sig_data) + len, GFP_KERNEL); + if (!sig_data) { + kfree(ctx); + return -ENOMEM; + } + sig_data->uid = audit_sig_uid; + sig_data->pid = audit_sig_pid; + memcpy(sig_data->ctx, ctx, len); + kfree(ctx); audit_send_reply(NETLINK_CB(skb).pid, seq, AUDIT_SIGNAL_INFO, - 0, 0, &sig_data, sizeof(sig_data)); + 0, 0, &sig_data, sizeof(*sig_data) + len); + kfree(sig_data); break; default: err = -EINVAL; -- 1.3.GIT