aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/audit.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/audit.c')
-rw-r--r--kernel/audit.c68
1 files changed, 30 insertions, 38 deletions
diff --git a/kernel/audit.c b/kernel/audit.c
index 8296aa516c5a..77770a034d59 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -56,7 +56,6 @@
56#include <net/netlink.h> 56#include <net/netlink.h>
57#include <linux/skbuff.h> 57#include <linux/skbuff.h>
58#include <linux/netlink.h> 58#include <linux/netlink.h>
59#include <linux/inotify.h>
60#include <linux/freezer.h> 59#include <linux/freezer.h>
61#include <linux/tty.h> 60#include <linux/tty.h>
62 61
@@ -468,23 +467,16 @@ static int audit_prepare_user_tty(pid_t pid, uid_t loginuid, u32 sessionid)
468 struct task_struct *tsk; 467 struct task_struct *tsk;
469 int err; 468 int err;
470 469
471 read_lock(&tasklist_lock); 470 rcu_read_lock();
472 tsk = find_task_by_vpid(pid); 471 tsk = find_task_by_vpid(pid);
473 err = -ESRCH; 472 if (!tsk) {
474 if (!tsk) 473 rcu_read_unlock();
475 goto out; 474 return -ESRCH;
476 err = 0; 475 }
477 476 get_task_struct(tsk);
478 spin_lock_irq(&tsk->sighand->siglock); 477 rcu_read_unlock();
479 if (!tsk->signal->audit_tty) 478 err = tty_audit_push_task(tsk, loginuid, sessionid);
480 err = -EPERM; 479 put_task_struct(tsk);
481 spin_unlock_irq(&tsk->sighand->siglock);
482 if (err)
483 goto out;
484
485 tty_audit_push_task(tsk, loginuid, sessionid);
486out:
487 read_unlock(&tasklist_lock);
488 return err; 480 return err;
489} 481}
490 482
@@ -507,7 +499,7 @@ int audit_send_list(void *_dest)
507} 499}
508 500
509struct sk_buff *audit_make_reply(int pid, int seq, int type, int done, 501struct sk_buff *audit_make_reply(int pid, int seq, int type, int done,
510 int multi, void *payload, int size) 502 int multi, const void *payload, int size)
511{ 503{
512 struct sk_buff *skb; 504 struct sk_buff *skb;
513 struct nlmsghdr *nlh; 505 struct nlmsghdr *nlh;
@@ -556,8 +548,8 @@ static int audit_send_reply_thread(void *arg)
556 * Allocates an skb, builds the netlink message, and sends it to the pid. 548 * Allocates an skb, builds the netlink message, and sends it to the pid.
557 * No failure notifications. 549 * No failure notifications.
558 */ 550 */
559void audit_send_reply(int pid, int seq, int type, int done, int multi, 551static void audit_send_reply(int pid, int seq, int type, int done, int multi,
560 void *payload, int size) 552 const void *payload, int size)
561{ 553{
562 struct sk_buff *skb; 554 struct sk_buff *skb;
563 struct task_struct *tsk; 555 struct task_struct *tsk;
@@ -881,40 +873,40 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
881 case AUDIT_TTY_GET: { 873 case AUDIT_TTY_GET: {
882 struct audit_tty_status s; 874 struct audit_tty_status s;
883 struct task_struct *tsk; 875 struct task_struct *tsk;
876 unsigned long flags;
884 877
885 read_lock(&tasklist_lock); 878 rcu_read_lock();
886 tsk = find_task_by_vpid(pid); 879 tsk = find_task_by_vpid(pid);
887 if (!tsk) 880 if (tsk && lock_task_sighand(tsk, &flags)) {
888 err = -ESRCH;
889 else {
890 spin_lock_irq(&tsk->sighand->siglock);
891 s.enabled = tsk->signal->audit_tty != 0; 881 s.enabled = tsk->signal->audit_tty != 0;
892 spin_unlock_irq(&tsk->sighand->siglock); 882 unlock_task_sighand(tsk, &flags);
893 } 883 } else
894 read_unlock(&tasklist_lock); 884 err = -ESRCH;
895 audit_send_reply(NETLINK_CB(skb).pid, seq, AUDIT_TTY_GET, 0, 0, 885 rcu_read_unlock();
896 &s, sizeof(s)); 886
887 if (!err)
888 audit_send_reply(NETLINK_CB(skb).pid, seq,
889 AUDIT_TTY_GET, 0, 0, &s, sizeof(s));
897 break; 890 break;
898 } 891 }
899 case AUDIT_TTY_SET: { 892 case AUDIT_TTY_SET: {
900 struct audit_tty_status *s; 893 struct audit_tty_status *s;
901 struct task_struct *tsk; 894 struct task_struct *tsk;
895 unsigned long flags;
902 896
903 if (nlh->nlmsg_len < sizeof(struct audit_tty_status)) 897 if (nlh->nlmsg_len < sizeof(struct audit_tty_status))
904 return -EINVAL; 898 return -EINVAL;
905 s = data; 899 s = data;
906 if (s->enabled != 0 && s->enabled != 1) 900 if (s->enabled != 0 && s->enabled != 1)
907 return -EINVAL; 901 return -EINVAL;
908 read_lock(&tasklist_lock); 902 rcu_read_lock();
909 tsk = find_task_by_vpid(pid); 903 tsk = find_task_by_vpid(pid);
910 if (!tsk) 904 if (tsk && lock_task_sighand(tsk, &flags)) {
911 err = -ESRCH;
912 else {
913 spin_lock_irq(&tsk->sighand->siglock);
914 tsk->signal->audit_tty = s->enabled != 0; 905 tsk->signal->audit_tty = s->enabled != 0;
915 spin_unlock_irq(&tsk->sighand->siglock); 906 unlock_task_sighand(tsk, &flags);
916 } 907 } else
917 read_unlock(&tasklist_lock); 908 err = -ESRCH;
909 rcu_read_unlock();
918 break; 910 break;
919 } 911 }
920 default: 912 default: