ALSA: ppc: keywest: drop using attach adapter
[cascardo/linux.git] / kernel / audit.c
index 2125cc4..1c13e42 100644 (file)
@@ -43,6 +43,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
+#include <linux/file.h>
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/atomic.h>
@@ -345,7 +346,7 @@ static int audit_set_backlog_wait_time(u32 timeout)
 static int audit_set_enabled(u32 state)
 {
        int rc;
-       if (state < AUDIT_OFF || state > AUDIT_LOCKED)
+       if (state > AUDIT_LOCKED)
                return -EINVAL;
 
        rc =  audit_do_config_change("audit_enabled", &audit_enabled, state);
@@ -500,7 +501,6 @@ static int kauditd_thread(void *dummy)
        set_freezable();
        while (!kthread_should_stop()) {
                struct sk_buff *skb;
-               DECLARE_WAITQUEUE(wait, current);
 
                flush_hold_queue();
 
@@ -515,16 +515,8 @@ static int kauditd_thread(void *dummy)
                                audit_printk_skb(skb);
                        continue;
                }
-               set_current_state(TASK_INTERRUPTIBLE);
-               add_wait_queue(&kauditd_wait, &wait);
 
-               if (!skb_queue_len(&audit_skb_queue)) {
-                       try_to_freeze();
-                       schedule();
-               }
-
-               __set_current_state(TASK_RUNNING);
-               remove_wait_queue(&kauditd_wait, &wait);
+               wait_event_freezable(kauditd_wait, skb_queue_len(&audit_skb_queue));
        }
        return 0;
 }
@@ -673,7 +665,7 @@ static int audit_netlink_ok(struct sk_buff *skb, u16 msg_type)
        case AUDIT_MAKE_EQUIV:
                /* Only support auditd and auditctl in initial pid namespace
                 * for now. */
-               if ((task_active_pid_ns(current) != &init_pid_ns))
+               if (task_active_pid_ns(current) != &init_pid_ns)
                        return -EPERM;
 
                if (!netlink_capable(skb, CAP_AUDIT_CONTROL))
@@ -887,8 +879,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
                if (s.mask & AUDIT_STATUS_BACKLOG_WAIT_TIME) {
                        if (sizeof(s) > (size_t)nlh->nlmsg_len)
                                return -EINVAL;
-                       if (s.backlog_wait_time < 0 ||
-                           s.backlog_wait_time > 10*AUDIT_BACKLOG_WAIT_TIME)
+                       if (s.backlog_wait_time > 10*AUDIT_BACKLOG_WAIT_TIME)
                                return -EINVAL;
                        err = audit_set_backlog_wait_time(s.backlog_wait_time);
                        if (err < 0)
@@ -1110,7 +1101,7 @@ static void audit_receive(struct sk_buff  *skb)
 }
 
 /* Run custom bind function on netlink socket group connect or bind requests. */
-static int audit_bind(int group)
+static int audit_bind(struct net *net, int group)
 {
        if (!capable(CAP_AUDIT_READ))
                return -EPERM;
@@ -1395,7 +1386,8 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask,
                return NULL;
        }
 
-       audit_backlog_wait_time = audit_backlog_wait_time_master;
+       if (!reserve)
+               audit_backlog_wait_time = audit_backlog_wait_time_master;
 
        ab = audit_buffer_alloc(ctx, gfp_mask, type);
        if (!ab) {
@@ -1668,7 +1660,7 @@ void audit_log_cap(struct audit_buffer *ab, char *prefix, kernel_cap_t *cap)
        audit_log_format(ab, " %s=", prefix);
        CAP_FOR_EACH_U32(i) {
                audit_log_format(ab, "%08x",
-                                cap->cap[(_KERNEL_CAPABILITY_U32S-1) - i]);
+                                cap->cap[CAP_LAST_U32 - i]);
        }
 }
 
@@ -1769,7 +1761,7 @@ void audit_log_name(struct audit_context *context, struct audit_names *n,
        } else
                audit_log_format(ab, " name=(null)");
 
-       if (n->ino != (unsigned long)-1) {
+       if (n->ino != (unsigned long)-1)
                audit_log_format(ab, " inode=%lu"
                                 " dev=%02x:%02x mode=%#ho"
                                 " ouid=%u ogid=%u rdev=%02x:%02x",
@@ -1781,7 +1773,6 @@ void audit_log_name(struct audit_context *context, struct audit_names *n,
                                 from_kgid(&init_user_ns, n->gid),
                                 MAJOR(n->rdev),
                                 MINOR(n->rdev));
-       }
        if (n->osid != 0) {
                char *ctx = NULL;
                u32 len;
@@ -1848,11 +1839,29 @@ error_path:
 }
 EXPORT_SYMBOL(audit_log_task_context);
 
+void audit_log_d_path_exe(struct audit_buffer *ab,
+                         struct mm_struct *mm)
+{
+       struct file *exe_file;
+
+       if (!mm)
+               goto out_null;
+
+       exe_file = get_mm_exe_file(mm);
+       if (!exe_file)
+               goto out_null;
+
+       audit_log_d_path(ab, " exe=", &exe_file->f_path);
+       fput(exe_file);
+       return;
+out_null:
+       audit_log_format(ab, " exe=(null)");
+}
+
 void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk)
 {
        const struct cred *cred;
        char comm[sizeof(tsk->comm)];
-       struct mm_struct *mm = tsk->mm;
        char *tty;
 
        if (!ab)
@@ -1888,13 +1897,7 @@ void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk)
        audit_log_format(ab, " comm=");
        audit_log_untrustedstring(ab, get_task_comm(comm, tsk));
 
-       if (mm) {
-               down_read(&mm->mmap_sem);
-               if (mm->exe_file)
-                       audit_log_d_path(ab, " exe=", &mm->exe_file->f_path);
-               up_read(&mm->mmap_sem);
-       } else
-               audit_log_format(ab, " exe=(null)");
+       audit_log_d_path_exe(ab, tsk->mm);
        audit_log_task_context(ab);
 }
 EXPORT_SYMBOL(audit_log_task_info);
@@ -1925,7 +1928,7 @@ void audit_log_link_denied(const char *operation, struct path *link)
 
        /* Generate AUDIT_PATH record with object. */
        name->type = AUDIT_TYPE_NORMAL;
-       audit_copy_inode(name, link->dentry, link->dentry->d_inode);
+       audit_copy_inode(name, link->dentry, d_backing_inode(link->dentry));
        audit_log_name(current->audit_context, name, link, 0, NULL);
 out:
        kfree(name);