1. 11 Jun, 2014 32 commits
  2. 07 Jun, 2014 8 commits
    • Greg Kroah-Hartman's avatar
      Linux 3.4.92 · 22feaed1
      Greg Kroah-Hartman authored
      22feaed1
    • Thomas Gleixner's avatar
      futex: Make lookup_pi_state more robust · 11b9a7a7
      Thomas Gleixner authored
      commit 54a21788 upstream.
      
      The current implementation of lookup_pi_state has ambigous handling of
      the TID value 0 in the user space futex.  We can get into the kernel
      even if the TID value is 0, because either there is a stale waiters bit
      or the owner died bit is set or we are called from the requeue_pi path
      or from user space just for fun.
      
      The current code avoids an explicit sanity check for pid = 0 in case
      that kernel internal state (waiters) are found for the user space
      address.  This can lead to state leakage and worse under some
      circumstances.
      
      Handle the cases explicit:
      
             Waiter | pi_state | pi->owner | uTID      | uODIED | ?
      
        [1]  NULL   | ---      | ---       | 0         | 0/1    | Valid
        [2]  NULL   | ---      | ---       | >0        | 0/1    | Valid
      
        [3]  Found  | NULL     | --        | Any       | 0/1    | Invalid
      
        [4]  Found  | Found    | NULL      | 0         | 1      | Valid
        [5]  Found  | Found    | NULL      | >0        | 1      | Invalid
      
        [6]  Found  | Found    | task      | 0         | 1      | Valid
      
        [7]  Found  | Found    | NULL      | Any       | 0      | Invalid
      
        [8]  Found  | Found    | task      | ==taskTID | 0/1    | Valid
        [9]  Found  | Found    | task      | 0         | 0      | Invalid
        [10] Found  | Found    | task      | !=taskTID | 0/1    | Invalid
      
       [1] Indicates that the kernel can acquire the futex atomically. We
           came came here due to a stale FUTEX_WAITERS/FUTEX_OWNER_DIED bit.
      
       [2] Valid, if TID does not belong to a kernel thread. If no matching
           thread is found then it indicates that the owner TID has died.
      
       [3] Invalid. The waiter is queued on a non PI futex
      
       [4] Valid state after exit_robust_list(), which sets the user space
           value to FUTEX_WAITERS | FUTEX_OWNER_DIED.
      
       [5] The user space value got manipulated between exit_robust_list()
           and exit_pi_state_list()
      
       [6] Valid state after exit_pi_state_list() which sets the new owner in
           the pi_state but cannot access the user space value.
      
       [7] pi_state->owner can only be NULL when the OWNER_DIED bit is set.
      
       [8] Owner and user space value match
      
       [9] There is no transient state which sets the user space TID to 0
           except exit_robust_list(), but this is indicated by the
           FUTEX_OWNER_DIED bit. See [4]
      
      [10] There is no transient state which leaves owner and user space
           TID out of sync.
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Will Drewry <wad@chromium.org>
      Cc: Darren Hart <dvhart@linux.intel.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      11b9a7a7
    • Thomas Gleixner's avatar
      futex: Always cleanup owner tid in unlock_pi · a8f96abb
      Thomas Gleixner authored
      commit 13fbca4c upstream.
      
      If the owner died bit is set at futex_unlock_pi, we currently do not
      cleanup the user space futex.  So the owner TID of the current owner
      (the unlocker) persists.  That's observable inconsistant state,
      especially when the ownership of the pi state got transferred.
      
      Clean it up unconditionally.
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Will Drewry <wad@chromium.org>
      Cc: Darren Hart <dvhart@linux.intel.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a8f96abb
    • Thomas Gleixner's avatar
      futex: Validate atomic acquisition in futex_lock_pi_atomic() · 2397889b
      Thomas Gleixner authored
      commit b3eaa9fc upstream.
      
      We need to protect the atomic acquisition in the kernel against rogue
      user space which sets the user space futex to 0, so the kernel side
      acquisition succeeds while there is existing state in the kernel
      associated to the real owner.
      
      Verify whether the futex has waiters associated with kernel state.  If
      it has, return -EINVAL.  The state is corrupted already, so no point in
      cleaning it up.  Subsequent calls will fail as well.  Not our problem.
      
      [ tglx: Use futex_top_waiter() and explain why we do not need to try
        	restoring the already corrupted user space state. ]
      Signed-off-by: default avatarDarren Hart <dvhart@linux.intel.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Will Drewry <wad@chromium.org>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2397889b
    • Thomas Gleixner's avatar
      futex-prevent-requeue-pi-on-same-futex.patch futex: Forbid uaddr == uaddr2 in... · 4cca4db7
      Thomas Gleixner authored
      futex-prevent-requeue-pi-on-same-futex.patch futex: Forbid uaddr == uaddr2 in futex_requeue(..., requeue_pi=1)
      
      commit e9c243a5 upstream.
      
      If uaddr == uaddr2, then we have broken the rule of only requeueing from
      a non-pi futex to a pi futex with this call.  If we attempt this, then
      dangling pointers may be left for rt_waiter resulting in an exploitable
      condition.
      
      This change brings futex_requeue() in line with futex_wait_requeue_pi()
      which performs the same check as per commit 6f7b0a2a ("futex: Forbid
      uaddr == uaddr2 in futex_wait_requeue_pi()")
      
      [ tglx: Compare the resulting keys as well, as uaddrs might be
        	different depending on the mapping ]
      
      Fixes CVE-2014-3153.
      
      Reported-by: Pinkie Pie
      Signed-off-by: default avatarWill Drewry <wad@chromium.org>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarDarren Hart <dvhart@linux.intel.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      
      4cca4db7
    • Stanislaw Gruszka's avatar
      ath9k: protect tid->sched check · c6f9d698
      Stanislaw Gruszka authored
      commit 21f8aaee upstream.
      
      We check tid->sched without a lock taken on ath_tx_aggr_sleep(). That
      is race condition which can result of doing list_del(&tid->list) twice
      (second time with poisoned list node) and cause crash like shown below:
      
      [424271.637220] BUG: unable to handle kernel paging request at 00100104
      [424271.637328] IP: [<f90fc072>] ath_tx_aggr_sleep+0x62/0xe0 [ath9k]
      ...
      [424271.639953] Call Trace:
      [424271.639998]  [<f90f6900>] ? ath9k_get_survey+0x110/0x110 [ath9k]
      [424271.640083]  [<f90f6942>] ath9k_sta_notify+0x42/0x50 [ath9k]
      [424271.640177]  [<f809cfef>] sta_ps_start+0x8f/0x1c0 [mac80211]
      [424271.640258]  [<c10f730e>] ? free_compound_page+0x2e/0x40
      [424271.640346]  [<f809e915>] ieee80211_rx_handlers+0x9d5/0x2340 [mac80211]
      [424271.640437]  [<c112f048>] ? kmem_cache_free+0x1d8/0x1f0
      [424271.640510]  [<c1345a84>] ? kfree_skbmem+0x34/0x90
      [424271.640578]  [<c10fc23c>] ? put_page+0x2c/0x40
      [424271.640640]  [<c1345a84>] ? kfree_skbmem+0x34/0x90
      [424271.640706]  [<c1345a84>] ? kfree_skbmem+0x34/0x90
      [424271.640787]  [<f809dde3>] ? ieee80211_rx_handlers_result+0x73/0x1d0 [mac80211]
      [424271.640897]  [<f80a07a0>] ieee80211_prepare_and_rx_handle+0x520/0xad0 [mac80211]
      [424271.641009]  [<f809e22d>] ? ieee80211_rx_handlers+0x2ed/0x2340 [mac80211]
      [424271.641104]  [<c13846ce>] ? ip_output+0x7e/0xd0
      [424271.641182]  [<f80a1057>] ieee80211_rx+0x307/0x7c0 [mac80211]
      [424271.641266]  [<f90fa6ee>] ath_rx_tasklet+0x88e/0xf70 [ath9k]
      [424271.641358]  [<f80a0f2c>] ? ieee80211_rx+0x1dc/0x7c0 [mac80211]
      [424271.641445]  [<f90f82db>] ath9k_tasklet+0xcb/0x130 [ath9k]
      
      Bug report:
      https://bugzilla.kernel.org/show_bug.cgi?id=70551Reported-and-tested-by: default avatarMax Sydorenko <maxim.stargazer@gmail.com>
      Signed-off-by: default avatarStanislaw Gruszka <sgruszka@redhat.com>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      [bwh: Backported to 3.2:
       - Adjust context
       - Use spin_unlock_bh() directly]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      [gkh: backported to 3.4:
       - adjust context
       - back out bwh's spinlock change]
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c6f9d698
    • Alan Cox's avatar
      dj: memory scribble in logi_dj · a592e244
      Alan Cox authored
      commit 8a55ade7 upstream.
      
      Allocate a structure not a pointer to it !
      Signed-off-by: default avatarAlan Cox <alan@linux.intel.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Cc: Yijing Wang <wangyijing@huawei.com>
      Cc: Marc Dionne <marc.c.dionne@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a592e244
    • Marc Dionne's avatar
      HID: logitech: don't use stack based dj_report structures · 761dae91
      Marc Dionne authored
      commit d8dc3494 upstream.
      
      On a system with a logitech wireless keyboard/mouse and DMA-API debugging
      enabled, this warning appears at boot:
      
      kernel: WARNING: at lib/dma-debug.c:929 check_for_stack.part.12+0x70/0xa7()
      kernel: Hardware name: MS-7593
      kernel: uhci_hcd 0000:00:1d.1: DMA-API: device driver maps memory fromstack [addr=ffff8801b0079c29]
      
      Make logi_dj_recv_query_paired_devices and logi_dj_recv_switch_to_dj_mode
      use a structure allocated with kzalloc rather than a stack based one.
      Signed-off-by: default avatarMarc Dionne <marc.c.dionne@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Cc: Yijing Wang <wangyijing@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      761dae91