diff options
| author | Eric W. Biederman <ebiederm@xmission.com> | 2012-09-11 03:24:49 -0400 |
|---|---|---|
| committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-09-17 21:07:40 -0400 |
| commit | 860c0aaff75e714c21d325f32d36a37572b4fffb (patch) | |
| tree | 2cbe5e79108da3a44ba5e5af7fbe07d22f1ed35a /kernel | |
| parent | 017143fecb3364e5fed8107d206799899f5dd684 (diff) | |
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: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/audit.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/kernel/audit.c b/kernel/audit.c index a31e31bba2d3..2e0dd5edf69b 100644 --- a/kernel/audit.c +++ b/kernel/audit.c | |||
| @@ -607,8 +607,7 @@ static int audit_netlink_ok(struct sk_buff *skb, u16 msg_type) | |||
| 607 | } | 607 | } |
| 608 | 608 | ||
| 609 | static int audit_log_common_recv_msg(struct audit_buffer **ab, u16 msg_type, | 609 | static int audit_log_common_recv_msg(struct audit_buffer **ab, u16 msg_type, |
| 610 | u32 pid, u32 uid, uid_t auid, u32 ses, | 610 | uid_t auid, u32 ses, u32 sid) |
| 611 | u32 sid) | ||
| 612 | { | 611 | { |
| 613 | int rc = 0; | 612 | int rc = 0; |
| 614 | char *ctx = NULL; | 613 | char *ctx = NULL; |
| @@ -621,7 +620,9 @@ static int audit_log_common_recv_msg(struct audit_buffer **ab, u16 msg_type, | |||
| 621 | 620 | ||
| 622 | *ab = audit_log_start(NULL, GFP_KERNEL, msg_type); | 621 | *ab = audit_log_start(NULL, GFP_KERNEL, msg_type); |
| 623 | audit_log_format(*ab, "pid=%d uid=%u auid=%u ses=%u", | 622 | audit_log_format(*ab, "pid=%d uid=%u auid=%u ses=%u", |
| 624 | pid, uid, auid, ses); | 623 | task_tgid_vnr(current), |
| 624 | from_kuid(&init_user_ns, current_uid()), | ||
| 625 | auid, ses); | ||
| 625 | if (sid) { | 626 | if (sid) { |
| 626 | rc = security_secid_to_secctx(sid, &ctx, &len); | 627 | rc = security_secid_to_secctx(sid, &ctx, &len); |
| 627 | if (rc) | 628 | if (rc) |
| @@ -637,7 +638,7 @@ static int audit_log_common_recv_msg(struct audit_buffer **ab, u16 msg_type, | |||
| 637 | 638 | ||
| 638 | static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | 639 | static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) |
| 639 | { | 640 | { |
| 640 | u32 uid, pid, seq, sid; | 641 | u32 seq, sid; |
| 641 | void *data; | 642 | void *data; |
| 642 | struct audit_status *status_get, status_set; | 643 | struct audit_status *status_get, status_set; |
| 643 | int err; | 644 | int err; |
| @@ -663,8 +664,6 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
| 663 | return err; | 664 | return err; |
| 664 | } | 665 | } |
| 665 | 666 | ||
| 666 | pid = NETLINK_CREDS(skb)->pid; | ||
| 667 | uid = NETLINK_CREDS(skb)->uid; | ||
| 668 | loginuid = audit_get_loginuid(current); | 667 | loginuid = audit_get_loginuid(current); |
| 669 | sessionid = audit_get_sessionid(current); | 668 | sessionid = audit_get_sessionid(current); |
| 670 | security_task_getsecid(current, &sid); | 669 | security_task_getsecid(current, &sid); |
| @@ -735,7 +734,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
| 735 | if (err) | 734 | if (err) |
| 736 | break; | 735 | break; |
| 737 | } | 736 | } |
| 738 | audit_log_common_recv_msg(&ab, msg_type, pid, uid, | 737 | audit_log_common_recv_msg(&ab, msg_type, |
| 739 | loginuid, sessionid, sid); | 738 | loginuid, sessionid, sid); |
| 740 | 739 | ||
| 741 | if (msg_type != AUDIT_USER_TTY) | 740 | if (msg_type != AUDIT_USER_TTY) |
| @@ -760,8 +759,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
| 760 | if (nlmsg_len(nlh) < sizeof(struct audit_rule)) | 759 | if (nlmsg_len(nlh) < sizeof(struct audit_rule)) |
| 761 | return -EINVAL; | 760 | return -EINVAL; |
| 762 | if (audit_enabled == AUDIT_LOCKED) { | 761 | if (audit_enabled == AUDIT_LOCKED) { |
| 763 | audit_log_common_recv_msg(&ab, AUDIT_CONFIG_CHANGE, pid, | 762 | audit_log_common_recv_msg(&ab, AUDIT_CONFIG_CHANGE, |
| 764 | uid, loginuid, sessionid, sid); | 763 | loginuid, sessionid, sid); |
| 765 | 764 | ||
| 766 | audit_log_format(ab, " audit_enabled=%d res=0", | 765 | audit_log_format(ab, " audit_enabled=%d res=0", |
| 767 | audit_enabled); | 766 | audit_enabled); |
| @@ -779,8 +778,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
| 779 | if (nlmsg_len(nlh) < sizeof(struct audit_rule_data)) | 778 | if (nlmsg_len(nlh) < sizeof(struct audit_rule_data)) |
| 780 | return -EINVAL; | 779 | return -EINVAL; |
| 781 | if (audit_enabled == AUDIT_LOCKED) { | 780 | if (audit_enabled == AUDIT_LOCKED) { |
| 782 | audit_log_common_recv_msg(&ab, AUDIT_CONFIG_CHANGE, pid, | 781 | audit_log_common_recv_msg(&ab, AUDIT_CONFIG_CHANGE, |
| 783 | uid, loginuid, sessionid, sid); | 782 | loginuid, sessionid, sid); |
| 784 | 783 | ||
| 785 | audit_log_format(ab, " audit_enabled=%d res=0", | 784 | audit_log_format(ab, " audit_enabled=%d res=0", |
| 786 | audit_enabled); | 785 | audit_enabled); |
| @@ -796,8 +795,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
| 796 | case AUDIT_TRIM: | 795 | case AUDIT_TRIM: |
| 797 | audit_trim_trees(); | 796 | audit_trim_trees(); |
| 798 | 797 | ||
| 799 | audit_log_common_recv_msg(&ab, AUDIT_CONFIG_CHANGE, pid, | 798 | audit_log_common_recv_msg(&ab, AUDIT_CONFIG_CHANGE, |
| 800 | uid, loginuid, sessionid, sid); | 799 | loginuid, sessionid, sid); |
| 801 | 800 | ||
| 802 | audit_log_format(ab, " op=trim res=1"); | 801 | audit_log_format(ab, " op=trim res=1"); |
| 803 | audit_log_end(ab); | 802 | audit_log_end(ab); |
| @@ -828,8 +827,8 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
| 828 | /* OK, here comes... */ | 827 | /* OK, here comes... */ |
| 829 | err = audit_tag_tree(old, new); | 828 | err = audit_tag_tree(old, new); |
| 830 | 829 | ||
| 831 | audit_log_common_recv_msg(&ab, AUDIT_CONFIG_CHANGE, pid, | 830 | audit_log_common_recv_msg(&ab, AUDIT_CONFIG_CHANGE, |
| 832 | uid, loginuid, sessionid, sid); | 831 | loginuid, sessionid, sid); |
| 833 | 832 | ||
| 834 | audit_log_format(ab, " op=make_equiv old="); | 833 | audit_log_format(ab, " op=make_equiv old="); |
| 835 | audit_log_untrustedstring(ab, old); | 834 | audit_log_untrustedstring(ab, old); |
