Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/audit
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 18 Jan 2012 00:06:51 +0000 (16:06 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 18 Jan 2012 00:41:31 +0000 (16:41 -0800)
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/audit: (29 commits)
  audit: no leading space in audit_log_d_path prefix
  audit: treat s_id as an untrusted string
  audit: fix signedness bug in audit_log_execve_info()
  audit: comparison on interprocess fields
  audit: implement all object interfield comparisons
  audit: allow interfield comparison between gid and ogid
  audit: complex interfield comparison helper
  audit: allow interfield comparison in audit rules
  Kernel: Audit Support For The ARM Platform
  audit: do not call audit_getname on error
  audit: only allow tasks to set their loginuid if it is -1
  audit: remove task argument to audit_set_loginuid
  audit: allow audit matching on inode gid
  audit: allow matching on obj_uid
  audit: remove audit_finish_fork as it can't be called
  audit: reject entry,always rules
  audit: inline audit_free to simplify the look of generic code
  audit: drop audit_set_macxattr as it doesn't do anything
  audit: inline checks for not needing to collect aux records
  audit: drop some potentially inadvisable likely notations
  ...

Use evil merge to fix up grammar mistakes in Kconfig file.

Bad speling and horrible grammar (and copious swearing) is to be
expected, but let's keep it to commit messages and comments, rather than
expose it to users in config help texts or printouts.

1  2 
arch/mips/include/asm/ptrace.h
arch/x86/ia32/ia32entry.S
arch/x86/kernel/entry_32.S
arch/x86/kernel/entry_64.S
fs/proc/base.c
include/linux/ptrace.h
init/Kconfig
kernel/audit.c
kernel/exit.c
kernel/fork.c

@@@ -137,14 -137,26 +137,26 @@@ extern int ptrace_set_watch_regs(struc
   */
  #define user_mode(regs) (((regs)->cp0_status & KU_MASK) == KU_USER)
  
- #define regs_return_value(_regs) ((_regs)->regs[2])
+ static inline int is_syscall_success(struct pt_regs *regs)
+ {
+       return !regs->regs[7];
+ }
+ static inline long regs_return_value(struct pt_regs *regs)
+ {
+       if (is_syscall_success(regs))
+               return regs->regs[2];
+       else
+               return -regs->regs[2];
+ }
  #define instruction_pointer(regs) ((regs)->cp0_epc)
  #define profile_pc(regs) instruction_pointer(regs)
  
  extern asmlinkage void syscall_trace_enter(struct pt_regs *regs);
  extern asmlinkage void syscall_trace_leave(struct pt_regs *regs);
  
 -extern NORET_TYPE void die(const char *, struct pt_regs *) ATTRIB_NORET;
 +extern void die(const char *, struct pt_regs *) __noreturn;
  
  static inline void die_if_kernel(const char *str, struct pt_regs *regs)
  {
@@@ -14,6 -14,7 +14,7 @@@
  #include <asm/segment.h>
  #include <asm/irqflags.h>
  #include <linux/linkage.h>
+ #include <linux/err.h>
  
  /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this.  */
  #include <linux/elf-em.h>
@@@ -27,6 -28,8 +28,6 @@@
  
        .section .entry.text, "ax"
  
 -#define IA32_NR_syscalls ((ia32_syscall_end - ia32_sys_call_table)/8)
 -
        .macro IA32_ARG_FIXUP noebp=0
        movl    %edi,%r8d
        .if \noebp
@@@ -189,7 -192,7 +190,7 @@@ sysexit_from_sys_call
        movl %ebx,%edx                  /* 3rd arg: 1st syscall arg */
        movl %eax,%esi                  /* 2nd arg: syscall number */
        movl $AUDIT_ARCH_I386,%edi      /* 1st arg: audit arch */
-       call audit_syscall_entry
+       call __audit_syscall_entry
        movl RAX-ARGOFFSET(%rsp),%eax   /* reload syscall number */
        cmpq $(IA32_NR_syscalls-1),%rax
        ja ia32_badsys
        TRACE_IRQS_ON
        sti
        movl %eax,%esi          /* second arg, syscall return value */
-       cmpl $0,%eax            /* is it < 0? */
-       setl %al                /* 1 if so, 0 if not */
+       cmpl $-MAX_ERRNO,%eax   /* is it an error ? */
+       jbe 1f
+       movslq %eax, %rsi       /* if error sign extend to 64 bits */
+ 1:    setbe %al               /* 1 if error, 0 if not */
        movzbl %al,%edi         /* zero-extend that into %edi */
-       inc %edi /* first arg, 0->1(AUDITSC_SUCCESS), 1->2(AUDITSC_FAILURE) */
-       call audit_syscall_exit
-       movl RAX-ARGOFFSET(%rsp),%eax   /* reload syscall return value */
+       call __audit_syscall_exit
+       movq RAX-ARGOFFSET(%rsp),%rax   /* reload syscall return value */
        movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
        cli
        TRACE_IRQS_OFF
@@@ -445,6 -449,9 +447,6 @@@ ia32_badsys
        movq $-ENOSYS,%rax
        jmp ia32_sysret
  
 -quiet_ni_syscall:
 -      movq $-ENOSYS,%rax
 -      ret
        CFI_ENDPROC
        
        .macro PTREGSCALL label, func, arg
@@@ -489,3 -496,357 +491,3 @@@ ia32_ptregs_common
        jmp  ia32_sysret        /* misbalances the return cache */
        CFI_ENDPROC
  END(ia32_ptregs_common)
 -
 -      .section .rodata,"a"
 -      .align 8
 -ia32_sys_call_table:
 -      .quad sys_restart_syscall
 -      .quad sys_exit
 -      .quad stub32_fork
 -      .quad sys_read
 -      .quad sys_write
 -      .quad compat_sys_open           /* 5 */
 -      .quad sys_close
 -      .quad sys32_waitpid
 -      .quad sys_creat
 -      .quad sys_link
 -      .quad sys_unlink                /* 10 */
 -      .quad stub32_execve
 -      .quad sys_chdir
 -      .quad compat_sys_time
 -      .quad sys_mknod
 -      .quad sys_chmod         /* 15 */
 -      .quad sys_lchown16
 -      .quad quiet_ni_syscall                  /* old break syscall holder */
 -      .quad sys_stat
 -      .quad sys32_lseek
 -      .quad sys_getpid                /* 20 */
 -      .quad compat_sys_mount  /* mount  */
 -      .quad sys_oldumount     /* old_umount  */
 -      .quad sys_setuid16
 -      .quad sys_getuid16
 -      .quad compat_sys_stime  /* stime */             /* 25 */
 -      .quad compat_sys_ptrace /* ptrace */
 -      .quad sys_alarm
 -      .quad sys_fstat /* (old)fstat */
 -      .quad sys_pause
 -      .quad compat_sys_utime  /* 30 */
 -      .quad quiet_ni_syscall  /* old stty syscall holder */
 -      .quad quiet_ni_syscall  /* old gtty syscall holder */
 -      .quad sys_access
 -      .quad sys_nice  
 -      .quad quiet_ni_syscall  /* 35 */        /* old ftime syscall holder */
 -      .quad sys_sync
 -      .quad sys32_kill
 -      .quad sys_rename
 -      .quad sys_mkdir
 -      .quad sys_rmdir         /* 40 */
 -      .quad sys_dup
 -      .quad sys_pipe
 -      .quad compat_sys_times
 -      .quad quiet_ni_syscall                  /* old prof syscall holder */
 -      .quad sys_brk           /* 45 */
 -      .quad sys_setgid16
 -      .quad sys_getgid16
 -      .quad sys_signal
 -      .quad sys_geteuid16
 -      .quad sys_getegid16     /* 50 */
 -      .quad sys_acct
 -      .quad sys_umount                        /* new_umount */
 -      .quad quiet_ni_syscall                  /* old lock syscall holder */
 -      .quad compat_sys_ioctl
 -      .quad compat_sys_fcntl64                /* 55 */
 -      .quad quiet_ni_syscall                  /* old mpx syscall holder */
 -      .quad sys_setpgid
 -      .quad quiet_ni_syscall                  /* old ulimit syscall holder */
 -      .quad sys_olduname
 -      .quad sys_umask         /* 60 */
 -      .quad sys_chroot
 -      .quad compat_sys_ustat
 -      .quad sys_dup2
 -      .quad sys_getppid
 -      .quad sys_getpgrp               /* 65 */
 -      .quad sys_setsid
 -      .quad sys32_sigaction
 -      .quad sys_sgetmask
 -      .quad sys_ssetmask
 -      .quad sys_setreuid16    /* 70 */
 -      .quad sys_setregid16
 -      .quad sys32_sigsuspend
 -      .quad compat_sys_sigpending
 -      .quad sys_sethostname
 -      .quad compat_sys_setrlimit      /* 75 */
 -      .quad compat_sys_old_getrlimit  /* old_getrlimit */
 -      .quad compat_sys_getrusage
 -      .quad compat_sys_gettimeofday
 -      .quad compat_sys_settimeofday
 -      .quad sys_getgroups16   /* 80 */
 -      .quad sys_setgroups16
 -      .quad compat_sys_old_select
 -      .quad sys_symlink
 -      .quad sys_lstat
 -      .quad sys_readlink              /* 85 */
 -      .quad sys_uselib
 -      .quad sys_swapon
 -      .quad sys_reboot
 -      .quad compat_sys_old_readdir
 -      .quad sys32_mmap                /* 90 */
 -      .quad sys_munmap
 -      .quad sys_truncate
 -      .quad sys_ftruncate
 -      .quad sys_fchmod
 -      .quad sys_fchown16              /* 95 */
 -      .quad sys_getpriority
 -      .quad sys_setpriority
 -      .quad quiet_ni_syscall                  /* old profil syscall holder */
 -      .quad compat_sys_statfs
 -      .quad compat_sys_fstatfs                /* 100 */
 -      .quad sys_ioperm
 -      .quad compat_sys_socketcall
 -      .quad sys_syslog
 -      .quad compat_sys_setitimer
 -      .quad compat_sys_getitimer      /* 105 */
 -      .quad compat_sys_newstat
 -      .quad compat_sys_newlstat
 -      .quad compat_sys_newfstat
 -      .quad sys_uname
 -      .quad stub32_iopl               /* 110 */
 -      .quad sys_vhangup
 -      .quad quiet_ni_syscall  /* old "idle" system call */
 -      .quad sys32_vm86_warning        /* vm86old */ 
 -      .quad compat_sys_wait4
 -      .quad sys_swapoff               /* 115 */
 -      .quad compat_sys_sysinfo
 -      .quad sys32_ipc
 -      .quad sys_fsync
 -      .quad stub32_sigreturn
 -      .quad stub32_clone              /* 120 */
 -      .quad sys_setdomainname
 -      .quad sys_newuname
 -      .quad sys_modify_ldt
 -      .quad compat_sys_adjtimex
 -      .quad sys32_mprotect            /* 125 */
 -      .quad compat_sys_sigprocmask
 -      .quad quiet_ni_syscall          /* create_module */
 -      .quad sys_init_module
 -      .quad sys_delete_module
 -      .quad quiet_ni_syscall          /* 130  get_kernel_syms */
 -      .quad sys32_quotactl
 -      .quad sys_getpgid
 -      .quad sys_fchdir
 -      .quad quiet_ni_syscall  /* bdflush */
 -      .quad sys_sysfs         /* 135 */
 -      .quad sys_personality
 -      .quad quiet_ni_syscall  /* for afs_syscall */
 -      .quad sys_setfsuid16
 -      .quad sys_setfsgid16
 -      .quad sys_llseek                /* 140 */
 -      .quad compat_sys_getdents
 -      .quad compat_sys_select
 -      .quad sys_flock
 -      .quad sys_msync
 -      .quad compat_sys_readv          /* 145 */
 -      .quad compat_sys_writev
 -      .quad sys_getsid
 -      .quad sys_fdatasync
 -      .quad compat_sys_sysctl /* sysctl */
 -      .quad sys_mlock         /* 150 */
 -      .quad sys_munlock
 -      .quad sys_mlockall
 -      .quad sys_munlockall
 -      .quad sys_sched_setparam
 -      .quad sys_sched_getparam   /* 155 */
 -      .quad sys_sched_setscheduler
 -      .quad sys_sched_getscheduler
 -      .quad sys_sched_yield
 -      .quad sys_sched_get_priority_max
 -      .quad sys_sched_get_priority_min  /* 160 */
 -      .quad sys32_sched_rr_get_interval
 -      .quad compat_sys_nanosleep
 -      .quad sys_mremap
 -      .quad sys_setresuid16
 -      .quad sys_getresuid16   /* 165 */
 -      .quad sys32_vm86_warning        /* vm86 */ 
 -      .quad quiet_ni_syscall  /* query_module */
 -      .quad sys_poll
 -      .quad quiet_ni_syscall /* old nfsservctl */
 -      .quad sys_setresgid16   /* 170 */
 -      .quad sys_getresgid16
 -      .quad sys_prctl
 -      .quad stub32_rt_sigreturn
 -      .quad sys32_rt_sigaction
 -      .quad sys32_rt_sigprocmask      /* 175 */
 -      .quad sys32_rt_sigpending
 -      .quad compat_sys_rt_sigtimedwait
 -      .quad sys32_rt_sigqueueinfo
 -      .quad sys_rt_sigsuspend
 -      .quad sys32_pread               /* 180 */
 -      .quad sys32_pwrite
 -      .quad sys_chown16
 -      .quad sys_getcwd
 -      .quad sys_capget
 -      .quad sys_capset
 -      .quad stub32_sigaltstack
 -      .quad sys32_sendfile
 -      .quad quiet_ni_syscall          /* streams1 */
 -      .quad quiet_ni_syscall          /* streams2 */
 -      .quad stub32_vfork            /* 190 */
 -      .quad compat_sys_getrlimit
 -      .quad sys_mmap_pgoff
 -      .quad sys32_truncate64
 -      .quad sys32_ftruncate64
 -      .quad sys32_stat64              /* 195 */
 -      .quad sys32_lstat64
 -      .quad sys32_fstat64
 -      .quad sys_lchown
 -      .quad sys_getuid
 -      .quad sys_getgid                /* 200 */
 -      .quad sys_geteuid
 -      .quad sys_getegid
 -      .quad sys_setreuid
 -      .quad sys_setregid
 -      .quad sys_getgroups     /* 205 */
 -      .quad sys_setgroups
 -      .quad sys_fchown
 -      .quad sys_setresuid
 -      .quad sys_getresuid
 -      .quad sys_setresgid     /* 210 */
 -      .quad sys_getresgid
 -      .quad sys_chown
 -      .quad sys_setuid
 -      .quad sys_setgid
 -      .quad sys_setfsuid              /* 215 */
 -      .quad sys_setfsgid
 -      .quad sys_pivot_root
 -      .quad sys_mincore
 -      .quad sys_madvise
 -      .quad compat_sys_getdents64     /* 220 getdents64 */
 -      .quad compat_sys_fcntl64        
 -      .quad quiet_ni_syscall          /* tux */
 -      .quad quiet_ni_syscall          /* security */
 -      .quad sys_gettid        
 -      .quad sys32_readahead   /* 225 */
 -      .quad sys_setxattr
 -      .quad sys_lsetxattr
 -      .quad sys_fsetxattr
 -      .quad sys_getxattr
 -      .quad sys_lgetxattr     /* 230 */
 -      .quad sys_fgetxattr
 -      .quad sys_listxattr
 -      .quad sys_llistxattr
 -      .quad sys_flistxattr
 -      .quad sys_removexattr   /* 235 */
 -      .quad sys_lremovexattr
 -      .quad sys_fremovexattr
 -      .quad sys_tkill
 -      .quad sys_sendfile64 
 -      .quad compat_sys_futex          /* 240 */
 -      .quad compat_sys_sched_setaffinity
 -      .quad compat_sys_sched_getaffinity
 -      .quad sys_set_thread_area
 -      .quad sys_get_thread_area
 -      .quad compat_sys_io_setup       /* 245 */
 -      .quad sys_io_destroy
 -      .quad compat_sys_io_getevents
 -      .quad compat_sys_io_submit
 -      .quad sys_io_cancel
 -      .quad sys32_fadvise64           /* 250 */
 -      .quad quiet_ni_syscall  /* free_huge_pages */
 -      .quad sys_exit_group
 -      .quad sys32_lookup_dcookie
 -      .quad sys_epoll_create
 -      .quad sys_epoll_ctl             /* 255 */
 -      .quad sys_epoll_wait
 -      .quad sys_remap_file_pages
 -      .quad sys_set_tid_address
 -      .quad compat_sys_timer_create
 -      .quad compat_sys_timer_settime  /* 260 */
 -      .quad compat_sys_timer_gettime
 -      .quad sys_timer_getoverrun
 -      .quad sys_timer_delete
 -      .quad compat_sys_clock_settime
 -      .quad compat_sys_clock_gettime  /* 265 */
 -      .quad compat_sys_clock_getres
 -      .quad compat_sys_clock_nanosleep
 -      .quad compat_sys_statfs64
 -      .quad compat_sys_fstatfs64
 -      .quad sys_tgkill                /* 270 */
 -      .quad compat_sys_utimes
 -      .quad sys32_fadvise64_64
 -      .quad quiet_ni_syscall  /* sys_vserver */
 -      .quad sys_mbind
 -      .quad compat_sys_get_mempolicy  /* 275 */
 -      .quad sys_set_mempolicy
 -      .quad compat_sys_mq_open
 -      .quad sys_mq_unlink
 -      .quad compat_sys_mq_timedsend
 -      .quad compat_sys_mq_timedreceive        /* 280 */
 -      .quad compat_sys_mq_notify
 -      .quad compat_sys_mq_getsetattr
 -      .quad compat_sys_kexec_load     /* reserved for kexec */
 -      .quad compat_sys_waitid
 -      .quad quiet_ni_syscall          /* 285: sys_altroot */
 -      .quad sys_add_key
 -      .quad sys_request_key
 -      .quad sys_keyctl
 -      .quad sys_ioprio_set
 -      .quad sys_ioprio_get            /* 290 */
 -      .quad sys_inotify_init
 -      .quad sys_inotify_add_watch
 -      .quad sys_inotify_rm_watch
 -      .quad sys_migrate_pages
 -      .quad compat_sys_openat         /* 295 */
 -      .quad sys_mkdirat
 -      .quad sys_mknodat
 -      .quad sys_fchownat
 -      .quad compat_sys_futimesat
 -      .quad sys32_fstatat             /* 300 */
 -      .quad sys_unlinkat
 -      .quad sys_renameat
 -      .quad sys_linkat
 -      .quad sys_symlinkat
 -      .quad sys_readlinkat            /* 305 */
 -      .quad sys_fchmodat
 -      .quad sys_faccessat
 -      .quad compat_sys_pselect6
 -      .quad compat_sys_ppoll
 -      .quad sys_unshare               /* 310 */
 -      .quad compat_sys_set_robust_list
 -      .quad compat_sys_get_robust_list
 -      .quad sys_splice
 -      .quad sys32_sync_file_range
 -      .quad sys_tee                   /* 315 */
 -      .quad compat_sys_vmsplice
 -      .quad compat_sys_move_pages
 -      .quad sys_getcpu
 -      .quad sys_epoll_pwait
 -      .quad compat_sys_utimensat      /* 320 */
 -      .quad compat_sys_signalfd
 -      .quad sys_timerfd_create
 -      .quad sys_eventfd
 -      .quad sys32_fallocate
 -      .quad compat_sys_timerfd_settime        /* 325 */
 -      .quad compat_sys_timerfd_gettime
 -      .quad compat_sys_signalfd4
 -      .quad sys_eventfd2
 -      .quad sys_epoll_create1
 -      .quad sys_dup3                          /* 330 */
 -      .quad sys_pipe2
 -      .quad sys_inotify_init1
 -      .quad compat_sys_preadv
 -      .quad compat_sys_pwritev
 -      .quad compat_sys_rt_tgsigqueueinfo      /* 335 */
 -      .quad sys_perf_event_open
 -      .quad compat_sys_recvmmsg
 -      .quad sys_fanotify_init
 -      .quad sys32_fanotify_mark
 -      .quad sys_prlimit64             /* 340 */
 -      .quad sys_name_to_handle_at
 -      .quad compat_sys_open_by_handle_at
 -      .quad compat_sys_clock_adjtime
 -      .quad sys_syncfs
 -      .quad compat_sys_sendmmsg       /* 345 */
 -      .quad sys_setns
 -      .quad compat_sys_process_vm_readv
 -      .quad compat_sys_process_vm_writev
 -ia32_syscall_end:
@@@ -42,6 -42,7 +42,7 @@@
   */
  
  #include <linux/linkage.h>
+ #include <linux/err.h>
  #include <asm/thread_info.h>
  #include <asm/irqflags.h>
  #include <asm/errno.h>
@@@ -81,6 -82,8 +82,6 @@@
   * enough to patch inline, increasing performance.
   */
  
 -#define nr_syscalls ((syscall_table_size)/4)
 -
  #ifdef CONFIG_PREEMPT
  #define preempt_stop(clobbers)        DISABLE_INTERRUPTS(clobbers); TRACE_IRQS_OFF
  #else
@@@ -421,7 -424,7 +422,7 @@@ sysenter_past_esp
        testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
        jnz sysenter_audit
  sysenter_do_call:
 -      cmpl $(nr_syscalls), %eax
 +      cmpl $(NR_syscalls), %eax
        jae syscall_badsys
        call *sys_call_table(,%eax,4)
        movl %eax,PT_EAX(%esp)
@@@ -453,7 -456,7 +454,7 @@@ sysenter_audit
        movl %ebx,%ecx                  /* 3rd arg: 1st syscall arg */
        movl %eax,%edx                  /* 2nd arg: syscall number */
        movl $AUDIT_ARCH_I386,%eax      /* 1st arg: audit arch */
-       call audit_syscall_entry
+       call __audit_syscall_entry
        pushl_cfi %ebx
        movl PT_EAX(%esp),%eax          /* reload syscall number */
        jmp sysenter_do_call
@@@ -464,11 -467,10 +465,10 @@@ sysexit_audit
        TRACE_IRQS_ON
        ENABLE_INTERRUPTS(CLBR_ANY)
        movl %eax,%edx          /* second arg, syscall return value */
-       cmpl $0,%eax            /* is it < 0? */
-       setl %al                /* 1 if so, 0 if not */
+       cmpl $-MAX_ERRNO,%eax   /* is it an error ? */
+       setbe %al               /* 1 if so, 0 if not */
        movzbl %al,%eax         /* zero-extend that */
-       inc %eax /* first arg, 0->1(AUDITSC_SUCCESS), 1->2(AUDITSC_FAILURE) */
-       call audit_syscall_exit
+       call __audit_syscall_exit
        DISABLE_INTERRUPTS(CLBR_ANY)
        TRACE_IRQS_OFF
        movl TI_flags(%ebp), %ecx
@@@ -502,7 -504,7 +502,7 @@@ ENTRY(system_call
                                        # system call tracing in operation / emulation
        testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
        jnz syscall_trace_entry
 -      cmpl $(nr_syscalls), %eax
 +      cmpl $(NR_syscalls), %eax
        jae syscall_badsys
  syscall_call:
        call *sys_call_table(,%eax,4)
@@@ -652,7 -654,7 +652,7 @@@ syscall_trace_entry
        movl %esp, %eax
        call syscall_trace_enter
        /* What it returned is what we'll actually use.  */
 -      cmpl $(nr_syscalls), %eax
 +      cmpl $(NR_syscalls), %eax
        jnae syscall_call
        jmp syscall_exit
  END(syscall_trace_entry)
@@@ -692,28 -694,29 +692,28 @@@ END(syscall_badsys
   * System calls that need a pt_regs pointer.
   */
  #define PTREGSCALL0(name) \
 -      ALIGN; \
 -ptregs_##name: \
 +ENTRY(ptregs_##name) ;  \
        leal 4(%esp),%eax; \
 -      jmp sys_##name;
 +      jmp sys_##name; \
 +ENDPROC(ptregs_##name)
  
  #define PTREGSCALL1(name) \
 -      ALIGN; \
 -ptregs_##name: \
 +ENTRY(ptregs_##name) ; \
        leal 4(%esp),%edx; \
        movl (PT_EBX+4)(%esp),%eax; \
 -      jmp sys_##name;
 +      jmp sys_##name; \
 +ENDPROC(ptregs_##name)
  
  #define PTREGSCALL2(name) \
 -      ALIGN; \
 -ptregs_##name: \
 +ENTRY(ptregs_##name) ; \
        leal 4(%esp),%ecx; \
        movl (PT_ECX+4)(%esp),%edx; \
        movl (PT_EBX+4)(%esp),%eax; \
 -      jmp sys_##name;
 +      jmp sys_##name; \
 +ENDPROC(ptregs_##name)
  
  #define PTREGSCALL3(name) \
 -      ALIGN; \
 -ptregs_##name: \
 +ENTRY(ptregs_##name) ; \
        CFI_STARTPROC; \
        leal 4(%esp),%eax; \
        pushl_cfi %eax; \
@@@ -738,7 -741,8 +738,7 @@@ PTREGSCALL2(vm86
  PTREGSCALL1(vm86old)
  
  /* Clone is an oddball.  The 4th arg is in %edi */
 -      ALIGN;
 -ptregs_clone:
 +ENTRY(ptregs_clone)
        CFI_STARTPROC
        leal 4(%esp),%eax
        pushl_cfi %eax
@@@ -1209,6 -1213,11 +1209,6 @@@ return_to_handler
        jmp *%ecx
  #endif
  
 -.section .rodata,"a"
 -#include "syscall_table_32.S"
 -
 -syscall_table_size=(.-sys_call_table)
 -
  /*
   * Some functions should be protected against kprobes
   */
@@@ -55,6 -55,7 +55,7 @@@
  #include <asm/paravirt.h>
  #include <asm/ftrace.h>
  #include <asm/percpu.h>
+ #include <linux/err.h>
  
  /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this.  */
  #include <linux/elf-em.h>
@@@ -548,7 -549,7 +549,7 @@@ badsys
  #ifdef CONFIG_AUDITSYSCALL
        /*
         * Fast path for syscall audit without full syscall trace.
-        * We just call audit_syscall_entry() directly, and then
+        * We just call __audit_syscall_entry() directly, and then
         * jump back to the normal fast path.
         */
  auditsys:
        movq %rdi,%rdx                  /* 3rd arg: 1st syscall arg */
        movq %rax,%rsi                  /* 2nd arg: syscall number */
        movl $AUDIT_ARCH_X86_64,%edi    /* 1st arg: audit arch */
-       call audit_syscall_entry
+       call __audit_syscall_entry
        LOAD_ARGS 0             /* reload call-clobbered registers */
        jmp system_call_fastpath
  
        /*
-        * Return fast path for syscall audit.  Call audit_syscall_exit()
+        * Return fast path for syscall audit.  Call __audit_syscall_exit()
         * directly and then jump back to the fast path with TIF_SYSCALL_AUDIT
         * masked off.
         */
  sysret_audit:
        movq RAX-ARGOFFSET(%rsp),%rsi   /* second arg, syscall return value */
-       cmpq $0,%rsi            /* is it < 0? */
-       setl %al                /* 1 if so, 0 if not */
+       cmpq $-MAX_ERRNO,%rsi   /* is it < -MAX_ERRNO? */
+       setbe %al               /* 1 if so, 0 if not */
        movzbl %al,%edi         /* zero-extend that into %edi */
-       inc %edi /* first arg, 0->1(AUDITSC_SUCCESS), 1->2(AUDITSC_FAILURE) */
-       call audit_syscall_exit
+       call __audit_syscall_exit
        movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
        jmp sysret_check
  #endif        /* CONFIG_AUDITSYSCALL */
@@@ -1480,214 -1480,62 +1480,214 @@@ ENTRY(error_exit
        CFI_ENDPROC
  END(error_exit)
  
 +/*
 + * Test if a given stack is an NMI stack or not.
 + */
 +      .macro test_in_nmi reg stack nmi_ret normal_ret
 +      cmpq %\reg, \stack
 +      ja \normal_ret
 +      subq $EXCEPTION_STKSZ, %\reg
 +      cmpq %\reg, \stack
 +      jb \normal_ret
 +      jmp \nmi_ret
 +      .endm
  
        /* runs on exception stack */
  ENTRY(nmi)
        INTR_FRAME
        PARAVIRT_ADJUST_EXCEPTION_FRAME
 -      pushq_cfi $-1
 +      /*
 +       * We allow breakpoints in NMIs. If a breakpoint occurs, then
 +       * the iretq it performs will take us out of NMI context.
 +       * This means that we can have nested NMIs where the next
 +       * NMI is using the top of the stack of the previous NMI. We
 +       * can't let it execute because the nested NMI will corrupt the
 +       * stack of the previous NMI. NMI handlers are not re-entrant
 +       * anyway.
 +       *
 +       * To handle this case we do the following:
 +       *  Check the a special location on the stack that contains
 +       *  a variable that is set when NMIs are executing.
 +       *  The interrupted task's stack is also checked to see if it
 +       *  is an NMI stack.
 +       *  If the variable is not set and the stack is not the NMI
 +       *  stack then:
 +       *    o Set the special variable on the stack
 +       *    o Copy the interrupt frame into a "saved" location on the stack
 +       *    o Copy the interrupt frame into a "copy" location on the stack
 +       *    o Continue processing the NMI
 +       *  If the variable is set or the previous stack is the NMI stack:
 +       *    o Modify the "copy" location to jump to the repeate_nmi
 +       *    o return back to the first NMI
 +       *
 +       * Now on exit of the first NMI, we first clear the stack variable
 +       * The NMI stack will tell any nested NMIs at that point that it is
 +       * nested. Then we pop the stack normally with iret, and if there was
 +       * a nested NMI that updated the copy interrupt stack frame, a
 +       * jump will be made to the repeat_nmi code that will handle the second
 +       * NMI.
 +       */
 +
 +      /* Use %rdx as out temp variable throughout */
 +      pushq_cfi %rdx
 +
 +      /*
 +       * Check the special variable on the stack to see if NMIs are
 +       * executing.
 +       */
 +      cmp $1, -8(%rsp)
 +      je nested_nmi
 +
 +      /*
 +       * Now test if the previous stack was an NMI stack.
 +       * We need the double check. We check the NMI stack to satisfy the
 +       * race when the first NMI clears the variable before returning.
 +       * We check the variable because the first NMI could be in a
 +       * breakpoint routine using a breakpoint stack.
 +       */
 +      lea 6*8(%rsp), %rdx
 +      test_in_nmi rdx, 4*8(%rsp), nested_nmi, first_nmi
 +
 +nested_nmi:
 +      /*
 +       * Do nothing if we interrupted the fixup in repeat_nmi.
 +       * It's about to repeat the NMI handler, so we are fine
 +       * with ignoring this one.
 +       */
 +      movq $repeat_nmi, %rdx
 +      cmpq 8(%rsp), %rdx
 +      ja 1f
 +      movq $end_repeat_nmi, %rdx
 +      cmpq 8(%rsp), %rdx
 +      ja nested_nmi_out
 +
 +1:
 +      /* Set up the interrupted NMIs stack to jump to repeat_nmi */
 +      leaq -6*8(%rsp), %rdx
 +      movq %rdx, %rsp
 +      CFI_ADJUST_CFA_OFFSET 6*8
 +      pushq_cfi $__KERNEL_DS
 +      pushq_cfi %rdx
 +      pushfq_cfi
 +      pushq_cfi $__KERNEL_CS
 +      pushq_cfi $repeat_nmi
 +
 +      /* Put stack back */
 +      addq $(11*8), %rsp
 +      CFI_ADJUST_CFA_OFFSET -11*8
 +
 +nested_nmi_out:
 +      popq_cfi %rdx
 +
 +      /* No need to check faults here */
 +      INTERRUPT_RETURN
 +
 +first_nmi:
 +      /*
 +       * Because nested NMIs will use the pushed location that we
 +       * stored in rdx, we must keep that space available.
 +       * Here's what our stack frame will look like:
 +       * +-------------------------+
 +       * | original SS             |
 +       * | original Return RSP     |
 +       * | original RFLAGS         |
 +       * | original CS             |
 +       * | original RIP            |
 +       * +-------------------------+
 +       * | temp storage for rdx    |
 +       * +-------------------------+
 +       * | NMI executing variable  |
 +       * +-------------------------+
 +       * | Saved SS                |
 +       * | Saved Return RSP        |
 +       * | Saved RFLAGS            |
 +       * | Saved CS                |
 +       * | Saved RIP               |
 +       * +-------------------------+
 +       * | copied SS               |
 +       * | copied Return RSP       |
 +       * | copied RFLAGS           |
 +       * | copied CS               |
 +       * | copied RIP              |
 +       * +-------------------------+
 +       * | pt_regs                 |
 +       * +-------------------------+
 +       *
 +       * The saved RIP is used to fix up the copied RIP that a nested
 +       * NMI may zero out. The original stack frame and the temp storage
 +       * is also used by nested NMIs and can not be trusted on exit.
 +       */
 +      /* Set the NMI executing variable on the stack. */
 +      pushq_cfi $1
 +
 +      /* Copy the stack frame to the Saved frame */
 +      .rept 5
 +      pushq_cfi 6*8(%rsp)
 +      .endr
 +
 +      /* Make another copy, this one may be modified by nested NMIs */
 +      .rept 5
 +      pushq_cfi 4*8(%rsp)
 +      .endr
 +
 +      /* Do not pop rdx, nested NMIs will corrupt it */
 +      movq 11*8(%rsp), %rdx
 +
 +      /*
 +       * Everything below this point can be preempted by a nested
 +       * NMI if the first NMI took an exception. Repeated NMIs
 +       * caused by an exception and nested NMI will start here, and
 +       * can still be preempted by another NMI.
 +       */
 +restart_nmi:
 +      pushq_cfi $-1           /* ORIG_RAX: no syscall to restart */
        subq $ORIG_RAX-R15, %rsp
        CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
 +      /*
 +       * Use save_paranoid to handle SWAPGS, but no need to use paranoid_exit
 +       * as we should not be calling schedule in NMI context.
 +       * Even with normal interrupts enabled. An NMI should not be
 +       * setting NEED_RESCHED or anything that normal interrupts and
 +       * exceptions might do.
 +       */
        call save_paranoid
        DEFAULT_FRAME 0
        /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
        movq %rsp,%rdi
        movq $-1,%rsi
        call do_nmi
 -#ifdef CONFIG_TRACE_IRQFLAGS
 -      /* paranoidexit; without TRACE_IRQS_OFF */
 -      /* ebx: no swapgs flag */
 -      DISABLE_INTERRUPTS(CLBR_NONE)
        testl %ebx,%ebx                         /* swapgs needed? */
        jnz nmi_restore
 -      testl $3,CS(%rsp)
 -      jnz nmi_userspace
  nmi_swapgs:
        SWAPGS_UNSAFE_STACK
  nmi_restore:
        RESTORE_ALL 8
 +      /* Clear the NMI executing stack variable */
 +      movq $0, 10*8(%rsp)
        jmp irq_return
 -nmi_userspace:
 -      GET_THREAD_INFO(%rcx)
 -      movl TI_flags(%rcx),%ebx
 -      andl $_TIF_WORK_MASK,%ebx
 -      jz nmi_swapgs
 -      movq %rsp,%rdi                  /* &pt_regs */
 -      call sync_regs
 -      movq %rax,%rsp                  /* switch stack for scheduling */
 -      testl $_TIF_NEED_RESCHED,%ebx
 -      jnz nmi_schedule
 -      movl %ebx,%edx                  /* arg3: thread flags */
 -      ENABLE_INTERRUPTS(CLBR_NONE)
 -      xorl %esi,%esi                  /* arg2: oldset */
 -      movq %rsp,%rdi                  /* arg1: &pt_regs */
 -      call do_notify_resume
 -      DISABLE_INTERRUPTS(CLBR_NONE)
 -      jmp nmi_userspace
 -nmi_schedule:
 -      ENABLE_INTERRUPTS(CLBR_ANY)
 -      call schedule
 -      DISABLE_INTERRUPTS(CLBR_ANY)
 -      jmp nmi_userspace
 -      CFI_ENDPROC
 -#else
 -      jmp paranoid_exit
        CFI_ENDPROC
 -#endif
  END(nmi)
  
 +      /*
 +       * If an NMI hit an iret because of an exception or breakpoint,
 +       * it can lose its NMI context, and a nested NMI may come in.
 +       * In that case, the nested NMI will change the preempted NMI's
 +       * stack to jump to here when it does the final iret.
 +       */
 +repeat_nmi:
 +      INTR_FRAME
 +      /* Update the stack variable to say we are still in NMI */
 +      movq $1, 5*8(%rsp)
 +
 +      /* copy the saved stack back to copy stack */
 +      .rept 5
 +      pushq_cfi 4*8(%rsp)
 +      .endr
 +
 +      jmp restart_nmi
 +      CFI_ENDPROC
 +end_repeat_nmi:
 +
  ENTRY(ignore_sysret)
        CFI_STARTPROC
        mov $-ENOSYS,%eax
diff --combined fs/proc/base.c
@@@ -198,7 -198,65 +198,7 @@@ static int proc_root_link(struct dentr
        return result;
  }
  
 -static struct mm_struct *__check_mem_permission(struct task_struct *task)
 -{
 -      struct mm_struct *mm;
 -
 -      mm = get_task_mm(task);
 -      if (!mm)
 -              return ERR_PTR(-EINVAL);
 -
 -      /*
 -       * A task can always look at itself, in case it chooses
 -       * to use system calls instead of load instructions.
 -       */
 -      if (task == current)
 -              return mm;
 -
 -      /*
 -       * If current is actively ptrace'ing, and would also be
 -       * permitted to freshly attach with ptrace now, permit it.
 -       */
 -      if (task_is_stopped_or_traced(task)) {
 -              int match;
 -              rcu_read_lock();
 -              match = (ptrace_parent(task) == current);
 -              rcu_read_unlock();
 -              if (match && ptrace_may_access(task, PTRACE_MODE_ATTACH))
 -                      return mm;
 -      }
 -
 -      /*
 -       * No one else is allowed.
 -       */
 -      mmput(mm);
 -      return ERR_PTR(-EPERM);
 -}
 -
 -/*
 - * If current may access user memory in @task return a reference to the
 - * corresponding mm, otherwise ERR_PTR.
 - */
 -static struct mm_struct *check_mem_permission(struct task_struct *task)
 -{
 -      struct mm_struct *mm;
 -      int err;
 -
 -      /*
 -       * Avoid racing if task exec's as we might get a new mm but validate
 -       * against old credentials.
 -       */
 -      err = mutex_lock_killable(&task->signal->cred_guard_mutex);
 -      if (err)
 -              return ERR_PTR(err);
 -
 -      mm = __check_mem_permission(task);
 -      mutex_unlock(&task->signal->cred_guard_mutex);
 -
 -      return mm;
 -}
 -
 -struct mm_struct *mm_for_maps(struct task_struct *task)
 +static struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
  {
        struct mm_struct *mm;
        int err;
  
        mm = get_task_mm(task);
        if (mm && mm != current->mm &&
 -                      !ptrace_may_access(task, PTRACE_MODE_READ)) {
 +                      !ptrace_may_access(task, mode)) {
                mmput(mm);
                mm = ERR_PTR(-EACCES);
        }
        return mm;
  }
  
 +struct mm_struct *mm_for_maps(struct task_struct *task)
 +{
 +      return mm_access(task, PTRACE_MODE_READ);
 +}
 +
  static int proc_pid_cmdline(struct task_struct *task, char * buffer)
  {
        int res = 0;
@@@ -601,8 -654,6 +601,8 @@@ static int proc_pid_permission(struct i
        bool has_perms;
  
        task = get_proc_task(inode);
 +      if (!task)
 +              return -ESRCH;
        has_perms = has_pid_permissions(pid, task, 1);
        put_task_struct(task);
  
@@@ -699,39 -750,38 +699,39 @@@ static const struct file_operations pro
  
  static int mem_open(struct inode* inode, struct file* file)
  {
 -      file->private_data = (void*)((long)current->self_exec_id);
 +      struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
 +      struct mm_struct *mm;
 +
 +      if (!task)
 +              return -ESRCH;
 +
 +      mm = mm_access(task, PTRACE_MODE_ATTACH);
 +      put_task_struct(task);
 +
 +      if (IS_ERR(mm))
 +              return PTR_ERR(mm);
 +
        /* OK to pass negative loff_t, we can catch out-of-range */
        file->f_mode |= FMODE_UNSIGNED_OFFSET;
 +      file->private_data = mm;
 +
        return 0;
  }
  
  static ssize_t mem_read(struct file * file, char __user * buf,
                        size_t count, loff_t *ppos)
  {
 -      struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
 +      int ret;
        char *page;
        unsigned long src = *ppos;
 -      int ret = -ESRCH;
 -      struct mm_struct *mm;
 +      struct mm_struct *mm = file->private_data;
  
 -      if (!task)
 -              goto out_no_task;
 +      if (!mm)
 +              return 0;
  
 -      ret = -ENOMEM;
        page = (char *)__get_free_page(GFP_TEMPORARY);
        if (!page)
 -              goto out;
 -
 -      mm = check_mem_permission(task);
 -      ret = PTR_ERR(mm);
 -      if (IS_ERR(mm))
 -              goto out_free;
 -
 -      ret = -EIO;
 - 
 -      if (file->private_data != (void*)((long)current->self_exec_id))
 -              goto out_put;
 +              return -ENOMEM;
  
        ret = 0;
   
        }
        *ppos = src;
  
 -out_put:
 -      mmput(mm);
 -out_free:
        free_page((unsigned long) page);
 -out:
 -      put_task_struct(task);
 -out_no_task:
        return ret;
  }
  
@@@ -767,15 -823,27 +767,15 @@@ static ssize_t mem_write(struct file * 
  {
        int copied;
        char *page;
 -      struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
        unsigned long dst = *ppos;
 -      struct mm_struct *mm;
 +      struct mm_struct *mm = file->private_data;
  
 -      copied = -ESRCH;
 -      if (!task)
 -              goto out_no_task;
 +      if (!mm)
 +              return 0;
  
 -      copied = -ENOMEM;
        page = (char *)__get_free_page(GFP_TEMPORARY);
        if (!page)
 -              goto out_task;
 -
 -      mm = check_mem_permission(task);
 -      copied = PTR_ERR(mm);
 -      if (IS_ERR(mm))
 -              goto out_free;
 -
 -      copied = -EIO;
 -      if (file->private_data != (void *)((long)current->self_exec_id))
 -              goto out_mm;
 +              return -ENOMEM;
  
        copied = 0;
        while (count > 0) {
        }
        *ppos = dst;
  
 -out_mm:
 -      mmput(mm);
 -out_free:
        free_page((unsigned long) page);
 -out_task:
 -      put_task_struct(task);
 -out_no_task:
        return copied;
  }
  
@@@ -819,20 -893,11 +819,20 @@@ loff_t mem_lseek(struct file *file, lof
        return file->f_pos;
  }
  
 +static int mem_release(struct inode *inode, struct file *file)
 +{
 +      struct mm_struct *mm = file->private_data;
 +
 +      mmput(mm);
 +      return 0;
 +}
 +
  static const struct file_operations proc_mem_operations = {
        .llseek         = mem_lseek,
        .read           = mem_read,
        .write          = mem_write,
        .open           = mem_open,
 +      .release        = mem_release,
  };
  
  static ssize_t environ_read(struct file *file, char __user *buf,
@@@ -1132,9 -1197,6 +1132,6 @@@ static ssize_t proc_loginuid_write(stru
        ssize_t length;
        uid_t loginuid;
  
-       if (!capable(CAP_AUDIT_CONTROL))
-               return -EPERM;
        rcu_read_lock();
        if (current != pid_task(proc_pid(inode), PIDTYPE_PID)) {
                rcu_read_unlock();
                goto out_free_page;
  
        }
-       length = audit_set_loginuid(current, loginuid);
+       length = audit_set_loginuid(loginuid);
        if (likely(length == 0))
                length = count;
  
diff --combined include/linux/ptrace.h
  
  #include <linux/compiler.h>           /* For unlikely.  */
  #include <linux/sched.h>              /* For struct task_struct.  */
+ #include <linux/err.h>                        /* for IS_ERR_VALUE */
  
  
  extern long arch_ptrace(struct task_struct *child, long request,
@@@ -127,9 -128,8 +128,9 @@@ extern void __ptrace_link(struct task_s
                          struct task_struct *new_parent);
  extern void __ptrace_unlink(struct task_struct *child);
  extern void exit_ptrace(struct task_struct *tracer);
 -#define PTRACE_MODE_READ   1
 -#define PTRACE_MODE_ATTACH 2
 +#define PTRACE_MODE_READ      0x01
 +#define PTRACE_MODE_ATTACH    0x02
 +#define PTRACE_MODE_NOAUDIT   0x04
  /* Returns 0 on success, -errno on denial. */
  extern int __ptrace_may_access(struct task_struct *task, unsigned int mode);
  /* Returns true on success, false on denial. */
@@@ -266,6 -266,15 +267,15 @@@ static inline void ptrace_release_task(
  #define force_successful_syscall_return() do { } while (0)
  #endif
  
+ #ifndef is_syscall_success
+ /*
+  * On most systems we can tell if a syscall is a success based on if the retval
+  * is an error value.  On some systems like ia64 and powerpc they have different
+  * indicators of success/failure and must define their own.
+  */
+ #define is_syscall_success(regs) (!IS_ERR_VALUE((unsigned long)(regs_return_value(regs))))
+ #endif
  /*
   * <asm/ptrace.h> should define the following things inside #ifdef __KERNEL__.
   *
diff --combined init/Kconfig
@@@ -355,7 -355,7 +355,7 @@@ config AUDI
  
  config AUDITSYSCALL
        bool "Enable system-call auditing support"
-       depends on AUDIT && (X86 || PPC || S390 || IA64 || UML || SPARC64 || SUPERH)
+       depends on AUDIT && (X86 || PPC || S390 || IA64 || UML || SPARC64 || SUPERH || ARM)
        default y if SECURITY_SELINUX
        help
          Enable low-overhead system-call auditing infrastructure that
@@@ -372,6 -372,20 +372,20 @@@ config AUDIT_TRE
        depends on AUDITSYSCALL
        select FSNOTIFY
  
 -        The config option toggles if a task setting it's loginuid requires
+ config AUDIT_LOGINUID_IMMUTABLE
+       bool "Make audit loginuid immutable"
+       depends on AUDIT
+       help
++        The config option toggles if a task setting its loginuid requires
+         CAP_SYS_AUDITCONTROL or if that task should require no special permissions
+         but should instead only allow setting its loginuid if it was never
+         previously set.  On systems which use systemd or a similar central
+         process to restart login services this should be set to true.  On older
+         systems in which an admin would typically have to directly stop and
+         start processes this should be set to false.  Setting this to true allows
+         one to drop potentially dangerous capabilites from the login tasks,
+         but may not be backwards compatible with older init systems.
  source "kernel/irq/Kconfig"
  
  menu "RCU Subsystem"
@@@ -713,6 -727,7 +727,6 @@@ config CGROUP_PER
  
  menuconfig CGROUP_SCHED
        bool "Group CPU scheduler"
 -      depends on EXPERIMENTAL
        default n
        help
          This feature lets CPU scheduler recognize task groups and control CPU
@@@ -783,17 -798,6 +797,17 @@@ config DEBUG_BLK_CGROU
  
  endif # CGROUPS
  
 +config CHECKPOINT_RESTORE
 +      bool "Checkpoint/restore support" if EXPERT
 +      default n
 +      help
 +        Enables additional kernel features in a sake of checkpoint/restore.
 +        In particular it adds auxiliary prctl codes to setup process text,
 +        data and heap segment sizes, and a few additional /proc filesystem
 +        entries.
 +
 +        If unsure, say N here.
 +
  menuconfig NAMESPACES
        bool "Namespaces support" if EXPERT
        default !EXPERT
diff --combined kernel/audit.c
@@@ -601,13 -601,13 +601,13 @@@ static int audit_netlink_ok(struct sk_b
        case AUDIT_TTY_SET:
        case AUDIT_TRIM:
        case AUDIT_MAKE_EQUIV:
 -              if (security_netlink_recv(skb, CAP_AUDIT_CONTROL))
 +              if (!capable(CAP_AUDIT_CONTROL))
                        err = -EPERM;
                break;
        case AUDIT_USER:
        case AUDIT_FIRST_USER_MSG ... AUDIT_LAST_USER_MSG:
        case AUDIT_FIRST_USER_MSG2 ... AUDIT_LAST_USER_MSG2:
 -              if (security_netlink_recv(skb, CAP_AUDIT_WRITE))
 +              if (!capable(CAP_AUDIT_WRITE))
                        err = -EPERM;
                break;
        default:  /* bad msg */
@@@ -631,7 -631,7 +631,7 @@@ static int audit_log_common_recv_msg(st
        }
  
        *ab = audit_log_start(NULL, GFP_KERNEL, msg_type);
-       audit_log_format(*ab, "user pid=%d uid=%u auid=%u ses=%u",
+       audit_log_format(*ab, "pid=%d uid=%u auid=%u ses=%u",
                         pid, uid, auid, ses);
        if (sid) {
                rc = security_secid_to_secctx(sid, &ctx, &len);
@@@ -1423,7 -1423,7 +1423,7 @@@ void audit_log_d_path(struct audit_buff
        char *p, *pathname;
  
        if (prefix)
-               audit_log_format(ab, " %s", prefix);
+               audit_log_format(ab, "%s", prefix);
  
        /* We will allow 11 spaces for ' (deleted)' to be appended */
        pathname = kmalloc(PATH_MAX+11, ab->gfp_mask);
diff --combined kernel/exit.c
@@@ -887,7 -887,7 +887,7 @@@ static void check_stack_usage(void
  static inline void check_stack_usage(void) {}
  #endif
  
 -NORET_TYPE void do_exit(long code)
 +void do_exit(long code)
  {
        struct task_struct *tsk = current;
        int group_dead;
        acct_collect(code, group_dead);
        if (group_dead)
                tty_audit_exit();
-       if (unlikely(tsk->audit_context))
-               audit_free(tsk);
+       audit_free(tsk);
  
        tsk->exit_code = code;
        taskstats_exit(tsk, group_dead);
  
  EXPORT_SYMBOL_GPL(do_exit);
  
 -NORET_TYPE void complete_and_exit(struct completion *comp, long code)
 +void complete_and_exit(struct completion *comp, long code)
  {
        if (comp)
                complete(comp);
@@@ -1070,7 -1069,7 +1069,7 @@@ SYSCALL_DEFINE1(exit, int, error_code
   * Take down every thread in the group.  This is called by fatal signals
   * as well as by sys_exit_group (below).
   */
 -NORET_TYPE void
 +void
  do_group_exit(int exit_code)
  {
        struct signal_struct *sig = current->signal;
diff --combined kernel/fork.c
@@@ -873,7 -873,6 +873,7 @@@ static int copy_io(unsigned long clone_
  {
  #ifdef CONFIG_BLOCK
        struct io_context *ioc = current->io_context;
 +      struct io_context *new_ioc;
  
        if (!ioc)
                return 0;
                if (unlikely(!tsk->io_context))
                        return -ENOMEM;
        } else if (ioprio_valid(ioc->ioprio)) {
 -              tsk->io_context = alloc_io_context(GFP_KERNEL, -1);
 -              if (unlikely(!tsk->io_context))
 +              new_ioc = get_task_io_context(tsk, GFP_KERNEL, NUMA_NO_NODE);
 +              if (unlikely(!new_ioc))
                        return -ENOMEM;
  
 -              tsk->io_context->ioprio = ioc->ioprio;
 +              new_ioc->ioprio = ioc->ioprio;
 +              put_io_context(new_ioc, NULL);
        }
  #endif
        return 0;
@@@ -1527,8 -1525,6 +1527,6 @@@ long do_fork(unsigned long clone_flags
                        init_completion(&vfork);
                }
  
-               audit_finish_fork(p);
                /*
                 * We set PF_STARTING at creation in case tracing wants to
                 * use this to distinguish a fully live task from one that