1. 14 Apr, 2014 8 commits
    • Mathias Krause's avatar
      ipc, msg: fix message length check for negative values · 5a27d698
      Mathias Krause authored
      commit 4e9b45a1 upstream.
      
      On 64 bit systems the test for negative message sizes is bogus as the
      size, which may be positive when evaluated as a long, will get truncated
      to an int when passed to load_msg().  So a long might very well contain a
      positive value but when truncated to an int it would become negative.
      
      That in combination with a small negative value of msg_ctlmax (which will
      be promoted to an unsigned type for the comparison against msgsz, making
      it a big positive value and therefore make it pass the check) will lead to
      two problems: 1/ The kmalloc() call in alloc_msg() will allocate a too
      small buffer as the addition of alen is effectively a subtraction.  2/ The
      copy_from_user() call in load_msg() will first overflow the buffer with
      userland data and then, when the userland access generates an access
      violation, the fixup handler copy_user_handle_tail() will try to fill the
      remainder with zeros -- roughly 4GB.  That almost instantly results in a
      system crash or reset.
      
        ,-[ Reproducer (needs to be run as root) ]--
        | #include <sys/stat.h>
        | #include <sys/msg.h>
        | #include <unistd.h>
        | #include <fcntl.h>
        |
        | int main(void) {
        |     long msg = 1;
        |     int fd;
        |
        |     fd = open("/proc/sys/kernel/msgmax", O_WRONLY);
        |     write(fd, "-1", 2);
        |     close(fd);
        |
        |     msgsnd(0, &msg, 0xfffffff0, IPC_NOWAIT);
        |
        |     return 0;
        | }
        '---
      
      Fix the issue by preventing msgsz from getting truncated by consistently
      using size_t for the message length.  This way the size checks in
      do_msgsnd() could still be passed with a negative value for msg_ctlmax but
      we would fail on the buffer allocation in that case and error out.
      
      Also change the type of m_ts from int to size_t to avoid similar nastiness
      in other code paths -- it is used in similar constructs, i.e.  signed vs.
      unsigned checks.  It should never become negative under normal
      circumstances, though.
      
      Setting msg_ctlmax to a negative value is an odd configuration and should
      be prevented.  As that might break existing userland, it will be handled
      in a separate commit so it could easily be reverted and reworked without
      reintroducing the above described bug.
      
      Hardening mechanisms for user copy operations would have catched that bug
      early -- e.g.  checking slab object sizes on user copy operations as the
      usercopy feature of the PaX patch does.  Or, for that matter, detect the
      long vs.  int sign change due to truncation, as the size overflow plugin
      of the very same patch does.
      
      [akpm@linux-foundation.org: fix i386 min() warnings]
      Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
      Cc: Pax Team <pageexec@freemail.hu>
      Cc: Davidlohr Bueso <davidlohr@hp.com>
      Cc: Brad Spengler <spender@grsecurity.net>
      Cc: Manfred Spraul <manfred@colorfullife.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      [bwh: Backported to 3.2:
       - Adjust context
       - Drop changes to alloc_msg() and copy_msg(), which don't exist]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Cc: Qiang Huang <h.huangqiang@huawei.com>
      Cc: Li Zefan <lizefan@huawei.com>
      Cc: Jianguo Wu <wujianguo@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5a27d698
    • Ingo Molnar's avatar
      compiler/gcc4: Add quirk for 'asm goto' miscompilation bug · d1915751
      Ingo Molnar authored
      commit 3f0116c3 upstream.
      
      Fengguang Wu, Oleg Nesterov and Peter Zijlstra tracked down
      a kernel crash to a GCC bug: GCC miscompiles certain 'asm goto'
      constructs, as outlined here:
      
        http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
      
      Implement a workaround suggested by Jakub Jelinek.
      Reported-and-tested-by: default avatarFengguang Wu <fengguang.wu@intel.com>
      Reported-by: default avatarOleg Nesterov <oleg@redhat.com>
      Reported-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
      Suggested-by: default avatarJakub Jelinek <jakub@redhat.com>
      Reviewed-by: default avatarRichard Henderson <rth@twiddle.net>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      [hq: Backported to 3.4: Adjust context]
      Signed-off-by: default avatarQiang Huang <h.huangqiang@huawei.com>
      Cc: Li Zefan <lizefan@huawei.com>
      Cc: Jianguo Wu <wujianguo@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d1915751
    • Daniel Santos's avatar
      compiler-gcc.h: Add gcc-recommended GCC_VERSION macro · 460207ad
      Daniel Santos authored
      commit 3f3f8d2f upstream.
      
      Throughout compiler*.h, many version checks are made.  These can be
      simplified by using the macro that gcc's documentation recommends.
      However, my primary reason for adding this is that I need bug-check
      macros that are enabled at certain gcc versions and it's cleaner to use
      this macro than the tradition method:
      
        #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ => 2)
      
      If you add patch level, it gets this ugly:
      
        #if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 2 || \
            __GNUC_MINOR__ == 2 __GNUC_PATCHLEVEL__ >= 1))
      
      As opposed to:
      
        #if GCC_VERSION >= 40201
      
      While having separate headers for gcc 3 & 4 eliminates some of this
      verbosity, they can still be cleaned up by this.
      
      See also:
      
        http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.htmlSigned-off-by: default avatarDaniel Santos <daniel.santos@pobox.com>
      Acked-by: default avatarBorislav Petkov <bp@alien8.de>
      Acked-by: default avatarDavid Rientjes <rientjes@google.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Josh Triplett <josh@joshtriplett.org>
      Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Cc: Qiang Huang <h.huangqiang@huawei.com>
      Cc: Li Zefan <lizefan@huawei.com>
      Cc: Jianguo Wu <wujianguo@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      460207ad
    • Tejun Heo's avatar
      workqueue: cond_resched() after processing each work item · 00cef7a5
      Tejun Heo authored
      commit b22ce278 upstream.
      
      If !PREEMPT, a kworker running work items back to back can hog CPU.
      This becomes dangerous when a self-requeueing work item which is
      waiting for something to happen races against stop_machine.  Such
      self-requeueing work item would requeue itself indefinitely hogging
      the kworker and CPU it's running on while stop_machine would wait for
      that CPU to enter stop_machine while preventing anything else from
      happening on all other CPUs.  The two would deadlock.
      
      Jamie Liu reports that this deadlock scenario exists around
      scsi_requeue_run_queue() and libata port multiplier support, where one
      port may exclude command processing from other ports.  With the right
      timing, scsi_requeue_run_queue() can end up requeueing itself trying
      to execute an IO which is asked to be retried while another device has
      an exclusive access, which in turn can't make forward progress due to
      stop_machine.
      
      Fix it by invoking cond_resched() after executing each work item.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reported-by: default avatarJamie Liu <jamieliu@google.com>
      References: http://thread.gmane.org/gmane.linux.kernel/1552567
      [bwh: Backported to 3.2: adjust context]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Cc: Qiang Huang <h.huangqiang@huawei.com>
      Cc: Li Zefan <lizefan@huawei.com>
      Cc: Jianguo Wu <wujianguo@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      00cef7a5
    • Bu, Yitian's avatar
      printk: Fix rq->lock vs logbuf_lock unlock lock inversion · aa34e62c
      Bu, Yitian authored
      commit dbda92d1 upstream.
      
      commit 07354eb1 ("locking printk: Annotate logbuf_lock as raw")
      reintroduced a lock inversion problem which was fixed in commit
      0b5e1c52 ("printk: Release console_sem after logbuf_lock"). This
      happened probably when fixing up patch rejects.
      
      Restore the ordering and unlock logbuf_lock before releasing
      console_sem.
      Signed-off-by: default avatarybu <ybu@qti.qualcomm.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/E807E903FE6CBE4D95E420FBFCC273B827413C@nasanexd01h.na.qualcomm.comSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      [bwh: Backported to 3.2: adjust context]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Cc: Qiang Huang <h.huangqiang@huawei.com>
      Cc: Li Zefan <lizefan@huawei.com>
      Cc: Jianguo Wu <wujianguo@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      aa34e62c
    • Oleg Nesterov's avatar
      audit: wait_for_auditd() should use TASK_UNINTERRUPTIBLE · 0df19efa
      Oleg Nesterov authored
      commit f000cfdd upstream.
      
      audit_log_start() does wait_for_auditd() in a loop until
      audit_backlog_wait_time passes or audit_skb_queue has a room.
      
      If signal_pending() is true this becomes a busy-wait loop, schedule() in
      TASK_INTERRUPTIBLE won't block.
      
      Thanks to Guy for fully investigating and explaining the problem.
      
      (akpm: that'll cause the system to lock up on a non-preemptible
      uniprocessor kernel)
      
      (Guy: "Our customer was in fact running a uniprocessor machine, and they
      reported a system hang.")
      Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
      Reported-by: default avatarGuy Streeter <streeter@redhat.com>
      Cc: Eric Paris <eparis@redhat.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      [bwh: Backported to 3.2: adjust context, indentation]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Cc: Qiang Huang <h.huangqiang@huawei.com>
      Cc: Li Zefan <lizefan@huawei.com>
      Cc: Jianguo Wu <wujianguo@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0df19efa
    • Tejun Heo's avatar
      idr: fix top layer handling · c45821f7
      Tejun Heo authored
      commit 326cf0f0 upstream.
      
      Most functions in idr fail to deal with the high bits when the idr
      tree grows to the maximum height.
      
      * idr_get_empty_slot() stops growing idr tree once the depth reaches
        MAX_IDR_LEVEL - 1, which is one depth shallower than necessary to
        cover the whole range.  The function doesn't even notice that it
        didn't grow the tree enough and ends up allocating the wrong ID
        given sufficiently high @starting_id.
      
        For example, on 64 bit, if the starting id is 0x7fffff01,
        idr_get_empty_slot() will grow the tree 5 layer deep, which only
        covers the 30 bits and then proceed to allocate as if the bit 30
        wasn't specified.  It ends up allocating 0x3fffff01 without the bit
        30 but still returns 0x7fffff01.
      
      * __idr_remove_all() will not remove anything if the tree is fully
        grown.
      
      * idr_find() can't find anything if the tree is fully grown.
      
      * idr_for_each() and idr_get_next() can't iterate anything if the tree
        is fully grown.
      
      Fix it by introducing idr_max() which returns the maximum possible ID
      given the depth of tree and replacing the id limit checks in all
      affected places.
      
      As the idr_layer pointer array pa[] needs to be 1 larger than the
      maximum depth, enlarge pa[] arrays by one.
      
      While this plugs the discovered issues, the whole code base is
      horrible and in desparate need of rewrite.  It's fragile like hell,
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      [bwh: Backported to 3.2:
       - Adjust context
       - s/MAX_IDR_LEVEL/MAX_LEVEL/; s/MAX_IDR_SHIFT/MAX_ID_SHIFT/
       - Drop change to idr_alloc()]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Cc: Qiang Huang <h.huangqiang@huawei.com>
      Cc: Li Zefan <lizefan@huawei.com>
      Cc: Jianguo Wu <wujianguo@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      
      c45821f7
    • Artem Bityutskiy's avatar
      proc: pid/status: show all supplementary groups · 4ca2cf4a
      Artem Bityutskiy authored
      commit 8d238027 upstream.
      
      We display a list of supplementary group for each process in
      /proc/<pid>/status.  However, we show only the first 32 groups, not all of
      them.
      
      Although this is rare, but sometimes processes do have more than 32
      supplementary groups, and this kernel limitation breaks user-space apps
      that rely on the group list in /proc/<pid>/status.
      
      Number 32 comes from the internal NGROUPS_SMALL macro which defines the
      length for the internal kernel "small" groups buffer.  There is no
      apparent reason to limit to this value.
      
      This patch removes the 32 groups printing limit.
      
      The Linux kernel limits the amount of supplementary groups by NGROUPS_MAX,
      which is currently set to 65536.  And this is the maximum count of groups
      we may possibly print.
      Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
      Acked-by: default avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      [bwh: Backported to 3.2: adjust context]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Cc: Qiang Huang <h.huangqiang@huawei.com>
      Cc: Li Zefan <lizefan@huawei.com>
      Cc: Jianguo Wu <wujianguo@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4ca2cf4a
  2. 03 Apr, 2014 7 commits
  3. 31 Mar, 2014 14 commits
  4. 24 Mar, 2014 11 commits
    • Greg Kroah-Hartman's avatar
      Linux 3.4.84 · b1cee752
      Greg Kroah-Hartman authored
      b1cee752
    • Paul E. McKenney's avatar
      jiffies: Avoid undefined behavior from signed overflow · 7c0a02e9
      Paul E. McKenney authored
      commit 5a581b36 upstream.
      
      According to the C standard 3.4.3p3, overflow of a signed integer results
      in undefined behavior.  This commit therefore changes the definitions
      of time_after(), time_after_eq(), time_after64(), and time_after_eq64()
      to avoid this undefined behavior.  The trick is that the subtraction
      is done using unsigned arithmetic, which according to 6.2.5p9 cannot
      overflow because it is defined as modulo arithmetic.  This has the added
      (though admittedly quite small) benefit of shortening four lines of code
      by four characters each.
      
      Note that the C standard considers the cast from unsigned to
      signed to be implementation-defined, see 6.3.1.3p3.  However, on a
      two's-complement system, an implementation that defines anything other
      than a reinterpretation of the bits is free to come to me, and I will be
      happy to act as a witness for its being committed to an insane asylum.
      (Although I have nothing against saturating arithmetic or signals in some
      cases, these things really should not be the default when compiling an
      operating-system kernel.)
      Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: John Stultz <john.stultz@linaro.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Eric Dumazet <eric.dumazet@gmail.com>
      Cc: Kevin Easton <kevin@guarana.org>
      [ paulmck: Included time_after64() and time_after_eq64(), as suggested
        by Eric Dumazet, also fixed commit message.]
      Reviewed-by: default avatarJosh Triplett <josh@joshtriplett.org>
      Ruchi Kandoi <kandoiruchi@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7c0a02e9
    • Roman Volkov's avatar
      ALSA: oxygen: modify adjust_dg_dac_routing function · 212b4654
      Roman Volkov authored
      commit 1f91ecc1 upstream.
      
      When selecting the audio output destinations (headphones,
      FP headphones, multichannel output), the channel routing
      should be changed depending on what destination selected.
      Also unnecessary I2S channels are digitally muted. This
      function called when the user selects the destination
      in the ALSA mixer.
      Signed-off-by: default avatarRoman Volkov <v1ron@mail.ru>
      Signed-off-by: default avatarClemens Ladisch <clemens@ladisch.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      
      212b4654
    • Filipe David Borba Manana's avatar
      Btrfs: fix data corruption when reading/updating compressed extents · dba79490
      Filipe David Borba Manana authored
      commit a2aa75e1 upstream.
      
      When using a mix of compressed file extents and prealloc extents, it
      is possible to fill a page of a file with random, garbage data from
      some unrelated previous use of the page, instead of a sequence of zeroes.
      
      A simple sequence of steps to get into such case, taken from the test
      case I made for xfstests, is:
      
         _scratch_mkfs
         _scratch_mount "-o compress-force=lzo"
         $XFS_IO_PROG -f -c "pwrite -S 0x06 -b 18670 266978 18670" $SCRATCH_MNT/foobar
         $XFS_IO_PROG -c "falloc 26450 665194" $SCRATCH_MNT/foobar
         $XFS_IO_PROG -c "truncate 542872" $SCRATCH_MNT/foobar
         $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foobar
      
      This results in the following file items in the fs tree:
      
         item 4 key (257 INODE_ITEM 0) itemoff 15879 itemsize 160
             inode generation 6 transid 6 size 542872 block group 0 mode 100600
         item 5 key (257 INODE_REF 256) itemoff 15863 itemsize 16
             inode ref index 2 namelen 6 name: foobar
         item 6 key (257 EXTENT_DATA 0) itemoff 15810 itemsize 53
             extent data disk byte 0 nr 0 gen 6
             extent data offset 0 nr 24576 ram 266240
             extent compression 0
         item 7 key (257 EXTENT_DATA 24576) itemoff 15757 itemsize 53
             prealloc data disk byte 12849152 nr 241664 gen 6
             prealloc data offset 0 nr 241664
         item 8 key (257 EXTENT_DATA 266240) itemoff 15704 itemsize 53
             extent data disk byte 12845056 nr 4096 gen 6
             extent data offset 0 nr 20480 ram 20480
             extent compression 2
         item 9 key (257 EXTENT_DATA 286720) itemoff 15651 itemsize 53
             prealloc data disk byte 13090816 nr 405504 gen 6
             prealloc data offset 0 nr 258048
      
      The on disk extent at offset 266240 (which corresponds to 1 single disk block),
      contains 5 compressed chunks of file data. Each of the first 4 compress 4096
      bytes of file data, while the last one only compresses 3024 bytes of file data.
      Therefore a read into the file region [285648 ; 286720[ (length = 4096 - 3024 =
      1072 bytes) should always return zeroes (our next extent is a prealloc one).
      
      The solution here is the compression code path to zero the remaining (untouched)
      bytes of the last page it uncompressed data into, as the information about how
      much space the file data consumes in the last page is not known in the upper layer
      fs/btrfs/extent_io.c:__do_readpage(). In __do_readpage we were correctly zeroing
      the remainder of the page but only if it corresponds to the last page of the inode
      and if the inode's size is not a multiple of the page size.
      
      This would cause not only returning random data on reads, but also permanently
      storing random data when updating parts of the region that should be zeroed.
      For the example above, it means updating a single byte in the region [285648 ; 286720[
      would store that byte correctly but also store random data on disk.
      
      A test case for xfstests follows soon.
      Signed-off-by: default avatarFilipe David Borba Manana <fdmanana@gmail.com>
      Signed-off-by: default avatarChris Mason <clm@fb.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dba79490
    • Ales Novak's avatar
      SCSI: storvsc: NULL pointer dereference fix · 7c1de350
      Ales Novak authored
      commit b12bb60d upstream.
      
      If the initialization of storvsc fails, the storvsc_device_destroy()
      causes NULL pointer dereference.
      
      storvsc_bus_scan()
        scsi_scan_target()
          __scsi_scan_target()
            scsi_probe_and_add_lun(hostdata=NULL)
              scsi_alloc_sdev(hostdata=NULL)
      
      	  sdev->hostdata = hostdata
      
      	  now the host allocation fails
      
                __scsi_remove_device(sdev)
      
      	  calls sdev->host->hostt->slave_destroy() ==
      	  storvsc_device_destroy(sdev)
      	    access of sdev->hostdata->request_mempool
      Signed-off-by: default avatarAles Novak <alnovak@suse.cz>
      Signed-off-by: default avatarThomas Abraham <tabraham@suse.com>
      Reviewed-by: default avatarJiri Kosina <jkosina@suse.cz>
      Acked-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7c1de350
    • Giridhar Malavali's avatar
    • Lukasz Dorau's avatar
      SCSI: isci: correct erroneous for_each_isci_host macro · d9e8942e
      Lukasz Dorau authored
      commit c59053a2 upstream.
      
      In the first place, the loop 'for' in the macro 'for_each_isci_host'
      (drivers/scsi/isci/host.h:314) is incorrect, because it accesses
      the 3rd element of 2 element array. After the 2nd iteration it executes
      the instruction:
              ihost = to_pci_info(pdev)->hosts[2]
      (while the size of the 'hosts' array equals 2) and reads an
      out of range element.
      
      In the second place, this loop is incorrectly optimized by GCC v4.8
      (see http://marc.info/?l=linux-kernel&m=138998871911336&w=2).
      As a result, on platforms with two SCU controllers,
      the loop is executed more times than it can be (for i=0,1 and 2).
      It causes kernel panic during entering the S3 state
      and the following oops after 'rmmod isci':
      
      BUG: unable to handle kernel NULL pointer dereference at (null)
      IP: [<ffffffff8131360b>] __list_add+0x1b/0xc0
      Oops: 0000 [#1] SMP
      RIP: 0010:[<ffffffff8131360b>]  [<ffffffff8131360b>] __list_add+0x1b/0xc0
      Call Trace:
        [<ffffffff81661b84>] __mutex_lock_slowpath+0x114/0x1b0
        [<ffffffff81661c3f>] mutex_lock+0x1f/0x30
        [<ffffffffa03e97cb>] sas_disable_events+0x1b/0x50 [libsas]
        [<ffffffffa03e9818>] sas_unregister_ha+0x18/0x60 [libsas]
        [<ffffffffa040316e>] isci_unregister+0x1e/0x40 [isci]
        [<ffffffffa0403efd>] isci_pci_remove+0x5d/0x100 [isci]
        [<ffffffff813391cb>] pci_device_remove+0x3b/0xb0
        [<ffffffff813fbf7f>] __device_release_driver+0x7f/0xf0
        [<ffffffff813fc8f8>] driver_detach+0xa8/0xb0
        [<ffffffff813fbb8b>] bus_remove_driver+0x9b/0x120
        [<ffffffff813fcf2c>] driver_unregister+0x2c/0x50
        [<ffffffff813381f3>] pci_unregister_driver+0x23/0x80
        [<ffffffffa04152f8>] isci_exit+0x10/0x1e [isci]
        [<ffffffff810d199b>] SyS_delete_module+0x16b/0x2d0
        [<ffffffff81012a21>] ? do_notify_resume+0x61/0xa0
        [<ffffffff8166ce29>] system_call_fastpath+0x16/0x1b
      
      The loop has been corrected.
      This patch fixes kernel panic during entering the S3 state
      and the above oops.
      Signed-off-by: default avatarLukasz Dorau <lukasz.dorau@intel.com>
      Reviewed-by: default avatarMaciej Patelczyk <maciej.patelczyk@intel.com>
      Tested-by: default avatarLukasz Dorau <lukasz.dorau@intel.com>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d9e8942e
    • Dan Williams's avatar
      SCSI: isci: fix reset timeout handling · ff441dfa
      Dan Williams authored
      commit ddfadd77 upstream.
      
      Remove an erroneous BUG_ON() in the case of a hard reset timeout.  The
      reset timeout handler puts the port into the "awaiting link-up" state.
      The timeout causes the device to be disconnected and we need to be in
      the awaiting link-up state to re-connect the port.  The BUG_ON() made
      the incorrect assumption that resets never timeout and we always
      complete the reset in the "resetting" state.
      
      Testing this patch also uncovered that libata continues to attempt to
      reset the port long after the driver has torn down the context.  Once
      the driver has committed to abandoning the link it must indicate to
      libata that recovery ends by returning -ENODEV from
      ->lldd_I_T_nexus_reset().
      Acked-by: default avatarLukasz Dorau <lukasz.dorau@intel.com>
      Reported-by: default avatarDavid Milburn <dmilburn@redhat.com>
      Reported-by: default avatarXun Ni <xun.ni@intel.com>
      Tested-by: default avatarXun Ni <xun.ni@intel.com>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ff441dfa
    • Marc Kleine-Budde's avatar
      can: flexcan: flexcan_open(): fix error path if flexcan_chip_start() fails · f8d17b6f
      Marc Kleine-Budde authored
      commit 7e9e148a upstream.
      
      If flexcan_chip_start() in flexcan_open() fails, the interrupt is not freed,
      this patch adds the missing cleanup.
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f8d17b6f
    • Arnd Bergmann's avatar
      vmxnet3: fix building without CONFIG_PCI_MSI · 5e764c59
      Arnd Bergmann authored
      commit 0a8d8c44 upstream.
      
      Since commit d25f06ea "vmxnet3: fix netpoll race condition",
      the vmxnet3 driver fails to build when CONFIG_PCI_MSI is disabled,
      because it unconditionally references the vmxnet3_msix_rx()
      function.
      
      To fix this, use the same #ifdef in the caller that exists around
      the function definition.
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Cc: Neil Horman <nhorman@tuxdriver.com>
      Cc: Shreyas Bhatewara <sbhatewara@vmware.com>
      Cc: "VMware, Inc." <pv-drivers@vmware.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Acked-by: default avatarNeil Horman <nhorman@tuxdriver.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5e764c59
    • Neil Horman's avatar
      vmxnet3: fix netpoll race condition · 6b4741d6
      Neil Horman authored
      commit d25f06ea upstream.
      
      vmxnet3's netpoll driver is incorrectly coded.  It directly calls
      vmxnet3_do_poll, which is the driver internal napi poll routine.  As the netpoll
      controller method doesn't block real napi polls in any way, there is a potential
      for race conditions in which the netpoll controller method and the napi poll
      method run concurrently.  The result is data corruption causing panics such as this
      one recently observed:
      PID: 1371   TASK: ffff88023762caa0  CPU: 1   COMMAND: "rs:main Q:Reg"
       #0 [ffff88023abd5780] machine_kexec at ffffffff81038f3b
       #1 [ffff88023abd57e0] crash_kexec at ffffffff810c5d92
       #2 [ffff88023abd58b0] oops_end at ffffffff8152b570
       #3 [ffff88023abd58e0] die at ffffffff81010e0b
       #4 [ffff88023abd5910] do_trap at ffffffff8152add4
       #5 [ffff88023abd5970] do_invalid_op at ffffffff8100cf95
       #6 [ffff88023abd5a10] invalid_op at ffffffff8100bf9b
          [exception RIP: vmxnet3_rq_rx_complete+1968]
          RIP: ffffffffa00f1e80  RSP: ffff88023abd5ac8  RFLAGS: 00010086
          RAX: 0000000000000000  RBX: ffff88023b5dcee0  RCX: 00000000000000c0
          RDX: 0000000000000000  RSI: 00000000000005f2  RDI: ffff88023b5dcee0
          RBP: ffff88023abd5b48   R8: 0000000000000000   R9: ffff88023a3b6048
          R10: 0000000000000000  R11: 0000000000000002  R12: ffff8802398d4cd8
          R13: ffff88023af35140  R14: ffff88023b60c890  R15: 0000000000000000
          ORIG_RAX: ffffffffffffffff  CS: 0010  SS: 0018
       #7 [ffff88023abd5b50] vmxnet3_do_poll at ffffffffa00f204a [vmxnet3]
       #8 [ffff88023abd5b80] vmxnet3_netpoll at ffffffffa00f209c [vmxnet3]
       #9 [ffff88023abd5ba0] netpoll_poll_dev at ffffffff81472bb7
      
      The fix is to do as other drivers do, and have the poll controller call the top
      half interrupt handler, which schedules a napi poll properly to recieve frames
      
      Tested by myself, successfully.
      Signed-off-by: default avatarNeil Horman <nhorman@tuxdriver.com>
      CC: Shreyas Bhatewara <sbhatewara@vmware.com>
      CC: "VMware, Inc." <pv-drivers@vmware.com>
      CC: "David S. Miller" <davem@davemloft.net>
      Reviewed-by: default avatarShreyas N Bhatewara <sbhatewara@vmware.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6b4741d6