diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-09-11 02:43:14 -0400 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-09-17 21:04:33 -0400 |
commit | 8aa14b64981ee4b95959e1ed331b672d053aab62 (patch) | |
tree | 961b0db4505ea2885562a0fd230bf67503f5cd28 /kernel/audit.c | |
parent | f95732e2e0a649c148be0242b72e3c7473092687 (diff) |
audit: Simply AUDIT_TTY_SET and AUDIT_TTY_GET
Use current instead of looking up the current up the current task by
process identifier. Netlink requests are processed in trhe context of
the sending task so this is safe.
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/audit.c')
-rw-r--r-- | kernel/audit.c | 38 |
1 files changed, 13 insertions, 25 deletions
diff --git a/kernel/audit.c b/kernel/audit.c index 58f704b432e4..2a8728fdefc4 100644 --- a/kernel/audit.c +++ b/kernel/audit.c | |||
@@ -866,41 +866,29 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
866 | break; | 866 | break; |
867 | case AUDIT_TTY_GET: { | 867 | case AUDIT_TTY_GET: { |
868 | struct audit_tty_status s; | 868 | struct audit_tty_status s; |
869 | struct task_struct *tsk; | 869 | struct task_struct *tsk = current; |
870 | unsigned long flags; | 870 | |
871 | 871 | spin_lock_irq(&tsk->sighand->siglock); | |
872 | rcu_read_lock(); | 872 | s.enabled = tsk->signal->audit_tty != 0; |
873 | tsk = find_task_by_vpid(pid); | 873 | spin_unlock_irq(&tsk->sighand->siglock); |
874 | if (tsk && lock_task_sighand(tsk, &flags)) { | 874 | |
875 | s.enabled = tsk->signal->audit_tty != 0; | 875 | audit_send_reply(NETLINK_CB(skb).pid, seq, |
876 | unlock_task_sighand(tsk, &flags); | 876 | AUDIT_TTY_GET, 0, 0, &s, sizeof(s)); |
877 | } else | ||
878 | err = -ESRCH; | ||
879 | rcu_read_unlock(); | ||
880 | |||
881 | if (!err) | ||
882 | audit_send_reply(NETLINK_CB(skb).pid, seq, | ||
883 | AUDIT_TTY_GET, 0, 0, &s, sizeof(s)); | ||
884 | break; | 877 | break; |
885 | } | 878 | } |
886 | case AUDIT_TTY_SET: { | 879 | case AUDIT_TTY_SET: { |
887 | struct audit_tty_status *s; | 880 | struct audit_tty_status *s; |
888 | struct task_struct *tsk; | 881 | struct task_struct *tsk = current; |
889 | unsigned long flags; | ||
890 | 882 | ||
891 | if (nlh->nlmsg_len < sizeof(struct audit_tty_status)) | 883 | if (nlh->nlmsg_len < sizeof(struct audit_tty_status)) |
892 | return -EINVAL; | 884 | return -EINVAL; |
893 | s = data; | 885 | s = data; |
894 | if (s->enabled != 0 && s->enabled != 1) | 886 | if (s->enabled != 0 && s->enabled != 1) |
895 | return -EINVAL; | 887 | return -EINVAL; |
896 | rcu_read_lock(); | 888 | |
897 | tsk = find_task_by_vpid(pid); | 889 | spin_lock_irq(&tsk->sighand->siglock); |
898 | if (tsk && lock_task_sighand(tsk, &flags)) { | 890 | tsk->signal->audit_tty = s->enabled != 0; |
899 | tsk->signal->audit_tty = s->enabled != 0; | 891 | spin_unlock_irq(&tsk->sighand->siglock); |
900 | unlock_task_sighand(tsk, &flags); | ||
901 | } else | ||
902 | err = -ESRCH; | ||
903 | rcu_read_unlock(); | ||
904 | break; | 892 | break; |
905 | } | 893 | } |
906 | default: | 894 | default: |