1. 22 Jul, 2013 22 commits
  2. 13 Jul, 2013 12 commits
  3. 03 Jul, 2013 6 commits
    • Greg Kroah-Hartman's avatar
      Linux 3.4.52 · ad7d5b07
      Greg Kroah-Hartman authored
      ad7d5b07
    • Peter Zijlstra's avatar
      perf: Fix mmap() accounting hole · 703197b6
      Peter Zijlstra authored
      commit 9bb5d40c upstream.
      
      Vince's fuzzer once again found holes. This time it spotted a leak in
      the locked page accounting.
      
      When an event had redirected output and its close() was the last
      reference to the buffer we didn't have a vm context to undo accounting.
      
      Change the code to destroy the buffer on the last munmap() and detach
      all redirected events at that time. This provides us the right context
      to undo the vm accounting.
      
      [Backporting for 3.4-stable.
      VM_RESERVED flag was replaced with pair 'VM_DONTEXPAND | VM_DONTDUMP' in
      314e51b9 since 3.7.0-rc1, and 314e51b9 comes from a big patchset, we didn't
      backport the patchset, so I restored 'VM_DNOTEXPAND | VM_DONTDUMP' as before:
      -	vma->vm_flags |= VM_DONTCOPY | VM_DONTEXPAND | VM_DONTDUMP;
      +	vma->vm_flags |= VM_DONTCOPY | VM_RESERVED;
       -- zliu]
      Reported-and-tested-by: default avatarVince Weaver <vincent.weaver@maine.edu>
      Signed-off-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20130604084421.GI8923@twins.programming.kicks-ass.net
      Cc: <stable@kernel.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarZhouping Liu <zliu@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      703197b6
    • Peter Zijlstra's avatar
      perf: Fix perf mmap bugs · 535fad87
      Peter Zijlstra authored
      commit 26cb63ad upstream.
      
      Vince reported a problem found by his perf specific trinity
      fuzzer.
      
      Al noticed 2 problems with perf's mmap():
      
       - it has issues against fork() since we use vma->vm_mm for accounting.
       - it has an rb refcount leak on double mmap().
      
      We fix the issues against fork() by using VM_DONTCOPY; I don't
      think there's code out there that uses this; we didn't hear
      about weird accounting problems/crashes. If we do need this to
      work, the previously proposed VM_PINNED could make this work.
      
      Aside from the rb reference leak spotted by Al, Vince's example
      prog was indeed doing a double mmap() through the use of
      perf_event_set_output().
      
      This exposes another problem, since we now have 2 events with
      one buffer, the accounting gets screwy because we account per
      event. Fix this by making the buffer responsible for its own
      accounting.
      
      [Backporting for 3.4-stable.
      VM_RESERVED flag was replaced with pair 'VM_DONTEXPAND | VM_DONTDUMP' in
      314e51b9 since 3.7.0-rc1, and 314e51b9 comes from a big patchset, we didn't
      backport the patchset, so I restored 'VM_DNOTEXPAND | VM_DONTDUMP' as before:
      -       vma->vm_flags |= VM_DONTCOPY | VM_DONTEXPAND | VM_DONTDUMP;
      +       vma->vm_flags |= VM_DONTCOPY | VM_RESERVED;
       -- zliu]
      Reported-by: default avatarVince Weaver <vincent.weaver@maine.edu>
      Signed-off-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
      Link: http://lkml.kernel.org/r/20130528085548.GA12193@twins.programming.kicks-ass.netSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarZhouping Liu <zliu@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      535fad87
    • Liang Li's avatar
      pch_uart: fix a deadlock when pch_uart as console · 5d2a2c71
      Liang Li authored
      commit 384e301e upstream.
      
      When we use pch_uart as system console like 'console=ttyPCH0,115200',
      then 'send break' to it. We'll encounter the deadlock on a cpu/core,
      with interrupts disabled on the core. When we happen to have all irqs
      affinity to cpu0 then the deadlock on cpu0 actually deadlock whole
      system.
      
      In pch_uart_interrupt, we have spin_lock_irqsave(&priv->lock, flags)
      then call pch_uart_err_ir when break is received. Then the call to
      dev_err would actually call to pch_console_write then we'll run into
      another spin_lock(&priv->lock), with interrupts disabled.
      
      So in the call sequence lead by pch_uart_interrupt, we should be
      carefully to call functions that will 'print message to console' only
      in case the uart port is not being used as serial console.
      Signed-off-by: default avatarLiang Li <liang.li@windriver.com>
      Cc: Yijing Wang <wangyijing@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5d2a2c71
    • Artem Bityutskiy's avatar
      UBIFS: fix a horrid bug · 4e3010bf
      Artem Bityutskiy authored
      commit 605c912b upstream.
      
      Al Viro pointed me to the fact that '->readdir()' and '->llseek()' have no
      mutual exclusion, which means the 'ubifs_dir_llseek()' can be run while we are
      in the middle of 'ubifs_readdir()'.
      
      This means that 'file->private_data' can be freed while 'ubifs_readdir()' uses
      it, and this is a very bad bug: not only 'ubifs_readdir()' can return garbage,
      but this may corrupt memory and lead to all kinds of problems like crashes an
      security holes.
      
      This patch fixes the problem by using the 'file->f_version' field, which
      '->llseek()' always unconditionally sets to zero. We set it to 1 in
      'ubifs_readdir()' and whenever we detect that it became 0, we know there was a
      seek and it is time to clear the state saved in 'file->private_data'.
      
      I tested this patch by writing a user-space program which runds readdir and
      seek in parallell. I could easily crash the kernel without these patches, but
      could not crash it with these patches.
      Reported-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
      Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4e3010bf
    • Artem Bityutskiy's avatar
      UBIFS: prepare to fix a horrid bug · eafde0bc
      Artem Bityutskiy authored
      commit 33f1a63a upstream.
      
      Al Viro pointed me to the fact that '->readdir()' and '->llseek()' have no
      mutual exclusion, which means the 'ubifs_dir_llseek()' can be run while we are
      in the middle of 'ubifs_readdir()'.
      
      First of all, this means that 'file->private_data' can be freed while
      'ubifs_readdir()' uses it.  But this particular patch does not fix the problem.
      This patch is only a preparation, and the fix will follow next.
      
      In this patch we make 'ubifs_readdir()' stop using 'file->f_pos' directly,
      because 'file->f_pos' can be changed by '->llseek()' at any point. This may
      lead 'ubifs_readdir()' to returning inconsistent data: directory entry names
      may correspond to incorrect file positions.
      
      So here we introduce a local variable 'pos', read 'file->f_pose' once at very
      the beginning, and then stick to 'pos'. The result of this is that when
      'ubifs_dir_llseek()' changes 'file->f_pos' while we are in the middle of
      'ubifs_readdir()', the latter "wins".
      Reported-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Tested-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
      Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      eafde0bc