Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Jan 09, 2008
  2. Jan 08, 2008
    • Thomas Gleixner's avatar
      futex: Prevent stale futex owner when interrupted/timeout · cdf71a10
      Thomas Gleixner authored
      Roland Westrelin did a great analysis of a long standing thinko in the
      return path of futex_lock_pi.
      
      While we fixed the lock steal case long ago, which was easy to trigger,
      we never had a test case which exposed this problem and stupidly never
      thought about the reverse lock stealing scenario and the return to user
      space with a stale state.
      
      When a blocked tasks returns from rt_mutex_timed_locked without holding
      the rt_mutex (due to a signal or timeout) and at the same time the task
      holding the futex is releasing the futex and assigning the ownership of
      the futex to the returning task, then it might happen that a third task
      acquires the rt_mutex before the final rt_mutex_trylock() of the
      returning task happens under the futex hash bucket lock. The returning
      task returns to user space with ETIMEOUT or EINTR, but the user space
      futex value is assigned to this task. The task which acquired the
      rt_mutex fixes the user space futex value right after the hash bucket
      lock has been released by the returning task, but for a short period of
      time the user space value is wrong.
      
      Detailed description is available at:
      
         https://bugzilla.redhat.com/show_bug.cgi?id=400541
      
      
      
      The fix for this is the same as we do when the rt_mutex was acquired by
      a higher priority task via lock stealing from the designated new owner.
      In that case we already fix the user space value and the internal
      pi_state up before we return. This mechanism can be used to fixup the
      above corner case as well. When the returning task, which failed to
      acquire the rt_mutex, notices that it is the designated owner of the
      futex, then it fixes up the stale user space value and the pi_state,
      before returning to user space. This happens with the futex hash bucket
      lock held, so the task which acquired the rt_mutex is guaranteed to be
      blocked on the hash bucket lock. We can access the rt_mutex owner, which
      gives us the pid of the new owner, safely here as the owner is not able
      to modify (release) it while waiting on the hash bucket lock.
      
      Rename the "curr" argument of fixup_pi_state_owner() to "newowner" to
      avoid confusion with current and add the check for the stale state into
      the failure path of rt_mutex_trylock() in the return path of
      unlock_futex_pi(). If the situation is detected use
      fixup_pi_state_owner() to assign everything to the owner of the
      rt_mutex.
      
      Pointed-out-and-tested-by: default avatarRoland Westrelin <roland.westrelin@sun.com>
      Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      cdf71a10
    • Alan Cox's avatar
      pl2303: Fix mode switching regression · bf5e5834
      Alan Cox authored
      
      Cleaning out all the incorrect 'no change made' checks for termios
      settings showed up a problem with the PL2303. The hardware here seems to
      lose sync and bits if you tell it to make no changes. This shows up with
      a real world application.
      
      To fix this the driver check for meaningful hardware changes is restored
      but doing the tests correctly and as a tty layer function so it doesn't
      get duplicated wrongly everywhere if other drivers turn out to need it.
      
      Signed-off-by: default avatarAlan Cox <alan@redhat.com>
      Tested-by: default avatarMirko Parthey <mirko.parthey@informatik.tu-chemnitz.de>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      bf5e5834
    • Eric Sandeen's avatar
      hfs: handle more on-disk corruptions without oopsing · cf059462
      Eric Sandeen authored
      
      hfs seems prone to bad things when it encounters on disk corruption.  Many
      values are read from disk, and used as lengths to memcpy, as an example.
      This patch fixes up several of these problematic cases.
      
      o sanity check the on-disk maximum key lengths on mount
        (these are set to a defined value at mkfs time and shouldn't differ)
      o check on-disk node keylens against the maximum key length for each tree
      o fix hfs_btree_open so that going out via free_tree: doesn't wind
        up in hfs_releasepage, which wants to follow the very pointer
        we were trying to set up:
      	HFS_SB(sb)->cat_tree = hfs_btree_open()
      		...
      		failure gets to hfs_releasepage and tries
      		to follow HFS_SB(sb)->cat_tree
      
      Tested with the fsfuzzer; it survives more than it used to.
      
      Signed-off-by: default avatarEric Sandeen <sandeen@redhat.com>
      Cc: Roman Zippel <zippel@linux-m68k.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      cf059462
    • Thomas Bogendoerfer's avatar
      Fix crash with FLAT_MEMORY and ARCH_PFN_OFFSET != 0 · 467bc461
      Thomas Bogendoerfer authored
      
      When using FLAT_MEMORY and ARCH_PFN_OFFSET is not 0, the kernel crashes in
      memmap_init_zone().  This bug got introduced by commit
      c713216d
      
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      Acked-by: default avatarMel Gorman <mel@csn.ul.ie>
      Cc: Bob Picco <bob.picco@hp.com>
      Cc: Dave Hansen <haveblue@us.ibm.com>
      Cc: Andy Whitcroft <apw@shadowen.org>
      Cc: Andi Kleen <ak@muc.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: "Keith Mannthey" <kmannth@gmail.com>
      Cc: "Luck, Tony" <tony.luck@intel.com>
      Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Cc: Yasunori Goto <y-goto@jp.fujitsu.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      467bc461
Loading