1. 25 Apr, 2013 27 commits
    • Thomas Gleixner's avatar
      sched_clock: Prevent 64bit inatomicity on 32bit systems · 4dfc47d2
      Thomas Gleixner authored
      commit a1cbcaa9 upstream.
      
      The sched_clock_remote() implementation has the following inatomicity
      problem on 32bit systems when accessing the remote scd->clock, which
      is a 64bit value.
      
      CPU0			CPU1
      
      sched_clock_local()	sched_clock_remote(CPU0)
      ...
      			remote_clock = scd[CPU0]->clock
      			    read_low32bit(scd[CPU0]->clock)
      cmpxchg64(scd->clock,...)
      			    read_high32bit(scd[CPU0]->clock)
      
      While the update of scd->clock is using an atomic64 mechanism, the
      readout on the remote cpu is not, which can cause completely bogus
      readouts.
      
      It is a quite rare problem, because it requires the update to hit the
      narrow race window between the low/high readout and the update must go
      across the 32bit boundary.
      
      The resulting misbehaviour is, that CPU1 will see the sched_clock on
      CPU1 ~4 seconds ahead of it's own and update CPU1s sched_clock value
      to this bogus timestamp. This stays that way due to the clamping
      implementation for about 4 seconds until the synchronization with
      CLOCK_MONOTONIC undoes the problem.
      
      The issue is hard to observe, because it might only result in a less
      accurate SCHED_OTHER timeslicing behaviour. To create observable
      damage on realtime scheduling classes, it is necessary that the bogus
      update of CPU1 sched_clock happens in the context of an realtime
      thread, which then gets charged 4 seconds of RT runtime, which results
      in the RT throttler mechanism to trigger and prevent scheduling of RT
      tasks for a little less than 4 seconds. So this is quite unlikely as
      well.
      
      The issue was quite hard to decode as the reproduction time is between
      2 days and 3 weeks and intrusive tracing makes it less likely, but the
      following trace recorded with trace_clock=global, which uses
      sched_clock_local(), gave the final hint:
      
        <idle>-0   0d..30 400269.477150: hrtimer_cancel: hrtimer=0xf7061e80
        <idle>-0   0d..30 400269.477151: hrtimer_start:  hrtimer=0xf7061e80 ...
      irq/20-S-587 1d..32 400273.772118: sched_wakeup:   comm= ... target_cpu=0
        <idle>-0   0dN.30 400273.772118: hrtimer_cancel: hrtimer=0xf7061e80
      
      What happens is that CPU0 goes idle and invokes
      sched_clock_idle_sleep_event() which invokes sched_clock_local() and
      CPU1 runs a remote wakeup for CPU0 at the same time, which invokes
      sched_remote_clock(). The time jump gets propagated to CPU0 via
      sched_remote_clock() and stays stale on both cores for ~4 seconds.
      
      There are only two other possibilities, which could cause a stale
      sched clock:
      
      1) ktime_get() which reads out CLOCK_MONOTONIC returns a sporadic
         wrong value.
      
      2) sched_clock() which reads the TSC returns a sporadic wrong value.
      
      #1 can be excluded because sched_clock would continue to increase for
         one jiffy and then go stale.
      
      #2 can be excluded because it would not make the clock jump
         forward. It would just result in a stale sched_clock for one jiffy.
      
      After quite some brain twisting and finding the same pattern on other
      traces, sched_clock_remote() remained the only place which could cause
      such a problem and as explained above it's indeed racy on 32bit
      systems.
      
      So while on 64bit systems the readout is atomic, we need to verify the
      remote readout on 32bit machines. We need to protect the local->clock
      readout in sched_clock_remote() on 32bit as well because an NMI could
      hit between the low and the high readout, call sched_clock_local() and
      modify local->clock.
      
      Thanks to Siegfried Wulsch for bearing with my debug requests and
      going through the tedious tasks of running a bunch of reproducer
      systems to generate the debug information which let me decode the
      issue.
      Reported-by: default avatarSiegfried Wulsch <Siegfried.Wulsch@rovema.de>
      Acked-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/r/alpine.LFD.2.02.1304051544160.21884@ionosSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      [bwh: Backported to 3.2: adjust filename]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      4dfc47d2
    • Michael Wolf's avatar
      powerpc: pSeries_lpar_hpte_remove fails from Adjunct partition being performed... · 2efb2740
      Michael Wolf authored
      powerpc: pSeries_lpar_hpte_remove fails from Adjunct partition being performed before the ANDCOND test
      
      commit 9fb26401 upstream.
      
      Some versions of pHyp will perform the adjunct partition test before the
      ANDCOND test.  The result of this is that H_RESOURCE can be returned and
      cause the BUG_ON condition to occur. The HPTE is not removed.  So add a
      check for H_RESOURCE, it is ok if this HPTE is not removed as
      pSeries_lpar_hpte_remove is looking for an HPTE to remove and not a
      specific HPTE to remove.  So it is ok to just move on to the next slot
      and try again.
      Signed-off-by: default avatarMichael Wolf <mjw@linux.vnet.ibm.com>
      Signed-off-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      2efb2740
    • Jay Estabrook's avatar
      alpha: Add irongate_io to PCI bus resources · 9c7787a1
      Jay Estabrook authored
      commit aa8b4be3 upstream.
      
      Fixes a NULL pointer dereference at boot on UP1500.
      Reviewed-and-Tested-by: default avatarMatt Turner <mattst88@gmail.com>
      Signed-off-by: default avatarJay Estabrook <jay.estabrook@gmail.com>
      Signed-off-by: default avatarMatt Turner <mattst88@gmail.com>
      Signed-off-by: default avatarMichael Cree <mcree@orcon.net.nz>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      9c7787a1
    • Eldad Zack's avatar
      ALSA: usb-audio: fix endianness bug in snd_nativeinstruments_* · 74e038af
      Eldad Zack authored
      commit 889d6684 upstream.
      
      The usb_control_msg() function expects __u16 types and performs
      the endianness conversions by itself.
      However, in three places, a conversion is performed before it is
      handed over to usb_control_msg(), which leads to a double conversion
      (= no conversion):
      * snd_usb_nativeinstruments_boot_quirk()
      * snd_nativeinstruments_control_get()
      * snd_nativeinstruments_control_put()
      
      Caught by sparse:
      
      sound/usb/mixer_quirks.c:512:38: warning: incorrect type in argument 6 (different base types)
      sound/usb/mixer_quirks.c:512:38:    expected unsigned short [unsigned] [usertype] index
      sound/usb/mixer_quirks.c:512:38:    got restricted __le16 [usertype] <noident>
      sound/usb/mixer_quirks.c:543:35: warning: incorrect type in argument 5 (different base types)
      sound/usb/mixer_quirks.c:543:35:    expected unsigned short [unsigned] [usertype] value
      sound/usb/mixer_quirks.c:543:35:    got restricted __le16 [usertype] <noident>
      sound/usb/mixer_quirks.c:543:56: warning: incorrect type in argument 6 (different base types)
      sound/usb/mixer_quirks.c:543:56:    expected unsigned short [unsigned] [usertype] index
      sound/usb/mixer_quirks.c:543:56:    got restricted __le16 [usertype] <noident>
      sound/usb/quirks.c:502:35: warning: incorrect type in argument 5 (different base types)
      sound/usb/quirks.c:502:35:    expected unsigned short [unsigned] [usertype] value
      sound/usb/quirks.c:502:35:    got restricted __le16 [usertype] <noident>
      Signed-off-by: default avatarEldad Zack <eldad@fogrefinery.com>
      Acked-by: default avatarDaniel Mack <zonque@gmail.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      74e038af
    • Li Fei's avatar
      hwspinlock: fix __hwspin_lock_request error path · f7626edc
      Li Fei authored
      commit c10b90d8 upstream.
      
      Even in failed case of pm_runtime_get_sync, the usage_count
      is incremented. In order to keep the usage_count with correct
      value and runtime power management to behave correctly, call
      pm_runtime_put_noidle in such case.
      
      In __hwspin_lock_request, module_put is also called before
      return in pm_runtime_get_sync failed case.
      
      Signed-off-by Liu Chuansheng <chuansheng.liu@intel.com>
      Signed-off-by: default avatarLi Fei <fei.li@intel.com>
      [edit commit log]
      Signed-off-by: default avatarOhad Ben-Cohen <ohad@wizery.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      f7626edc
    • Youquan Song's avatar
      ata_piix: Fix DVD not dectected at some Haswell platforms · e319383b
      Youquan Song authored
      commit b55f84e2 upstream.
      
      There is a quirk patch 5e5a4f5d
      "ata_piix: make DVD Drive recognisable on systems with Intel Sandybridge
       chipsets(v2)" fixing the 4 ports IDE controller 32bit PIO mode.
      
      We've hit a problem with DVD not recognized on Haswell Desktop platform which
      includes Lynx Point 2-port SATA controller.
      
      This quirk patch disables 32bit PIO on this controller in IDE mode.
      
      v2: Change spelling error in statememnt pointed by Sergei Shtylyov.
      v3: Change comment statememnt and spliting line over 80 characters pointed by
          Libor Pechacek and also rebase the patch against 3.8-rc7 kernel.
      Tested-by: default avatarLee, Chun-Yi <jlee@suse.com>
      Signed-off-by: default avatarYouquan Song <youquan.song@intel.com>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      e319383b
    • Shan Hai's avatar
      libata: Set max sector to 65535 for Slimtype DVD A DS8A8SH drive · 2c10a283
      Shan Hai authored
      commit a32450e1 upstream.
      
      The Slimtype DVD A  DS8A8SH drive locks up when max sector is smaller than
      65535, and the blow backtrace is observed on locking up:
      
      INFO: task flush-8:32:1130 blocked for more than 120 seconds.
      "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      flush-8:32      D ffffffff8180cf60     0  1130      2 0x00000000
       ffff880273aef618 0000000000000046 0000000000000005 ffff880273aee000
       ffff880273aee000 ffff880273aeffd8 ffff880273aee010 ffff880273aee000
       ffff880273aeffd8 ffff880273aee000 ffff88026e842ea0 ffff880274a10000
      Call Trace:
       [<ffffffff8168fc2d>] schedule+0x5d/0x70
       [<ffffffff8168fccc>] io_schedule+0x8c/0xd0
       [<ffffffff81324461>] get_request+0x731/0x7d0
       [<ffffffff8133dc60>] ? cfq_allow_merge+0x50/0x90
       [<ffffffff81083aa0>] ? wake_up_bit+0x40/0x40
       [<ffffffff81320443>] ? bio_attempt_back_merge+0x33/0x110
       [<ffffffff813248ea>] blk_queue_bio+0x23a/0x3f0
       [<ffffffff81322176>] generic_make_request+0xc6/0x120
       [<ffffffff81322308>] submit_bio+0x138/0x160
       [<ffffffff811d7596>] ? bio_alloc_bioset+0x96/0x120
       [<ffffffff811d1f61>] submit_bh+0x1f1/0x220
       [<ffffffff811d48b8>] __block_write_full_page+0x228/0x340
       [<ffffffff811d3650>] ? attach_nobh_buffers+0xc0/0xc0
       [<ffffffff811d8960>] ? I_BDEV+0x10/0x10
       [<ffffffff811d8960>] ? I_BDEV+0x10/0x10
       [<ffffffff811d4ab6>] block_write_full_page_endio+0xe6/0x100
       [<ffffffff811d4ae5>] block_write_full_page+0x15/0x20
       [<ffffffff811d9268>] blkdev_writepage+0x18/0x20
       [<ffffffff81142527>] __writepage+0x17/0x40
       [<ffffffff811438ba>] write_cache_pages+0x34a/0x4a0
       [<ffffffff81142510>] ? set_page_dirty+0x70/0x70
       [<ffffffff81143a61>] generic_writepages+0x51/0x80
       [<ffffffff81143ab0>] do_writepages+0x20/0x50
       [<ffffffff811c9ed6>] __writeback_single_inode+0xa6/0x2b0
       [<ffffffff811ca861>] writeback_sb_inodes+0x311/0x4d0
       [<ffffffff811caaa6>] __writeback_inodes_wb+0x86/0xd0
       [<ffffffff811cad43>] wb_writeback+0x1a3/0x330
       [<ffffffff816916cf>] ? _raw_spin_lock_irqsave+0x3f/0x50
       [<ffffffff811b8362>] ? get_nr_inodes+0x52/0x70
       [<ffffffff811cb0ac>] wb_do_writeback+0x1dc/0x260
       [<ffffffff8168dd34>] ? schedule_timeout+0x204/0x240
       [<ffffffff811cb232>] bdi_writeback_thread+0x102/0x2b0
       [<ffffffff811cb130>] ? wb_do_writeback+0x260/0x260
       [<ffffffff81083550>] kthread+0xc0/0xd0
       [<ffffffff81083490>] ? kthread_worker_fn+0x1b0/0x1b0
       [<ffffffff8169a3ec>] ret_from_fork+0x7c/0xb0
       [<ffffffff81083490>] ? kthread_worker_fn+0x1b0/0x1b0
      
       The above trace was triggered by
         "dd if=/dev/zero of=/dev/sr0 bs=2048 count=32768"
      
       It was previously working by accident, since another bug introduced
       by 4dce8ba9 (libata: Use 'bool' return value for ata_id_XXX) caused
       all drives to use maxsect=65535.
      Signed-off-by: default avatarShan Hai <shan.hai@windriver.com>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      2c10a283
    • Shan Hai's avatar
      libata: Use integer return value for atapi_command_packet_set · 274c4edc
      Shan Hai authored
      commit d8668fcb upstream.
      
      The function returns type of ATAPI drives so it should return integer value.
      The commit 4dce8ba9 (libata: Use 'bool' return value for ata_id_XXX) since
      v2.6.39 changed the type of return value from int to bool, the change would
      cause all of the ATAPI class drives to be treated as TYPE_TAPE and the
      max_sectors of the drives to be set to 65535 because of the commit
      f8d8e579(libata: increase 128 KB / cmd limit for ATAPI tape drives), for the
      function would return true for all ATAPI class drives and the TYPE_TAPE is
      defined as 0x01.
      Signed-off-by: default avatarShan Hai <shan.hai@windriver.com>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      274c4edc
    • Tim Gardner's avatar
      rt2x00: rt2x00pci_regbusy_read() - only print register access failure once · 61d50e12
      Tim Gardner authored
      commit 83589b30 upstream.
      
      BugLink: http://bugs.launchpad.net/bugs/1128840
      
      It appears that when this register read fails it never recovers, so
      I think there is no need to repeat the same error message ad infinitum.
      
      Cc: Ivo van Doorn <IvDoorn@gmail.com>
      Cc: Gertjan van Wingerde <gwingerde@gmail.com>
      Cc: Helmut Schaa <helmut.schaa@googlemail.com>
      Cc: "John W. Linville" <linville@tuxdriver.com>
      Cc: linux-wireless@vger.kernel.org
      Cc: users@rt2x00.serialmonkey.com
      Cc: netdev@vger.kernel.org
      Signed-off-by: default avatarTim Gardner <tim.gardner@canonical.com>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      61d50e12
    • Jussi Kivilinna's avatar
      crypto: gcm - fix assumption that assoc has one segment · da6e577a
      Jussi Kivilinna authored
      commit d3dde522 upstream.
      
      rfc4543(gcm(*)) code for GMAC assumes that assoc scatterlist always contains
      only one segment and only makes use of this first segment. However ipsec passes
      assoc with three segments when using 'extended sequence number' thus in this
      case rfc4543(gcm(*)) fails to function correctly. Patch fixes this issue.
      Reported-by: default avatarChaoxing Lin <Chaoxing.Lin@ultra-3eti.com>
      Tested-by: default avatarChaoxing Lin <Chaoxing.Lin@ultra-3eti.com>
      Signed-off-by: default avatarJussi Kivilinna <jussi.kivilinna@iki.fi>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      da6e577a
    • Michael Bohan's avatar
      hrtimer: Don't reinitialize a cpu_base lock on CPU_UP · de16cb5f
      Michael Bohan authored
      commit 84cc8fd2 upstream.
      
      The current code makes the assumption that a cpu_base lock won't be
      held if the CPU corresponding to that cpu_base is offline, which isn't
      always true.
      
      If a hrtimer is not queued, then it will not be migrated by
      migrate_hrtimers() when a CPU is offlined. Therefore, the hrtimer's
      cpu_base may still point to a CPU which has subsequently gone offline
      if the timer wasn't enqueued at the time the CPU went down.
      
      Normally this wouldn't be a problem, but a cpu_base's lock is blindly
      reinitialized each time a CPU is brought up. If a CPU is brought
      online during the period that another thread is performing a hrtimer
      operation on a stale hrtimer, then the lock will be reinitialized
      under its feet, and a SPIN_BUG() like the following will be observed:
      
      <0>[   28.082085] BUG: spinlock already unlocked on CPU#0, swapper/0/0
      <0>[   28.087078]  lock: 0xc4780b40, value 0x0 .magic: dead4ead, .owner: <none>/-1, .owner_cpu: -1
      <4>[   42.451150] [<c0014398>] (unwind_backtrace+0x0/0x120) from [<c0269220>] (do_raw_spin_unlock+0x44/0xdc)
      <4>[   42.460430] [<c0269220>] (do_raw_spin_unlock+0x44/0xdc) from [<c071b5bc>] (_raw_spin_unlock+0x8/0x30)
      <4>[   42.469632] [<c071b5bc>] (_raw_spin_unlock+0x8/0x30) from [<c00a9ce0>] (__hrtimer_start_range_ns+0x1e4/0x4f8)
      <4>[   42.479521] [<c00a9ce0>] (__hrtimer_start_range_ns+0x1e4/0x4f8) from [<c00aa014>] (hrtimer_start+0x20/0x28)
      <4>[   42.489247] [<c00aa014>] (hrtimer_start+0x20/0x28) from [<c00e6190>] (rcu_idle_enter_common+0x1ac/0x320)
      <4>[   42.498709] [<c00e6190>] (rcu_idle_enter_common+0x1ac/0x320) from [<c00e6440>] (rcu_idle_enter+0xa0/0xb8)
      <4>[   42.508259] [<c00e6440>] (rcu_idle_enter+0xa0/0xb8) from [<c000f268>] (cpu_idle+0x24/0xf0)
      <4>[   42.516503] [<c000f268>] (cpu_idle+0x24/0xf0) from [<c06ed3c0>] (rest_init+0x88/0xa0)
      <4>[   42.524319] [<c06ed3c0>] (rest_init+0x88/0xa0) from [<c0c00978>] (start_kernel+0x3d0/0x434)
      
      As an example, this particular crash occurred when hrtimer_start() was
      executed on CPU #0. The code locked the hrtimer's current cpu_base
      corresponding to CPU #1. CPU #0 then tried to switch the hrtimer's
      cpu_base to an optimal CPU which was online. In this case, it selected
      the cpu_base corresponding to CPU #3.
      
      Before it could proceed, CPU #1 came online and reinitialized the
      spinlock corresponding to its cpu_base. Thus now CPU #0 held a lock
      which was reinitialized. When CPU #0 finally ended up unlocking the
      old cpu_base corresponding to CPU #1 so that it could switch to CPU
      #3, we hit this SPIN_BUG() above while in switch_hrtimer_base().
      
      CPU #0                            CPU #1
      ----                              ----
      ...                               <offline>
      hrtimer_start()
      lock_hrtimer_base(base #1)
      ...                               init_hrtimers_cpu()
      switch_hrtimer_base()             ...
      ...                               raw_spin_lock_init(&cpu_base->lock)
      raw_spin_unlock(&cpu_base->lock)  ...
      <spin_bug>
      
      Solve this by statically initializing the lock.
      Signed-off-by: default avatarMichael Bohan <mbohan@codeaurora.org>
      Link: http://lkml.kernel.org/r/1363745965-23475-1-git-send-email-mbohan@codeaurora.orgSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      de16cb5f
    • Johan Hovold's avatar
      USB: ti_usb_3410_5052: fix use-after-free in TIOCMIWAIT · 3668b9c1
      Johan Hovold authored
      commit fc98ab87 upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      [bwh: Backported to 3.2: adjust context]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      3668b9c1
    • Johan Hovold's avatar
      USB: ssu100: fix use-after-free in TIOCMIWAIT · a8d64652
      Johan Hovold authored
      commit 43a66b4c upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      [bwh: Backported to 3.2: adjust context]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      a8d64652
    • Johan Hovold's avatar
      USB: spcp8x5: fix use-after-free in TIOCMIWAIT · d1baabc8
      Johan Hovold authored
      commit dbcea761 upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      [bwh: Backported to 3.2: adjust context, indentation]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      d1baabc8
    • Johan Hovold's avatar
      USB: pl2303: fix use-after-free in TIOCMIWAIT · 664e1221
      Johan Hovold authored
      commit 40509ca9 upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      664e1221
    • Johan Hovold's avatar
      USB: oti6858: fix use-after-free in TIOCMIWAIT · 5db2cb16
      Johan Hovold authored
      commit 8edfdab3 upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      [bwh: Backported to 3.2: adjust context, indentation]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      5db2cb16
    • Johan Hovold's avatar
      USB: mos7840: fix use-after-free in TIOCMIWAIT · 82159cdc
      Johan Hovold authored
      commit a14430db upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      82159cdc
    • Johan Hovold's avatar
      USB: mos7840: fix broken TIOCMIWAIT · 928ab285
      Johan Hovold authored
      commit e670c6af upstream.
      
      Make sure waiting processes are woken on modem-status changes.
      
      Currently processes are only woken on termios changes regardless of
      whether the modem status has changed.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      [bwh: Backported to 3.2: adjust context]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      928ab285
    • Johan Hovold's avatar
      USB: mct_u232: fix use-after-free in TIOCMIWAIT · 4f8adbff
      Johan Hovold authored
      commit cf1d2444 upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      [bwh: Backported to 3.2: adjust context]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      4f8adbff
    • Johan Hovold's avatar
      USB: io_ti: fix use-after-free in TIOCMIWAIT · 24d369d8
      Johan Hovold authored
      commit 7b245969 upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      24d369d8
    • Johan Hovold's avatar
      USB: io_edgeport: fix use-after-free in TIOCMIWAIT · 0c384c6e
      Johan Hovold authored
      commit 33357625 upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      0c384c6e
    • Johan Hovold's avatar
      USB: ftdi_sio: fix use-after-free in TIOCMIWAIT · 31b9905f
      Johan Hovold authored
      commit 71ccb9b0 upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      
      When switching to tty ports, some lifetime assumptions were changed.
      Specifically, close can now be called before the final tty reference is
      dropped as part of hangup at device disconnect. Even with the ftdi
      private-data refcounting this means that the port private data can be
      freed while a process is sleeping on modem-status changes and thus
      cannot be relied on to detect disconnects when woken up.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      31b9905f
    • Johan Hovold's avatar
      USB: cypress_m8: fix use-after-free in TIOCMIWAIT · 2d5a267e
      Johan Hovold authored
      commit 356050d8 upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      
      Also remove bogus test for private data pointer being NULL as it is
      never assigned in the loop.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      2d5a267e
    • Johan Hovold's avatar
      USB: ch341: fix use-after-free in TIOCMIWAIT · d14eeaff
      Johan Hovold authored
      commit fa1e11d5 upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      d14eeaff
    • Johan Hovold's avatar
      USB: ark3116: fix use-after-free in TIOCMIWAIT · 923ab36b
      Johan Hovold authored
      commit 50188603 upstream.
      
      Use the port wait queue and make sure to check the serial disconnected
      flag before accessing private port data after waking up.
      
      This is is needed as the private port data (including the wait queue
      itself) can be gone when waking up after a disconnect.
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      923ab36b
    • Ming Lei's avatar
      USB: serial: fix hang when opening port · a796ce48
      Ming Lei authored
      commit eba0e3c3 upstream.
      
      Johan's 'fix use-after-free in TIOCMIWAIT' patchset[1] introduces
      one bug which can cause kernel hang when opening port.
      
      This patch initialized the 'port->delta_msr_wait' waitqueue head
      to fix the bug which is introduced in 3.9-rc4.
      
      [1], http://marc.info/?l=linux-usb&m=136368139627876&w=2Signed-off-by: default avatarMing Lei <tom.leiming@gmail.com>
      Acked-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      a796ce48
    • Johan Hovold's avatar
      USB: serial: add modem-status-change wait queue · da07f459
      Johan Hovold authored
      commit e5b33dc9 upstream.
      
      Add modem-status-change wait queue to struct usb_serial_port that
      subdrivers can use to implement TIOCMIWAIT.
      
      Currently subdrivers use a private wait queue which may have been
      released when waking up after device disconnected.
      
      Note that we're adding a new wait queue rather than reusing the tty-port
      one as we do not want to get woken up at hangup (yet).
      Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      da07f459
  2. 10 Apr, 2013 13 commits