diff options
Diffstat (limited to 'kernel/audit.c')
-rw-r--r-- | kernel/audit.c | 77 |
1 files changed, 36 insertions, 41 deletions
diff --git a/kernel/audit.c b/kernel/audit.c index d96045789b54..939500317066 100644 --- a/kernel/audit.c +++ b/kernel/audit.c | |||
@@ -74,6 +74,8 @@ static int audit_initialized; | |||
74 | int audit_enabled; | 74 | int audit_enabled; |
75 | int audit_ever_enabled; | 75 | int audit_ever_enabled; |
76 | 76 | ||
77 | EXPORT_SYMBOL_GPL(audit_enabled); | ||
78 | |||
77 | /* Default state when kernel boots without any parameters. */ | 79 | /* Default state when kernel boots without any parameters. */ |
78 | static int audit_default; | 80 | static int audit_default; |
79 | 81 | ||
@@ -400,7 +402,7 @@ static void kauditd_send_skb(struct sk_buff *skb) | |||
400 | if (err < 0) { | 402 | if (err < 0) { |
401 | BUG_ON(err != -ECONNREFUSED); /* Shouldn't happen */ | 403 | BUG_ON(err != -ECONNREFUSED); /* Shouldn't happen */ |
402 | printk(KERN_ERR "audit: *NO* daemon at audit_pid=%d\n", audit_pid); | 404 | printk(KERN_ERR "audit: *NO* daemon at audit_pid=%d\n", audit_pid); |
403 | audit_log_lost("auditd dissapeared\n"); | 405 | audit_log_lost("auditd disappeared\n"); |
404 | audit_pid = 0; | 406 | audit_pid = 0; |
405 | /* we might get lucky and get this in the next auditd */ | 407 | /* we might get lucky and get this in the next auditd */ |
406 | audit_hold_skb(skb); | 408 | audit_hold_skb(skb); |
@@ -467,23 +469,16 @@ static int audit_prepare_user_tty(pid_t pid, uid_t loginuid, u32 sessionid) | |||
467 | struct task_struct *tsk; | 469 | struct task_struct *tsk; |
468 | int err; | 470 | int err; |
469 | 471 | ||
470 | read_lock(&tasklist_lock); | 472 | rcu_read_lock(); |
471 | tsk = find_task_by_vpid(pid); | 473 | tsk = find_task_by_vpid(pid); |
472 | err = -ESRCH; | 474 | if (!tsk) { |
473 | if (!tsk) | 475 | rcu_read_unlock(); |
474 | goto out; | 476 | return -ESRCH; |
475 | err = 0; | 477 | } |
476 | 478 | get_task_struct(tsk); | |
477 | spin_lock_irq(&tsk->sighand->siglock); | 479 | rcu_read_unlock(); |
478 | if (!tsk->signal->audit_tty) | 480 | err = tty_audit_push_task(tsk, loginuid, sessionid); |
479 | err = -EPERM; | 481 | put_task_struct(tsk); |
480 | spin_unlock_irq(&tsk->sighand->siglock); | ||
481 | if (err) | ||
482 | goto out; | ||
483 | |||
484 | tty_audit_push_task(tsk, loginuid, sessionid); | ||
485 | out: | ||
486 | read_unlock(&tasklist_lock); | ||
487 | return err; | 482 | return err; |
488 | } | 483 | } |
489 | 484 | ||
@@ -506,7 +501,7 @@ int audit_send_list(void *_dest) | |||
506 | } | 501 | } |
507 | 502 | ||
508 | struct sk_buff *audit_make_reply(int pid, int seq, int type, int done, | 503 | struct sk_buff *audit_make_reply(int pid, int seq, int type, int done, |
509 | int multi, void *payload, int size) | 504 | int multi, const void *payload, int size) |
510 | { | 505 | { |
511 | struct sk_buff *skb; | 506 | struct sk_buff *skb; |
512 | struct nlmsghdr *nlh; | 507 | struct nlmsghdr *nlh; |
@@ -555,8 +550,8 @@ static int audit_send_reply_thread(void *arg) | |||
555 | * Allocates an skb, builds the netlink message, and sends it to the pid. | 550 | * Allocates an skb, builds the netlink message, and sends it to the pid. |
556 | * No failure notifications. | 551 | * No failure notifications. |
557 | */ | 552 | */ |
558 | void audit_send_reply(int pid, int seq, int type, int done, int multi, | 553 | static void audit_send_reply(int pid, int seq, int type, int done, int multi, |
559 | void *payload, int size) | 554 | const void *payload, int size) |
560 | { | 555 | { |
561 | struct sk_buff *skb; | 556 | struct sk_buff *skb; |
562 | struct task_struct *tsk; | 557 | struct task_struct *tsk; |
@@ -678,9 +673,9 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
678 | 673 | ||
679 | pid = NETLINK_CREDS(skb)->pid; | 674 | pid = NETLINK_CREDS(skb)->pid; |
680 | uid = NETLINK_CREDS(skb)->uid; | 675 | uid = NETLINK_CREDS(skb)->uid; |
681 | loginuid = NETLINK_CB(skb).loginuid; | 676 | loginuid = audit_get_loginuid(current); |
682 | sessionid = NETLINK_CB(skb).sessionid; | 677 | sessionid = audit_get_sessionid(current); |
683 | sid = NETLINK_CB(skb).sid; | 678 | security_task_getsecid(current, &sid); |
684 | seq = nlh->nlmsg_seq; | 679 | seq = nlh->nlmsg_seq; |
685 | data = NLMSG_DATA(nlh); | 680 | data = NLMSG_DATA(nlh); |
686 | 681 | ||
@@ -880,40 +875,40 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
880 | case AUDIT_TTY_GET: { | 875 | case AUDIT_TTY_GET: { |
881 | struct audit_tty_status s; | 876 | struct audit_tty_status s; |
882 | struct task_struct *tsk; | 877 | struct task_struct *tsk; |
878 | unsigned long flags; | ||
883 | 879 | ||
884 | read_lock(&tasklist_lock); | 880 | rcu_read_lock(); |
885 | tsk = find_task_by_vpid(pid); | 881 | tsk = find_task_by_vpid(pid); |
886 | if (!tsk) | 882 | if (tsk && lock_task_sighand(tsk, &flags)) { |
887 | err = -ESRCH; | ||
888 | else { | ||
889 | spin_lock_irq(&tsk->sighand->siglock); | ||
890 | s.enabled = tsk->signal->audit_tty != 0; | 883 | s.enabled = tsk->signal->audit_tty != 0; |
891 | spin_unlock_irq(&tsk->sighand->siglock); | 884 | unlock_task_sighand(tsk, &flags); |
892 | } | 885 | } else |
893 | read_unlock(&tasklist_lock); | 886 | err = -ESRCH; |
894 | audit_send_reply(NETLINK_CB(skb).pid, seq, AUDIT_TTY_GET, 0, 0, | 887 | rcu_read_unlock(); |
895 | &s, sizeof(s)); | 888 | |
889 | if (!err) | ||
890 | audit_send_reply(NETLINK_CB(skb).pid, seq, | ||
891 | AUDIT_TTY_GET, 0, 0, &s, sizeof(s)); | ||
896 | break; | 892 | break; |
897 | } | 893 | } |
898 | case AUDIT_TTY_SET: { | 894 | case AUDIT_TTY_SET: { |
899 | struct audit_tty_status *s; | 895 | struct audit_tty_status *s; |
900 | struct task_struct *tsk; | 896 | struct task_struct *tsk; |
897 | unsigned long flags; | ||
901 | 898 | ||
902 | if (nlh->nlmsg_len < sizeof(struct audit_tty_status)) | 899 | if (nlh->nlmsg_len < sizeof(struct audit_tty_status)) |
903 | return -EINVAL; | 900 | return -EINVAL; |
904 | s = data; | 901 | s = data; |
905 | if (s->enabled != 0 && s->enabled != 1) | 902 | if (s->enabled != 0 && s->enabled != 1) |
906 | return -EINVAL; | 903 | return -EINVAL; |
907 | read_lock(&tasklist_lock); | 904 | rcu_read_lock(); |
908 | tsk = find_task_by_vpid(pid); | 905 | tsk = find_task_by_vpid(pid); |
909 | if (!tsk) | 906 | if (tsk && lock_task_sighand(tsk, &flags)) { |
910 | err = -ESRCH; | ||
911 | else { | ||
912 | spin_lock_irq(&tsk->sighand->siglock); | ||
913 | tsk->signal->audit_tty = s->enabled != 0; | 907 | tsk->signal->audit_tty = s->enabled != 0; |
914 | spin_unlock_irq(&tsk->sighand->siglock); | 908 | unlock_task_sighand(tsk, &flags); |
915 | } | 909 | } else |
916 | read_unlock(&tasklist_lock); | 910 | err = -ESRCH; |
911 | rcu_read_unlock(); | ||
917 | break; | 912 | break; |
918 | } | 913 | } |
919 | default: | 914 | default: |