Incremental to returning sid in AUDIT_SIGNAL_INFO (and correcting it); will
fold on next rebase.
Signed-off-by: Al Viro <viro(a)zeniv.linux.org.uk>
---
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
Show replies by date