Commit 860c0aaf authored by Eric W. Biederman's avatar Eric W. Biederman

audit: Don't pass pid or uid to audit_log_common_recv_msg

The only place we use the uid and the pid that we calculate in
audit_receive_msg is in audit_log_common_recv_msg so move the
calculation of these values into the audit_log_common_recv_msg.

Simplify the calcuation of the current pid and uid by
reading them from current instead of reading them from
NETLINK_CREDS.

Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Eric Paris <eparis@redhat.com>
Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
parent 017143fe
...@@ -607,8 +607,7 @@ static int audit_netlink_ok(struct sk_buff *skb, u16 msg_type) ...@@ -607,8 +607,7 @@ static int audit_netlink_ok(struct sk_buff *skb, u16 msg_type)
} }
static int audit_log_common_recv_msg(struct audit_buffer **ab, u16 msg_type, static int audit_log_common_recv_msg(struct audit_buffer **ab, u16 msg_type,
u32 pid, u32 uid, uid_t auid, u32 ses, uid_t auid, u32 ses, u32 sid)
u32 sid)
{ {
int rc = 0; int rc = 0;
char *ctx = NULL; char *ctx = NULL;
...@@ -621,7 +620,9 @@ static int audit_log_common_recv_msg(struct audit_buffer **ab, u16 msg_type, ...@@ -621,7 +620,9 @@ static int audit_log_common_recv_msg(struct audit_buffer **ab, u16 msg_type,
*ab = audit_log_start(NULL, GFP_KERNEL, msg_type); *ab = audit_log_start(NULL, GFP_KERNEL, msg_type);
audit_log_format(*ab, "pid=%d uid=%u auid=%u ses=%u", audit_log_format(*ab, "pid=%d uid=%u auid=%u ses=%u",
pid, uid, auid, ses); task_tgid_vnr(current),
from_kuid(&init_user_ns, current_uid()),
auid, ses);
if (sid) { if (sid) {
rc = security_secid_to_secctx(sid, &ctx, &len); rc = security_secid_to_secctx(sid, &ctx, &len);
if (rc) if (rc)
...@@ -637,7 +638,7 @@ static int audit_log_common_recv_msg(struct audit_buffer **ab, u16 msg_type, ...@@ -637,7 +638,7 @@ static int audit_log_common_recv_msg(struct audit_buffer **ab, u16 msg_type,
static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
{ {
u32 uid, pid, seq, sid; u32 seq, sid;
void *data; void *data;
struct audit_status *status_get, status_set; struct audit_status *status_get, status_set;
int err; int err;
...@@ -663,8 +664,6 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -663,8 +664,6 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
return err; return err;
} }
pid = NETLINK_CREDS(skb)->pid;
uid = NETLINK_CREDS(skb)->uid;
loginuid = audit_get_loginuid(current); loginuid = audit_get_loginuid(current);
sessionid = audit_get_sessionid(current); sessionid = audit_get_sessionid(current);
security_task_getsecid(current, &sid); security_task_getsecid(current, &sid);
...@@ -735,7 +734,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -735,7 +734,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
if (err) if (err)
break; break;
} }
audit_log_common_recv_msg(&ab, msg_type, pid, uid, audit_log_common_recv_msg(&ab, msg_type,
loginuid, sessionid, sid); loginuid, sessionid, sid);
if (msg_type != AUDIT_USER_TTY) if (msg_type != AUDIT_USER_TTY)
...@@ -760,8 +759,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -760,8 +759,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
if (nlmsg_len(nlh) < sizeof(struct audit_rule)) if (nlmsg_len(nlh) < sizeof(struct audit_rule))
return -EINVAL; return -EINVAL;
if (audit_enabled == AUDIT_LOCKED) { if (audit_enabled == AUDIT_LOCKED) {
audit_log_common_recv_msg(&ab, AUDIT_CONFIG_CHANGE, pid, audit_log_common_recv_msg(&ab, AUDIT_CONFIG_CHANGE,
uid, loginuid, sessionid, sid); loginuid, sessionid, sid);
audit_log_format(ab, " audit_enabled=%d res=0", audit_log_format(ab, " audit_enabled=%d res=0",
audit_enabled); audit_enabled);
...@@ -779,8 +778,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -779,8 +778,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
if (nlmsg_len(nlh) < sizeof(struct audit_rule_data)) if (nlmsg_len(nlh) < sizeof(struct audit_rule_data))
return -EINVAL; return -EINVAL;
if (audit_enabled == AUDIT_LOCKED) { if (audit_enabled == AUDIT_LOCKED) {
audit_log_common_recv_msg(&ab, AUDIT_CONFIG_CHANGE, pid, audit_log_common_recv_msg(&ab, AUDIT_CONFIG_CHANGE,
uid, loginuid, sessionid, sid); loginuid, sessionid, sid);
audit_log_format(ab, " audit_enabled=%d res=0", audit_log_format(ab, " audit_enabled=%d res=0",
audit_enabled); audit_enabled);
...@@ -796,8 +795,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -796,8 +795,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
case AUDIT_TRIM: case AUDIT_TRIM:
audit_trim_trees(); audit_trim_trees();
audit_log_common_recv_msg(&ab, AUDIT_CONFIG_CHANGE, pid, audit_log_common_recv_msg(&ab, AUDIT_CONFIG_CHANGE,
uid, loginuid, sessionid, sid); loginuid, sessionid, sid);
audit_log_format(ab, " op=trim res=1"); audit_log_format(ab, " op=trim res=1");
audit_log_end(ab); audit_log_end(ab);
...@@ -828,8 +827,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -828,8 +827,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
/* OK, here comes... */ /* OK, here comes... */
err = audit_tag_tree(old, new); err = audit_tag_tree(old, new);
audit_log_common_recv_msg(&ab, AUDIT_CONFIG_CHANGE, pid, audit_log_common_recv_msg(&ab, AUDIT_CONFIG_CHANGE,
uid, loginuid, sessionid, sid); loginuid, sessionid, sid);
audit_log_format(ab, " op=make_equiv old="); audit_log_format(ab, " op=make_equiv old=");
audit_log_untrustedstring(ab, old); audit_log_untrustedstring(ab, old);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment