1. 07 Oct, 2012 12 commits
  2. 02 Oct, 2012 28 commits
    • Greg Kroah-Hartman's avatar
      Linux 3.0.44 · b9a7985a
      Greg Kroah-Hartman authored
      b9a7985a
    • Will Deacon's avatar
      ARM: 7467/1: mutex: use generic xchg-based implementation for ARMv6+ · 54d4d42b
      Will Deacon authored
      commit a76d7bd9 upstream.
      
      The open-coded mutex implementation for ARMv6+ cores suffers from a
      severe lack of barriers, so in the uncontended case we don't actually
      protect any accesses performed during the critical section.
      
      Furthermore, the code is largely a duplication of the ARMv6+ atomic_dec
      code but optimised to remove a branch instruction, as the mutex fastpath
      was previously inlined. Now that this is executed out-of-line, we can
      reuse the atomic access code for the locking (in fact, we use the xchg
      code as this produces shorter critical sections).
      
      This patch uses the generic xchg based implementation for mutexes on
      ARMv6+, which introduces barriers to the lock/unlock operations and also
      has the benefit of removing a fair amount of inline assembly code.
      Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
      Acked-by: default avatarNicolas Pitre <nico@linaro.org>
      Reported-by: default avatarShan Kang <kangshan0910@gmail.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      54d4d42b
    • Alan Stern's avatar
      USB: Fix race condition when removing host controllers · b15ab4ac
      Alan Stern authored
      commit 0d00dc26 upstream.
      
      This patch (as1607) fixes a race that can occur if a USB host
      controller is removed while a process is reading the
      /sys/kernel/debug/usb/devices file.
      
      The usb_device_read() routine uses the bus->root_hub pointer to
      determine whether or not the root hub is registered.  The is not a
      valid test, because the pointer is set before the root hub gets
      registered and remains set even after the root hub is unregistered and
      deallocated.  As a result, usb_device_read() or usb_device_dump() can
      access freed memory, causing an oops.
      
      The patch changes the test to use the hcd->rh_registered flag, which
      does get set and cleared at the appropriate times.  It also makes sure
      to hold the usb_bus_list_lock mutex while setting the flag, so that
      usb_device_read() will become aware of new root hubs as soon as they
      are registered.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Reported-by: default avatarDon Zickus <dzickus@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b15ab4ac
    • Andi Kleen's avatar
      MCE: Fix vm86 handling for 32bit mce handler · 8ef8fa74
      Andi Kleen authored
      commit a129a7c8 upstream.
      
      When running on 32bit the mce handler could misinterpret
      vm86 mode as ring 0. This can affect whether it does recovery
      or not; it was possible to panic when recovery was actually
      possible.
      
      Fix this by always forcing vm86 to look like ring 3.
      
      [ Backport to 3.0 notes:
      Things changed there slightly:
         - move mce_get_rip() up. It fills up m->cs and m->ip values which
           are evaluated in mce_severity(). Therefore move it up right before
           the mce_severity call. This seem to be another bug in 3.0?
         - Place the backport (fix m->cs in V86 case) to where m->cs gets
           filled which is mce_get_rip() in 3.0
      ]
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
      Signed-off-by: default avatarThomas Renninger <trenn@suse.de>
      Reviewed-by: default avatarTony Luck <tony.luck@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8ef8fa74
    • Yasunori Goto's avatar
      sched: Fix ancient race in do_exit() · ca465bac
      Yasunori Goto authored
      commit b5740f4b upstream.
      
      try_to_wake_up() has a problem which may change status from TASK_DEAD to
      TASK_RUNNING in race condition with SMI or guest environment of virtual
      machine. As a result, exited task is scheduled() again and panic occurs.
      
      Here is the sequence how it occurs:
      
       ----------------------------------+-----------------------------
                                         |
                  CPU A                  |             CPU B
       ----------------------------------+-----------------------------
      
      TASK A calls exit()....
      
      do_exit()
      
        exit_mm()
          down_read(mm->mmap_sem);
      
          rwsem_down_failed_common()
      
            set TASK_UNINTERRUPTIBLE
            set waiter.task <= task A
            list_add to sem->wait_list
                 :
            raw_spin_unlock_irq()
            (I/O interruption occured)
      
                                            __rwsem_do_wake(mmap_sem)
      
                                              list_del(&waiter->list);
                                              waiter->task = NULL
                                              wake_up_process(task A)
                                                try_to_wake_up()
                                                   (task is still
                                                     TASK_UNINTERRUPTIBLE)
                                                    p->on_rq is still 1.)
      
                                                    ttwu_do_wakeup()
                                                       (*A)
                                                         :
           (I/O interruption handler finished)
      
            if (!waiter.task)
                schedule() is not called
                due to waiter.task is NULL.
      
            tsk->state = TASK_RUNNING
      
                :
                                                    check_preempt_curr();
                                                        :
        task->state = TASK_DEAD
                                                    (*B)
                                              <---    set TASK_RUNNING (*C)
      
           schedule()
           (exit task is running again)
           BUG_ON() is called!
       --------------------------------------------------------
      
      The execution time between (*A) and (*B) is usually very short,
      because the interruption is disabled, and setting TASK_RUNNING at (*C)
      must be executed before setting TASK_DEAD.
      
      HOWEVER, if SMI is interrupted between (*A) and (*B),
      (*C) is able to execute AFTER setting TASK_DEAD!
      Then, exited task is scheduled again, and BUG_ON() is called....
      
      If the system works on guest system of virtual machine, the time
      between (*A) and (*B) may be also long due to scheduling of hypervisor,
      and same phenomenon can occur.
      
      By this patch, do_exit() waits for releasing task->pi_lock which is used
      in try_to_wake_up(). It guarantees the task becomes TASK_DEAD after
      waking up.
      Signed-off-by: default avatarYasunori Goto <y-goto@jp.fujitsu.com>
      Acked-by: default avatarOleg Nesterov <oleg@redhat.com>
      Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Link: http://lkml.kernel.org/r/20120117174031.3118.E1E9C6FF@jp.fujitsu.comSigned-off-by: default avatarIngo Molnar <mingo@elte.hu>
      Cc: Michal Hocko <mhocko@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ca465bac
    • Herton Ronaldo Krzesinski's avatar
      spi/spi-fsl-spi: reference correct pdata in fsl_spi_cs_control · 81e80587
      Herton Ronaldo Krzesinski authored
      commit 067aa481 upstream.
      
      Commit 178db7d3, "spi: Fix device unregistration when unregistering
      the bus master", changed spi device initialization of dev.parent pointer
      to be the master's device pointer instead of his parent.
      
      This introduced a bug in spi-fsl-spi, since its usage of spi device
      pointer was not updated accordingly. This was later fixed by commit
      5039a869, "spi/mpc83xx: fix NULL pdata dereference bug", but it missed
      another spot on fsl_spi_cs_control function where we also need to update
      usage of spi device pointer. This change address that.
      Signed-off-by: default avatarHerton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
      Acked-by: default avatarJoakim Tjernlund <Joakim.Tjernlund@transmode.se>
      Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
      Cc: Alfredo Capella <alfredo.capella@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      81e80587
    • Kenth Eriksson's avatar
      spi/mpc83xx: fix NULL pdata dereference bug · 7388a987
      Kenth Eriksson authored
      commit 5039a869 upstream.
      
      Commit 178db7d3, "spi: Fix device unregistration when unregistering
      the bus master", changed device initialization to be children of the
      bus master, not children of the bus masters parent device. The pdata
      pointer used in fsl_spi_chipselect must updated to reflect the changed
      initialization.
      Signed-off-by: default avatarKenth Eriksson <kenth.eriksson@transmode.com>
      Acked-by: default avatarJoakim Tjernlund <Joakim.Tjernlund@transmode.se>
      Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
      Cc: Alfredo Capella <alfredo.capella@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7388a987
    • Artem Bityutskiy's avatar
      UBI: fix a horrible memory deallocation bug · aaa9ef3b
      Artem Bityutskiy authored
      commit 78b495c3 upstream
      
      UBI was mistakingly using 'kfree()' instead of 'kmem_cache_free()' when
      freeing "attach eraseblock" structures in vtbl.c. Thankfully, this happened
      only when we were doing auto-format, so many systems were unaffected. However,
      there are still many users affected.
      
      It is strange, but the system did not crash and nothing bad happened when
      the SLUB memory allocator was used. However, in case of SLOB we observed an
      crash right away.
      
      This problem was introduced in 2.6.39 by commit
      "6c1e875c UBI: add slab cache for ubi_scan_leb objects"
      Reported-by: default avatarRichard Genoud <richard.genoud@gmail.com>
      Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
      Signed-off-by: default avatarRichard Genoud <richard.genoud@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      aaa9ef3b
    • Chris Boot's avatar
      e1000e: Disable ASPM L1 on 82574 · 41cc15ce
      Chris Boot authored
      commit d4a4206e upstream.
      
      ASPM on the 82574 causes trouble. Currently the driver disables L0s for
      this NIC but only disables L1 if the MTU is >1500. This patch simply
      causes L1 to be disabled regardless of the MTU setting.
      Signed-off-by: default avatarChris Boot <bootc@bootc.net>
      Cc: "Wyborny, Carolyn" <carolyn.wyborny@intel.com>
      Cc: Nix <nix@esperi.org.uk>
      Link: https://lkml.org/lkml/2012/3/19/362Tested-by: default avatarJeff Pieper <jeffrey.e.pieper@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      Signed-off-by: default avatarNikola Ciprich <nikola.ciprich@linuxbox.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      41cc15ce
    • Al Cooper's avatar
      mmc: Prevent 1.8V switch for SD hosts that don't support UHS modes. · cfa379de
      Al Cooper authored
      commit 4188bba0 upstream.
      
      The driver should not try to switch to 1.8V when the SD 3.0 host
      controller does not have any UHS capabilities bits set (SDR50, DDR50
      or SDR104). See page 72 of "SD Specifications Part A2 SD Host
      Controller Simplified Specification Version 3.00" under
      "1.8V Signaling Enable". Instead of setting SDR12 and SDR25 in the host
      capabilities data structure for all V3.0 host controllers, only set them
      if SDR104, SDR50 or DDR50 is set in the host capabilities register. This
      will prevent the switch to 1.8V later.
      Signed-off-by: default avatarAl Cooper <acooper@gmail.com>
      Acked-by: default avatarArindam Nath <arindam.nath@amd.com>
      Acked-by: default avatarPhilip Rakity <prakity@marvell.com>
      Acked-by: default avatarGirish K S <girish.shivananjappa@linaro.org>
      Signed-off-by: default avatarChris Ball <cjb@laptop.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cfa379de
    • Subhash Jadavani's avatar
      mmc: sd: Handle SD3.0 cards not supporting UHS-I bus speed mode · 09e4ad5a
      Subhash Jadavani authored
      commit f2815f68 upstream.
      
      Here is Essential conditions to indicate Version 3.00 Card
      (SD_SPEC=2 and SD_SPEC3=1) :
      (1) The card shall support CMD6
      (2) The card shall support CMD8
      (3) The card shall support CMD42
      (4) User area capacity shall be up to 2GB (SDSC) or 32GB (SDHC)
          User area capacity shall be more than or equal to 32GB and
          up to 2TB (SDXC)
      (5) Speed Class shall be supported (SDHC or SDXC)
      
      So even if SD card doesn't support any of the newly defined
      UHS-I bus speed mode, it can advertise itself as SD3.0 cards
      as long as it supports all the essential conditions of
      SD3.0 cards. Given this, these type of cards should atleast
      run in High Speed mode @50MHZ if it supports HS.
      
      But current initialization sequence for SD3.0 cards is
      such that these non-UHS-I SD3.0 cards runs in Default
      Speed mode @25MHz.
      
      This patch makes sure that these non-UHS-I SD3.0 cards run
      in High Speed Mode @50MHz.
      
      Tested this patch with SanDisk Extreme SDHC 8GB Class 10 card.
      Reported-by: default avatar"Hiremath, Vaibhav" <hvaibhav@ti.com>
      Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
      Signed-off-by: default avatarChris Ball <cjb@laptop.org>
      09e4ad5a
    • Phillip Lougher's avatar
      Squashfs: fix mount time sanity check for corrupted superblock · 9523d524
      Phillip Lougher authored
      commit cc37f75a upstream.
      
      A Squashfs filesystem containing nothing but an empty directory,
      although unusual and ultimately pointless, is still valid.
      
      The directory_table >= next_table sanity check rejects these
      filesystems as invalid because the directory_table is empty and
      equal to next_table.
      Signed-off-by: default avatarPhillip Lougher <phillip@squashfs.org.uk>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9523d524
    • Tomoya MORINAGA's avatar
      pch_uart: Fix parity setting issue · b960ba52
      Tomoya MORINAGA authored
      commit 38bd2a1a upstream.
      
      Parity Setting value is reverse.
      E.G. In case of setting ODD parity, EVEN value is set.
      This patch inverts "if" condition.
      Signed-off-by: default avatarTomoya MORINAGA <tomoya.rohm@gmail.com>
      Acked-by: default avatarAlan Cox <alan@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b960ba52
    • Tomoya MORINAGA's avatar
      pch_uart: Fix rx error interrupt setting issue · 4b14f6f4
      Tomoya MORINAGA authored
      commit 9539dfb7 upstream.
      
      Rx Error interrupt(E.G. parity error) is not enabled.
      So, when parity error occurs, error interrupt is not occurred.
      As a result, the received data is not dropped.
      
      This patch adds enable/disable rx error interrupt code.
      Signed-off-by: default avatarTomoya MORINAGA <tomoya.rohm@gmail.com>
      Acked-by: default avatarAlan Cox <alan@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4b14f6f4
    • Alan Cox's avatar
      pch_uart: Fix missing break for 16 byte fifo · 00b35456
      Alan Cox authored
      commit 9bc03743 upstream.
      
      Otherwise we fall back to the wrong value.
      
      Reported-by: <dcb314@hotmail.com>
      Resolves-bug: https://bugzilla.kernel.org/show_bug.cgi?id=44091Signed-off-by: default avatarAlan Cox <alan@linux.intel.com>
      Signed-off-by: default avatarTomoya MORINAGA <tomoya.rohm@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      00b35456
    • Douglas Bagnall's avatar
      media: Avoid sysfs oops when an rc_dev's raw device is absent · abfbc26e
      Douglas Bagnall authored
      commit 720bb643 upstream.
      
      For some reason, when the lirc daemon learns that a usb remote control
      has been unplugged, it wants to read the sysfs attributes of the
      disappearing device. This is useful for uncovering transient
      inconsistencies, but less so for keeping the system running when such
      inconsistencies exist.
      
      Under some circumstances (like every time I unplug my dvb stick from
      my laptop), lirc catches an rc_dev whose raw event handler has been
      removed (presumably by ir_raw_event_unregister), and proceeds to
      interrogate the raw protocols supported by the NULL pointer.
      
      This patch avoids the NULL dereference, and ignores the issue of how
      this state of affairs came about in the first place.
      
      Version 2 incorporates changes recommended by Mauro Carvalho Chehab
      (-ENODEV instead of -EINVAL, and a signed-off-by).
      Signed-off-by: default avatarDouglas Bagnall <douglas@paradise.net.nz>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
      Cc: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      abfbc26e
    • John Stultz's avatar
      time: Move ktime_t overflow checking into timespec_valid_strict · fe979e2c
      John Stultz authored
      commit cee58483 upstream
      
      Andreas Bombe reported that the added ktime_t overflow checking added to
      timespec_valid in commit 4e8b1452 ("time: Improve sanity checking of
      timekeeping inputs") was causing problems with X.org because it caused
      timeouts larger then KTIME_T to be invalid.
      
      Previously, these large timeouts would be clamped to KTIME_MAX and would
      never expire, which is valid.
      
      This patch splits the ktime_t overflow checking into a new
      timespec_valid_strict function, and converts the timekeeping codes
      internal checking to use this more strict function.
      Reported-and-tested-by: default avatarAndreas Bombe <aeb@debian.org>
      Cc: Zhouping Liu <zliu@redhat.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fe979e2c
    • John Stultz's avatar
      time: Avoid making adjustments if we haven't accumulated anything · 4ffa9a80
      John Stultz authored
      commit bf2ac312 upstream
      
      If update_wall_time() is called and the current offset isn't large
      enough to accumulate, avoid re-calling timekeeping_adjust which may
      change the clock freq and can cause 1ns inconsistencies with
      CLOCK_REALTIME_COARSE/CLOCK_MONOTONIC_COARSE.
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Link: http://lkml.kernel.org/r/1345595449-34965-5-git-send-email-john.stultz@linaro.orgSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4ffa9a80
    • John Stultz's avatar
      time: Improve sanity checking of timekeeping inputs · 44fa9a01
      John Stultz authored
      commit 4e8b1452 upstream
      
      Unexpected behavior could occur if the time is set to a value large
      enough to overflow a 64bit ktime_t (which is something larger then the
      year 2262).
      
      Also unexpected behavior could occur if large negative offsets are
      injected via adjtimex.
      
      So this patch improves the sanity check timekeeping inputs by
      improving the timespec_valid() check, and then makes better use of
      timespec_valid() to make sure we don't set the time to an invalid
      negative value or one that overflows ktime_t.
      
      Note: This does not protect from setting the time close to overflowing
      ktime_t and then letting natural accumulation cause the overflow.
      Reported-by: default avatarCAI Qian <caiqian@redhat.com>
      Reported-by: default avatarSasha Levin <levinsasha928@gmail.com>
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Zhouping Liu <zliu@redhat.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Link: http://lkml.kernel.org/r/1344454580-17031-1-git-send-email-john.stultz@linaro.orgSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      44fa9a01
    • Eric Dumazet's avatar
      drop_monitor: dont sleep in atomic context · 81cee4e9
      Eric Dumazet authored
      commit bec4596b upstream.
      
      drop_monitor calls several sleeping functions while in atomic context.
      
       BUG: sleeping function called from invalid context at mm/slub.c:943
       in_atomic(): 1, irqs_disabled(): 0, pid: 2103, name: kworker/0:2
       Pid: 2103, comm: kworker/0:2 Not tainted 3.5.0-rc1+ #55
       Call Trace:
        [<ffffffff810697ca>] __might_sleep+0xca/0xf0
        [<ffffffff811345a3>] kmem_cache_alloc_node+0x1b3/0x1c0
        [<ffffffff8105578c>] ? queue_delayed_work_on+0x11c/0x130
        [<ffffffff815343fb>] __alloc_skb+0x4b/0x230
        [<ffffffffa00b0360>] ? reset_per_cpu_data+0x160/0x160 [drop_monitor]
        [<ffffffffa00b022f>] reset_per_cpu_data+0x2f/0x160 [drop_monitor]
        [<ffffffffa00b03ab>] send_dm_alert+0x4b/0xb0 [drop_monitor]
        [<ffffffff810568e0>] process_one_work+0x130/0x4c0
        [<ffffffff81058249>] worker_thread+0x159/0x360
        [<ffffffff810580f0>] ? manage_workers.isra.27+0x240/0x240
        [<ffffffff8105d403>] kthread+0x93/0xa0
        [<ffffffff816be6d4>] kernel_thread_helper+0x4/0x10
        [<ffffffff8105d370>] ? kthread_freezable_should_stop+0x80/0x80
        [<ffffffff816be6d0>] ? gs_change+0xb/0xb
      
      Rework the logic to call the sleeping functions in right context.
      
      Use standard timer/workqueue api to let system chose any cpu to perform
      the allocation and netlink send.
      
      Also avoid a loop if reset_per_cpu_data() cannot allocate memory :
      use mod_timer() to wait 1/10 second before next try.
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Neil Horman <nhorman@tuxdriver.com>
      Reviewed-by: default avatarNeil Horman <nhorman@tuxdriver.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Cc: Ben Hutchings <ben@decadent.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      81cee4e9
    • Neil Horman's avatar
      drop_monitor: prevent init path from scheduling on the wrong cpu · 2c51de7f
      Neil Horman authored
      commit 4fdcfa12 upstream.
      
      I just noticed after some recent updates, that the init path for the drop
      monitor protocol has a minor error.  drop monitor maintains a per cpu structure,
      that gets initalized from a single cpu.  Normally this is fine, as the protocol
      isn't in use yet, but I recently made a change that causes a failed skb
      allocation to reschedule itself .  Given the current code, the implication is
      that this workqueue reschedule will take place on the wrong cpu.  If drop
      monitor is used early during the boot process, its possible that two cpus will
      access a single per-cpu structure in parallel, possibly leading to data
      corruption.
      
      This patch fixes the situation, by storing the cpu number that a given instance
      of this per-cpu data should be accessed from.  In the case of a need for a
      reschedule, the cpu stored in the struct is assigned the rescheule, rather than
      the currently executing cpu
      
      Tested successfully by myself.
      Signed-off-by: default avatarNeil Horman <nhorman@tuxdriver.com>
      CC: David Miller <davem@davemloft.net>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Cc: Ben Hutchings <ben@decadent.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2c51de7f
    • Neil Horman's avatar
      drop_monitor: Make updating data->skb smp safe · b2f89a7c
      Neil Horman authored
      commit 3885ca78 upstream.
      
      Eric Dumazet pointed out to me that the drop_monitor protocol has some holes in
      its smp protections.  Specifically, its possible to replace data->skb while its
      being written.  This patch corrects that by making data->skb an rcu protected
      variable.  That will prevent it from being overwritten while a tracepoint is
      modifying it.
      Signed-off-by: default avatarNeil Horman <nhorman@tuxdriver.com>
      Reported-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
      CC: David Miller <davem@davemloft.net>
      Acked-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Cc: Ben Hutchings <ben@decadent.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2f89a7c
    • Neil Horman's avatar
      drop_monitor: fix sleeping in invalid context warning · 34c0bc42
      Neil Horman authored
      commit cde2e9a6 upstream.
      
      Eric Dumazet pointed out this warning in the drop_monitor protocol to me:
      
      [   38.352571] BUG: sleeping function called from invalid context at kernel/mutex.c:85
      [   38.352576] in_atomic(): 1, irqs_disabled(): 0, pid: 4415, name: dropwatch
      [   38.352580] Pid: 4415, comm: dropwatch Not tainted 3.4.0-rc2+ #71
      [   38.352582] Call Trace:
      [   38.352592]  [<ffffffff8153aaf0>] ? trace_napi_poll_hit+0xd0/0xd0
      [   38.352599]  [<ffffffff81063f2a>] __might_sleep+0xca/0xf0
      [   38.352606]  [<ffffffff81655b16>] mutex_lock+0x26/0x50
      [   38.352610]  [<ffffffff8153aaf0>] ? trace_napi_poll_hit+0xd0/0xd0
      [   38.352616]  [<ffffffff810b72d9>] tracepoint_probe_register+0x29/0x90
      [   38.352621]  [<ffffffff8153a585>] set_all_monitor_traces+0x105/0x170
      [   38.352625]  [<ffffffff8153a8ca>] net_dm_cmd_trace+0x2a/0x40
      [   38.352630]  [<ffffffff8154a81a>] genl_rcv_msg+0x21a/0x2b0
      [   38.352636]  [<ffffffff810f8029>] ? zone_statistics+0x99/0xc0
      [   38.352640]  [<ffffffff8154a600>] ? genl_rcv+0x30/0x30
      [   38.352645]  [<ffffffff8154a059>] netlink_rcv_skb+0xa9/0xd0
      [   38.352649]  [<ffffffff8154a5f0>] genl_rcv+0x20/0x30
      [   38.352653]  [<ffffffff81549a7e>] netlink_unicast+0x1ae/0x1f0
      [   38.352658]  [<ffffffff81549d76>] netlink_sendmsg+0x2b6/0x310
      [   38.352663]  [<ffffffff8150824f>] sock_sendmsg+0x10f/0x130
      [   38.352668]  [<ffffffff8150abe0>] ? move_addr_to_kernel+0x60/0xb0
      [   38.352673]  [<ffffffff81515f04>] ? verify_iovec+0x64/0xe0
      [   38.352677]  [<ffffffff81509c46>] __sys_sendmsg+0x386/0x390
      [   38.352682]  [<ffffffff810ffaf9>] ? handle_mm_fault+0x139/0x210
      [   38.352687]  [<ffffffff8165b5bc>] ? do_page_fault+0x1ec/0x4f0
      [   38.352693]  [<ffffffff8106ba4d>] ? set_next_entity+0x9d/0xb0
      [   38.352699]  [<ffffffff81310b49>] ? tty_ldisc_deref+0x9/0x10
      [   38.352703]  [<ffffffff8106d363>] ? pick_next_task_fair+0x63/0x140
      [   38.352708]  [<ffffffff8150b8d4>] sys_sendmsg+0x44/0x80
      [   38.352713]  [<ffffffff8165f8e2>] system_call_fastpath+0x16/0x1b
      
      It stems from holding a spinlock (trace_state_lock) while attempting to register
      or unregister tracepoint hooks, making in_atomic() true in this context, leading
      to the warning when the tracepoint calls might_sleep() while its taking a mutex.
      Since we only use the trace_state_lock to prevent trace protocol state races, as
      well as hardware stat list updates on an rcu write side, we can just convert the
      spinlock to a mutex to avoid this problem.
      Signed-off-by: default avatarNeil Horman <nhorman@tuxdriver.com>
      Reported-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
      CC: David Miller <davem@davemloft.net>
      Acked-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Cc: Ben Hutchings <ben@decadent.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      34c0bc42
    • Jarod Wilson's avatar
      media: lirc_sir: make device registration work · ae04311e
      Jarod Wilson authored
      commit 4b71ca6b upstream.
      
      For one, the driver device pointer needs to be filled in, or the lirc core
      will refuse to load the driver. And we really need to wire up all the
      platform_device bits. This has been tested via the lirc sourceforge tree
      and verified to work, been sitting there for months, finally getting
      around to sending it. :\
      Signed-off-by: default avatarJarod Wilson <jarod@redhat.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
      CC: Josh Boyer <jwboyer@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ae04311e
    • Peter Zijlstra's avatar
      sched: Fix race in task_group() · 64ac72f8
      Peter Zijlstra authored
      commit 8323f26c upstream.
      
      Stefan reported a crash on a kernel before a3e5d109 ("sched:
      Don't call task_group() too many times in set_task_rq()"), he
      found the reason to be that the multiple task_group()
      invocations in set_task_rq() returned different values.
      
      Looking at all that I found a lack of serialization and plain
      wrong comments.
      
      The below tries to fix it using an extra pointer which is
      updated under the appropriate scheduler locks. Its not pretty,
      but I can't really see another way given how all the cgroup
      stuff works.
      Reported-and-tested-by: default avatarStefan Bader <stefan.bader@canonical.com>
      Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1340364965.18025.71.camel@twinsSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      64ac72f8
    • Thomas Renninger's avatar
      cpufreq / ACPI: Fix not loading acpi-cpufreq driver regression · cf0a7166
      Thomas Renninger authored
      commit c4686c71 upstream.
      
      Commit d640113f introduced a regression on SMP
      systems where the processor core with ACPI id zero is disabled
      (typically should be the case because of hyperthreading).
      The regression got spread through stable kernels.
      On 3.0.X it got introduced via 3.0.18.
      
      Such platforms may be rare, but do exist.
      Look out for a disabled processor with acpi_id 0 in dmesg:
      ACPI: LAPIC (acpi_id[0x00] lapic_id[0x10] disabled)
      
      This problem has been observed on a:
      HP Proliant BL280c G6 blade
      
      This patch restricts the introduced workaround to platforms
      with nr_cpu_ids <= 1.
      Signed-off-by: default avatarThomas Renninger <trenn@suse.de>
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cf0a7166
    • Daniel J Blueman's avatar
      libata: Prevent interface errors with Seagate FreeAgent GoFlex · 894682fd
      Daniel J Blueman authored
      commit c531077f upstream.
      
      When using my Seagate FreeAgent GoFlex eSATAp external disk enclosure,
      interface errors are always seen until 1.5Gbps is negotiated [1]. This
      occurs using any disk in the enclosure, and when the disk is connected
      directly with a generic passive eSATAp cable, we see stable 3Gbps
      operation as expected.
      
      Blacklist 3Gbps mode to avoid dataloss and the ~30s delay bus reset
      and renegotiation incurs.
      Signed-off-by: default avatarDaniel J Blueman <daniel@quora.org>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      894682fd
    • Weiping Pan's avatar
      rds: set correct msg_namelen · 25dee10e
      Weiping Pan authored
      commit 06b6a1cf upstream.
      
      Jay Fenlason (fenlason@redhat.com) found a bug,
      that recvfrom() on an RDS socket can return the contents of random kernel
      memory to userspace if it was called with a address length larger than
      sizeof(struct sockaddr_in).
      rds_recvmsg() also fails to set the addr_len paramater properly before
      returning, but that's just a bug.
      There are also a number of cases wher recvfrom() can return an entirely bogus
      address. Anything in rds_recvmsg() that returns a non-negative value but does
      not go through the "sin = (struct sockaddr_in *)msg->msg_name;" code path
      at the end of the while(1) loop will return up to 128 bytes of kernel memory
      to userspace.
      
      And I write two test programs to reproduce this bug, you will see that in
      rds_server, fromAddr will be overwritten and the following sock_fd will be
      destroyed.
      Yes, it is the programmer's fault to set msg_namelen incorrectly, but it is
      better to make the kernel copy the real length of address to user space in
      such case.
      
      How to run the test programs ?
      I test them on 32bit x86 system, 3.5.0-rc7.
      
      1 compile
      gcc -o rds_client rds_client.c
      gcc -o rds_server rds_server.c
      
      2 run ./rds_server on one console
      
      3 run ./rds_client on another console
      
      4 you will see something like:
      server is waiting to receive data...
      old socket fd=3
      server received data from client:data from client
      msg.msg_namelen=32
      new socket fd=-1067277685
      sendmsg()
      : Bad file descriptor
      
      /***************** rds_client.c ********************/
      
      int main(void)
      {
      	int sock_fd;
      	struct sockaddr_in serverAddr;
      	struct sockaddr_in toAddr;
      	char recvBuffer[128] = "data from client";
      	struct msghdr msg;
      	struct iovec iov;
      
      	sock_fd = socket(AF_RDS, SOCK_SEQPACKET, 0);
      	if (sock_fd < 0) {
      		perror("create socket error\n");
      		exit(1);
      	}
      
      	memset(&serverAddr, 0, sizeof(serverAddr));
      	serverAddr.sin_family = AF_INET;
      	serverAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
      	serverAddr.sin_port = htons(4001);
      
      	if (bind(sock_fd, (struct sockaddr*)&serverAddr, sizeof(serverAddr)) < 0) {
      		perror("bind() error\n");
      		close(sock_fd);
      		exit(1);
      	}
      
      	memset(&toAddr, 0, sizeof(toAddr));
      	toAddr.sin_family = AF_INET;
      	toAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
      	toAddr.sin_port = htons(4000);
      	msg.msg_name = &toAddr;
      	msg.msg_namelen = sizeof(toAddr);
      	msg.msg_iov = &iov;
      	msg.msg_iovlen = 1;
      	msg.msg_iov->iov_base = recvBuffer;
      	msg.msg_iov->iov_len = strlen(recvBuffer) + 1;
      	msg.msg_control = 0;
      	msg.msg_controllen = 0;
      	msg.msg_flags = 0;
      
      	if (sendmsg(sock_fd, &msg, 0) == -1) {
      		perror("sendto() error\n");
      		close(sock_fd);
      		exit(1);
      	}
      
      	printf("client send data:%s\n", recvBuffer);
      
      	memset(recvBuffer, '\0', 128);
      
      	msg.msg_name = &toAddr;
      	msg.msg_namelen = sizeof(toAddr);
      	msg.msg_iov = &iov;
      	msg.msg_iovlen = 1;
      	msg.msg_iov->iov_base = recvBuffer;
      	msg.msg_iov->iov_len = 128;
      	msg.msg_control = 0;
      	msg.msg_controllen = 0;
      	msg.msg_flags = 0;
      	if (recvmsg(sock_fd, &msg, 0) == -1) {
      		perror("recvmsg() error\n");
      		close(sock_fd);
      		exit(1);
      	}
      
      	printf("receive data from server:%s\n", recvBuffer);
      
      	close(sock_fd);
      
      	return 0;
      }
      
      /***************** rds_server.c ********************/
      
      int main(void)
      {
      	struct sockaddr_in fromAddr;
      	int sock_fd;
      	struct sockaddr_in serverAddr;
      	unsigned int addrLen;
      	char recvBuffer[128];
      	struct msghdr msg;
      	struct iovec iov;
      
      	sock_fd = socket(AF_RDS, SOCK_SEQPACKET, 0);
      	if(sock_fd < 0) {
      		perror("create socket error\n");
      		exit(0);
      	}
      
      	memset(&serverAddr, 0, sizeof(serverAddr));
      	serverAddr.sin_family = AF_INET;
      	serverAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
      	serverAddr.sin_port = htons(4000);
      	if (bind(sock_fd, (struct sockaddr*)&serverAddr, sizeof(serverAddr)) < 0) {
      		perror("bind error\n");
      		close(sock_fd);
      		exit(1);
      	}
      
      	printf("server is waiting to receive data...\n");
      	msg.msg_name = &fromAddr;
      
      	/*
      	 * I add 16 to sizeof(fromAddr), ie 32,
      	 * and pay attention to the definition of fromAddr,
      	 * recvmsg() will overwrite sock_fd,
      	 * since kernel will copy 32 bytes to userspace.
      	 *
      	 * If you just use sizeof(fromAddr), it works fine.
      	 * */
      	msg.msg_namelen = sizeof(fromAddr) + 16;
      	/* msg.msg_namelen = sizeof(fromAddr); */
      	msg.msg_iov = &iov;
      	msg.msg_iovlen = 1;
      	msg.msg_iov->iov_base = recvBuffer;
      	msg.msg_iov->iov_len = 128;
      	msg.msg_control = 0;
      	msg.msg_controllen = 0;
      	msg.msg_flags = 0;
      
      	while (1) {
      		printf("old socket fd=%d\n", sock_fd);
      		if (recvmsg(sock_fd, &msg, 0) == -1) {
      			perror("recvmsg() error\n");
      			close(sock_fd);
      			exit(1);
      		}
      		printf("server received data from client:%s\n", recvBuffer);
      		printf("msg.msg_namelen=%d\n", msg.msg_namelen);
      		printf("new socket fd=%d\n", sock_fd);
      		strcat(recvBuffer, "--data from server");
      		if (sendmsg(sock_fd, &msg, 0) == -1) {
      			perror("sendmsg()\n");
      			close(sock_fd);
      			exit(1);
      		}
      	}
      
      	close(sock_fd);
      	return 0;
      }
      Signed-off-by: default avatarWeiping Pan <wpan@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      25dee10e