1. 20 Mar, 2013 40 commits
    • Guo Chao's avatar
      loopdev: fix a deadlock · 54d75ff2
      Guo Chao authored
      commit 5370019d upstream.
      
      bd_mutex and lo_ctl_mutex can be held in different order.
      
      Path #1:
      
      blkdev_open
       blkdev_get
        __blkdev_get (hold bd_mutex)
         lo_open (hold lo_ctl_mutex)
      
      Path #2:
      
      blkdev_ioctl
       lo_ioctl (hold lo_ctl_mutex)
        lo_set_capacity (hold bd_mutex)
      
      Lockdep does not report it, because path #2 actually holds a subclass of
      lo_ctl_mutex.  This subclass seems creep into the code by mistake.  The
      patch author actually just mentioned it in the changelog, see commit
      f028f3b2 ("loop: fix circular locking in loop_clr_fd()"), also see:
      
      	http://marc.info/?l=linux-kernel&m=123806169129727&w=2
      
      Path #2 hold bd_mutex to call bd_set_size(), I've protected it
      with i_mutex in a previous patch, so drop bd_mutex at this site.
      Signed-off-by: default avatarGuo Chao <yan@linux.vnet.ibm.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Guo Chao <yan@linux.vnet.ibm.com>
      Cc: M. Hindess <hindessm@uk.ibm.com>
      Cc: Nikanth Karthikesan <knikanth@suse.de>
      Cc: Jens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      54d75ff2
    • Guo Chao's avatar
      block: use i_size_write() in bd_set_size() · c1a782a5
      Guo Chao authored
      commit d646a02a upstream.
      
      blkdev_ioctl(GETBLKSIZE) uses i_size_read() to read size of block device.
      If we update block size directly, reader may see intermediate result in
      some machines and configurations.  Use i_size_write() instead.
      Signed-off-by: default avatarGuo Chao <yan@linux.vnet.ibm.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Guo Chao <yan@linux.vnet.ibm.com>
      Cc: M. Hindess <hindessm@uk.ibm.com>
      Cc: Nikanth Karthikesan <knikanth@suse.de>
      Cc: Jens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      c1a782a5
    • Laszlo Ersek's avatar
      xen-netfront: delay gARP until backend switches to Connected · 29db446a
      Laszlo Ersek authored
      commit 08e34eb1 upstream.
      
      After a guest is live migrated, the xen-netfront driver emits a gratuitous
      ARP message, so that networking hardware on the target host's subnet can
      take notice, and public routing to the guest is re-established. However,
      if the packet appears on the backend interface before the backend is added
      to the target host's bridge, the packet is lost, and the migrated guest's
      peers become unable to talk to the guest.
      
      A sufficient two-parts condition to prevent the above is:
      
      (1) ensure that the backend only moves to Connected xenbus state after its
      hotplug scripts completed, ie. the netback interface got added to the
      bridge; and
      
      (2) ensure the frontend only queues the gARP when it sees the backend move
      to Connected.
      
      These two together provide complete ordering. Sub-condition (1) is already
      satisfied by commit f942dc25 in Linus' tree, based on commit
      6b0b80ca7165 from [1].
      
      In general, the full condition is sufficient, not necessary, because,
      according to [2], live migration has been working for a long time without
      satisfying sub-condition (2). However, after 6b0b80ca7165 was backported
      to the RHEL-5 host to ensure (1), (2) still proved necessary in the RHEL-6
      guest. This patch intends to provide (2) for upstream.
      
      The Reviewed-by line comes from [3].
      
      [1] git://xenbits.xen.org/people/ianc/linux-2.6.git#upstream/dom0/backend/netback-history
      [2] http://old-list-archives.xen.org/xen-devel/2011-06/msg01969.html
      [3] http://old-list-archives.xen.org/xen-devel/2011-07/msg00484.htmlSigned-off-by: default avatarLaszlo Ersek <lersek@redhat.com>
      Reviewed-by: default avatarIan Campbell <ian.campbell@citrix.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      29db446a
    • Jiang Liu's avatar
      mm/hotplug: correctly add new zone to all other nodes' zone lists · 1bdb24f5
      Jiang Liu authored
      commit 08dff7b7 upstream.
      
      When online_pages() is called to add new memory to an empty zone, it
      rebuilds all zone lists by calling build_all_zonelists().  But there's a
      bug which prevents the new zone to be added to other nodes' zone lists.
      
      online_pages() {
      	build_all_zonelists()
      	.....
      	node_set_state(zone_to_nid(zone), N_HIGH_MEMORY)
      }
      
      Here the node of the zone is put into N_HIGH_MEMORY state after calling
      build_all_zonelists(), but build_all_zonelists() only adds zones from
      nodes in N_HIGH_MEMORY state to the fallback zone lists.
      build_all_zonelists()
      
          ->__build_all_zonelists()
      	->build_zonelists()
      	    ->find_next_best_node()
      		->for_each_node_state(n, N_HIGH_MEMORY)
      
      So memory in the new zone will never be used by other nodes, and it may
      cause strange behavor when system is under memory pressure.  So put node
      into N_HIGH_MEMORY state before calling build_all_zonelists().
      Signed-off-by: default avatarJianguo Wu <wujianguo@huawei.com>
      Signed-off-by: default avatarJiang Liu <liuj97@gmail.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Michal Hocko <mhocko@suse.cz>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Cc: Yinghai Lu <yinghai@kernel.org>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Keping Chen <chenkeping@huawei.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]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      1bdb24f5
    • Sven Eckelmann's avatar
      batman-adv: Only write requested number of byte to user buffer · f3fa0df5
      Sven Eckelmann authored
      commit b5a1eeef upstream.
      
      Don't write more than the requested number of bytes of an batman-adv icmp
      packet to the userspace buffer. Otherwise unrelated userspace memory might get
      overridden by the kernel.
      Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
      Signed-off-by: default avatarMarek Lindner <lindner_marek@yahoo.de>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      f3fa0df5
    • Paul Kot's avatar
      batman-adv: bat_socket_read missing checks · 83257435
      Paul Kot authored
      commit c00b6856 upstream.
      
      Writing a icmp_packet_rr and then reading icmp_packet can lead to kernel
      memory corruption, if __user *buf is just below TASK_SIZE.
      Signed-off-by: default avatarPaul Kot <pawlkt@gmail.com>
      [sven@narfation.org: made it checkpatch clean]
      Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
      Signed-off-by: default avatarMarek Lindner <lindner_marek@yahoo.de>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      83257435
    • Sarah Sharp's avatar
      USB: Fix connected device switch to Inactive state. · 0eb97065
      Sarah Sharp authored
      commit d3b9d7a9 upstream.
      
      A USB 3.0 device can transition to the Inactive state if a U1 or U2 exit
      transition fails.  The current code in hub_events simply issues a warm
      reset, but does not call any pre-reset or post-reset driver methods (or
      unbind/rebind drivers without them).  Therefore the drivers won't know
      their device has just been reset.
      
      hub_events should instead call usb_reset_device.  This means
      hub_port_reset now needs to figure out whether it should issue a warm
      reset or a hot reset.
      
      Remove the FIXME note about needing disconnect() for a NOTATTACHED
      device.  This patch fixes that.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      0eb97065
    • Sarah Sharp's avatar
      USB: Rip out recursive call on warm port reset. · 52cbf32a
      Sarah Sharp authored
      commit a24a6078 upstream.
      
      When a hot reset fails on a USB 3.0 port, the current port reset code
      recursively calls hub_port_reset inside hub_port_wait_reset.  This isn't
      ideal, since we should avoid recursive calls in the kernel, and it also
      doesn't allow us to issue multiple warm resets on reset failures.
      
      Rip out the recursive call.  Instead, add code to hub_port_reset to
      issue a warm reset if the hot reset fails, and try multiple warm resets
      before giving up on the port.
      
      In hub_port_wait_reset, remove the recursive call and re-indent.  The
      code is basically the same, except:
      
      1. It bails out early if the port has transitioned to Inactive or
      Compliance Mode after the reset completed.
      
      2. It doesn't consider a connect status change to be a failed reset.  If
      multiple warm resets needed to be issued, the connect status may have
      changed, so we need to ignore that and look at the port link state
      instead.  hub_port_reset will now do that.
      
      3. It unconditionally sets udev->speed on all types of successful
      resets.  The old recursive code would set the port speed when the second
      hub_port_reset returned.
      
      The old code did not handle connected devices needing a warm reset well.
      There were only two situations that the old code handled correctly: an
      empty port needing a warm reset, and a hot reset that migrated to a warm
      reset.
      
      When an empty port needed a warm reset, hub_port_reset was called with
      the warm variable set.  The code in hub_port_finish_reset would skip
      telling the USB core and the xHC host that the device was reset, because
      otherwise that would result in a NULL pointer dereference.
      
      When a USB 3.0 device reset migrated to a warm reset, the recursive call
      made the call stack look like this:
      
      hub_port_reset(warm = false)
              hub_wait_port_reset(warm = false)
                      hub_port_reset(warm = true)
                              hub_wait_port_reset(warm = true)
                              hub_port_finish_reset(warm = true)
                              (return up the call stack to the first wait)
      
              hub_port_finish_reset(warm = false)
      
      The old code didn't want to notify the USB core or the xHC host of device reset
      twice, so it only did it in the second call to hub_port_finish_reset,
      when warm was set to false.  This was necessary because
      before patch two ("USB: Ignore xHCI Reset Device status."), the USB core
      would pay attention to the xHC Reset Device command error status, and
      the second call would always fail.
      
      Now that we no longer have the recursive call, and warm can change from
      false to true in hub_port_reset, we need to have hub_port_finish_reset
      unconditionally notify the USB core and the xHC of the device reset.
      
      In hub_port_finish_reset, unconditionally clear the connect status
      change (CSC) bit for USB 3.0 hubs when the port reset is done.  If we
      had to issue multiple warm resets for a device, that bit may have been
      set if the device went into SS.Inactive and then was successfully warm
      reset.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      52cbf32a
    • Sarah Sharp's avatar
      USB: Prepare for refactoring by adding extra udev checks. · 5bd7c59c
      Sarah Sharp authored
      commit 2d4fa940 upstream.
      
      The next patch will refactor the hub port code to rip out the recursive
      call to hub_port_reset on a failed hot reset.  In preparation for that,
      make sure all code paths can deal with being called with a NULL udev.
      The usb_device will not be valid if warm reset was issued because a port
      transitioned to the Inactive or Compliance Mode on a device connect.
      
      This patch should have no effect on current behavior.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      5bd7c59c
    • Sarah Sharp's avatar
      USB: Don't use EHCI port sempahore for USB 3.0 hubs. · 541f862e
      Sarah Sharp authored
      commit 0fe51aa5 upstream.
      
      The EHCI host controller needs to prevent EHCI initialization when the
      UHCI or OHCI companion controller is in the middle of a port reset.  It
      uses ehci_cf_port_reset_rwsem to do this.  USB 3.0 hubs can't be under
      an EHCI host controller, so it makes no sense to down the semaphore for
      USB 3.0 hubs.  It also makes the warm port reset code more complex.
      
      Don't down ehci_cf_port_reset_rwsem for USB 3.0 hubs.
      Signed-off-by: default avatarSarah Sharp <sarah.a.sharp@linux.intel.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      541f862e
    • Mathieu Desnoyers's avatar
      Fix: compat_rw_copy_check_uvector() misuse in aio, readv, writev, and security keys · d9737ff1
      Mathieu Desnoyers authored
      commit 8aec0f5d upstream.
      
      Looking at mm/process_vm_access.c:process_vm_rw() and comparing it to
      compat_process_vm_rw() shows that the compatibility code requires an
      explicit "access_ok()" check before calling
      compat_rw_copy_check_uvector(). The same difference seems to appear when
      we compare fs/read_write.c:do_readv_writev() to
      fs/compat.c:compat_do_readv_writev().
      
      This subtle difference between the compat and non-compat requirements
      should probably be debated, as it seems to be error-prone. In fact,
      there are two others sites that use this function in the Linux kernel,
      and they both seem to get it wrong:
      
      Now shifting our attention to fs/aio.c, we see that aio_setup_iocb()
      also ends up calling compat_rw_copy_check_uvector() through
      aio_setup_vectored_rw(). Unfortunately, the access_ok() check appears to
      be missing. Same situation for
      security/keys/compat.c:compat_keyctl_instantiate_key_iov().
      
      I propose that we add the access_ok() check directly into
      compat_rw_copy_check_uvector(), so callers don't have to worry about it,
      and it therefore makes the compat call code similar to its non-compat
      counterpart. Place the access_ok() check in the same location where
      copy_from_user() can trigger a -EFAULT error in the non-compat code, so
      the ABI behaviors are alike on both compat and non-compat.
      
      While we are here, fix compat_do_readv_writev() so it checks for
      compat_rw_copy_check_uvector() negative return values.
      
      And also, fix a memory leak in compat_keyctl_instantiate_key_iov() error
      handling.
      Acked-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Acked-by: default avatarAl Viro <viro@ZenIV.linux.org.uk>
      Signed-off-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      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>
      d9737ff1
    • Mathias Krause's avatar
      crypto: user - fix info leaks in report API · f56cb892
      Mathias Krause authored
      commit 9a5467bf upstream.
      
      Three errors resulting in kernel memory disclosure:
      
      1/ The structures used for the netlink based crypto algorithm report API
      are located on the stack. As snprintf() does not fill the remainder of
      the buffer with null bytes, those stack bytes will be disclosed to users
      of the API. Switch to strncpy() to fix this.
      
      2/ crypto_report_one() does not initialize all field of struct
      crypto_user_alg. Fix this to fix the heap info leak.
      
      3/ For the module name we should copy only as many bytes as
      module_name() returns -- not as much as the destination buffer could
      hold. But the current code does not and therefore copies random data
      from behind the end of the module name, as the module name is always
      shorter than CRYPTO_MAX_ALG_NAME.
      
      Also switch to use strncpy() to copy the algorithm's name and
      driver_name. They are strings, after all.
      Signed-off-by: default avatarMathias Krause <minipli@googlemail.com>
      Cc: Steffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      [bwh: Backported to 3.2: adjust context]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      f56cb892
    • Guenter Roeck's avatar
      hwmon: (pmbus/ltc2978) Fix temperature reporting · a5f562fe
      Guenter Roeck authored
      commit 8c958c70 upstream.
      
      On LTC2978, only READ_TEMPERATURE is supported. It reports
      the internal junction temperature. This register is unpaged.
      
      On LTC3880, READ_TEMPERATURE and READ_TEMPERATURE2 are supported.
      READ_TEMPERATURE is paged and reports external temperatures.
      READ_TEMPERATURE2 is unpaged and reports the internal junction
      temperature.
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Acked-by: default avatarJean Delvare <khali@linux-fr.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      a5f562fe
    • Axel Lin's avatar
    • Kees Cook's avatar
      signal: always clear sa_restorer on execve · 125664f0
      Kees Cook authored
      commit 2ca39528 upstream.
      
      When the new signal handlers are set up, the location of sa_restorer is
      not cleared, leaking a parent process's address space location to
      children.  This allows for a potential bypass of the parent's ASLR by
      examining the sa_restorer value returned when calling sigaction().
      
      Based on what should be considered "secret" about addresses, it only
      matters across the exec not the fork (since the VMAs haven't changed
      until the exec).  But since exec sets SIG_DFL and keeps sa_restorer,
      this is where it should be fixed.
      
      Given the few uses of sa_restorer, a "set" function was not written
      since this would be the only use.  Instead, we use
      __ARCH_HAS_SA_RESTORER, as already done in other places.
      
      Example of the leak before applying this patch:
      
        $ cat /proc/$$/maps
        ...
        7fb9f3083000-7fb9f3238000 r-xp 00000000 fd:01 404469 .../libc-2.15.so
        ...
        $ ./leak
        ...
        7f278bc74000-7f278be29000 r-xp 00000000 fd:01 404469 .../libc-2.15.so
        ...
        1 0 (nil) 0x7fb9f30b94a0
        2 4000000 (nil) 0x7f278bcaa4a0
        3 4000000 (nil) 0x7f278bcaa4a0
        4 0 (nil) 0x7fb9f30b94a0
        ...
      
      [akpm@linux-foundation.org: use SA_RESTORER for backportability]
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Reported-by: default avatarEmese Revfy <re.emese@gmail.com>
      Cc: Emese Revfy <re.emese@gmail.com>
      Cc: PaX Team <pageexec@freemail.hu>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Serge Hallyn <serge.hallyn@canonical.com>
      Cc: Julien Tinnes <jln@google.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>
      125664f0
    • Oliver Neukum's avatar
      USB: cdc-wdm: fix buffer overflow · 8e535446
      Oliver Neukum authored
      commit c0f5ecee upstream.
      
      The buffer for responses must not overflow.
      If this would happen, set a flag, drop the data and return
      an error after user space has read all remaining data.
      Signed-off-by: default avatarOliver Neukum <oliver@neukum.org>
      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>
      8e535446
    • Marcin Jurkowski's avatar
      w1: fix oops when w1_search is called from netlink connector · cd144405
      Marcin Jurkowski authored
      commit 9d1817ca upstream.
      
      On Sat, Mar 02, 2013 at 10:45:10AM +0100, Sven Geggus wrote:
      > This is the bad commit I found doing git bisect:
      > 04f482fa is the first bad commit
      > commit 04f482fa
      > Author: Patrick McHardy <kaber@trash.net>
      > Date:   Mon Mar 28 08:39:36 2011 +0000
      
      Good job. I was too lazy to bisect for bad commit;)
      
      Reading the code I found problematic kthread_should_stop call from netlink
      connector which causes the oops. After applying a patch, I've been testing
      owfs+w1 setup for nearly two days and it seems to work very reliable (no
      hangs, no memleaks etc).
      More detailed description and possible fix is given below:
      
      Function w1_search can be called from either kthread or netlink callback.
      While the former works fine, the latter causes oops due to kthread_should_stop
      invocation.
      
      This patch adds a check if w1_search is serving netlink command, skipping
      kthread_should_stop invocation if so.
      Signed-off-by: default avatarMarcin Jurkowski <marcin1j@gmail.com>
      Acked-by: default avatarEvgeniy Polyakov <zbr@ioremap.net>
      Cc: Josh Boyer <jwboyer@gmail.com>
      Tested-by: default avatarSven Geggus <lists@fuchsschwanzdomain.de>
      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>
      cd144405
    • Steve Conklin's avatar
      usb: serial: Add Rigblaster Advantage to device table · 0c0e3753
      Steve Conklin authored
      commit a57e82a1 upstream.
      
      The Rigblaster Advantage is an amateur radio interface sold by West Mountain
      Radio. It contains a cp210x serial interface but the device ID is not in
      the driver.
      Signed-off-by: default avatarSteve Conklin <sconklin@canonical.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      0c0e3753
    • Paul Bolle's avatar
      tty: serial: fix typo "ARCH_S5P6450" · 88ef1234
      Paul Bolle authored
      commit 827aa0d3 upstream.
      
      This could have been either ARCH_S5P64X0 or CPU_S5P6450. Looking at
      commit 2555e663 ("ARM: S5P64X0: Add UART
      serial support for S5P6450") - which added this typo - makes clear this
      should be CPU_S5P6450.
      Signed-off-by: default avatarPaul Bolle <pebolle@tiscali.nl>
      Acked-by: default avatarKukjin Kim <kgene.kim@samsung.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>
      88ef1234
    • Wang YanQing's avatar
      serial: 8250_pci: add support for another kind of NetMos Technology PCI 9835 Multi-I/O Controller · 80d17151
      Wang YanQing authored
      commit 8d2f8cd4 upstream.
      
      01:08.0 Communication controller: NetMos Technology PCI 9835 Multi-I/O Controller (rev 01)
      	Subsystem: Device [1000:0012]
      	Control: I/O+ Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
      	Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
      	Interrupt: pin A routed to IRQ 20
      	Region 0: I/O ports at e050 [size=8]
      	Region 1: I/O ports at e040 [size=8]
      	Region 2: I/O ports at e030 [size=8]
      	Region 3: I/O ports at e020 [size=8]
      	Region 4: I/O ports at e010 [size=8]
      	Region 5: I/O ports at e000 [size=16]
      Signed-off-by: default avatarWang YanQing <udknight@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      [bwh: Backported to 3.2: adjust filename]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      80d17151
    • Scott Ashcroft's avatar
      Fix 4 port and add support for 8 port 'Unknown' PCI serial port cards · 7b2f4ae4
      Scott Ashcroft authored
      commit d13402a4 upstream.
      
      I've managed to find an 8 port version of the card 4 port card which was discussed here:
      
      http://marc.info/?l=linux-serial&m=120760744205314&w=2
      
      Looking back at that thread there were two issues in the original patch.
      
      1) The I/O ports for the UARTs are within BAR2 not BAR0. This can been seen in the original post.
      2) A serial quirk isn't needed as these cards have no memory in BAR0 which makes pci_plx9050_init just return.
      
      This patch fixes the 4 port support to use BAR2, removes the bogus quirk and adds support for the 8 port card.
      
      $ lspci -vvv -n -s 00:08.0
      00:08.0 0780: 10b5:9050 (rev 01)
      	Subsystem: 10b5:1588
      	Control: I/O+ Mem- BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
      	Status: Cap+ 66MHz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
      	Interrupt: pin A routed to IRQ 17
      	Region 1: I/O ports at ff00 [size=128]
      	Region 2: I/O ports at fe00 [size=64]
      	Region 3: I/O ports at fd00 [size=8]
      	Capabilities: <access denied>
      	Kernel driver in use: serial
      
      $ dmesg | grep 0000:00:08.0:
      [    0.083320] pci 0000:00:08.0: [10b5:9050] type 0 class 0x000780
      [    0.083355] pci 0000:00:08.0: reg 14: [io  0xff00-0xff7f]
      [    0.083369] pci 0000:00:08.0: reg 18: [io  0xfe00-0xfe3f]
      [    0.083382] pci 0000:00:08.0: reg 1c: [io  0xfd00-0xfd07]
      [    0.083460] pci 0000:00:08.0: PME# supported from D0 D3hot
      [    1.212867] 0000:00:08.0: ttyS4 at I/O 0xfe00 (irq = 17) is a 16550A
      [    1.233073] 0000:00:08.0: ttyS5 at I/O 0xfe08 (irq = 17) is a 16550A
      [    1.253270] 0000:00:08.0: ttyS6 at I/O 0xfe10 (irq = 17) is a 16550A
      [    1.273468] 0000:00:08.0: ttyS7 at I/O 0xfe18 (irq = 17) is a 16550A
      [    1.293666] 0000:00:08.0: ttyS8 at I/O 0xfe20 (irq = 17) is a 16550A
      [    1.313863] 0000:00:08.0: ttyS9 at I/O 0xfe28 (irq = 17) is a 16550A
      [    1.334061] 0000:00:08.0: ttyS10 at I/O 0xfe30 (irq = 17) is a 16550A
      [    1.354258] 0000:00:08.0: ttyS11 at I/O 0xfe38 (irq = 17) is a 16550A
      Signed-off-by: default avatarScott Ashcroft <scott.ashcroft@talk21.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      [bwh: Backported to 3.2: adjust filename, context]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      7b2f4ae4
    • Ley Foon Tan's avatar
      tty/serial: Add support for Altera serial port · 3aed3255
      Ley Foon Tan authored
      commit e06c93ca upstream.
      
      Add support for Altera 8250/16550 compatible serial port.
      Signed-off-by: default avatarLey Foon Tan <lftan@altera.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      [bwh: Backported to 3.2: adjust filenames, context]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      3aed3255
    • David Howells's avatar
      keys: fix race with concurrent install_user_keyrings() · c1dd1f57
      David Howells authored
      commit 0da9dfdd upstream.
      
      This fixes CVE-2013-1792.
      
      There is a race in install_user_keyrings() that can cause a NULL pointer
      dereference when called concurrently for the same user if the uid and
      uid-session keyrings are not yet created.  It might be possible for an
      unprivileged user to trigger this by calling keyctl() from userspace in
      parallel immediately after logging in.
      
      Assume that we have two threads both executing lookup_user_key(), both
      looking for KEY_SPEC_USER_SESSION_KEYRING.
      
      	THREAD A			THREAD B
      	===============================	===============================
      					==>call install_user_keyrings();
      	if (!cred->user->session_keyring)
      	==>call install_user_keyrings()
      					...
      					user->uid_keyring = uid_keyring;
      	if (user->uid_keyring)
      		return 0;
      	<==
      	key = cred->user->session_keyring [== NULL]
      					user->session_keyring = session_keyring;
      	atomic_inc(&key->usage); [oops]
      
      At the point thread A dereferences cred->user->session_keyring, thread B
      hasn't updated user->session_keyring yet, but thread A assumes it is
      populated because install_user_keyrings() returned ok.
      
      The race window is really small but can be exploited if, for example,
      thread B is interrupted or preempted after initializing uid_keyring, but
      before doing setting session_keyring.
      
      This couldn't be reproduced on a stock kernel.  However, after placing
      systemtap probe on 'user->session_keyring = session_keyring;' that
      introduced some delay, the kernel could be crashed reliably.
      
      Fix this by checking both pointers before deciding whether to return.
      Alternatively, the test could be done away with entirely as it is checked
      inside the mutex - but since the mutex is global, that may not be the best
      way.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Reported-by: default avatarMateusz Guzik <mguzik@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarJames Morris <james.l.morris@oracle.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      c1dd1f57
    • Lars-Peter Clausen's avatar
      ext3: Fix format string issues · 058f677c
      Lars-Peter Clausen authored
      commit 8d0c2d10 upstream.
      
      ext3_msg() takes the printk prefix as the second parameter and the
      format string as the third parameter. Two callers of ext3_msg omit the
      prefix and pass the format string as the second parameter and the first
      parameter to the format string as the third parameter. In both cases
      this string comes from an arbitrary source. Which means the string may
      contain format string characters, which will
      lead to undefined and potentially harmful behavior.
      
      The issue was introduced in commit 4cf46b67("ext3: Unify log messages
      in ext3") and is fixed by this patch.
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      058f677c
    • Dan Williams's avatar
      qcaux: add Franklin U600 · 0081426e
      Dan Williams authored
      commit 2d90e636 upstream.
      
      4 ports; AT/PPP is standard CDC-ACM.  The other three (added by this
      patch) are QCDM/DIAG, possibly GPS, and unknown.
      Signed-off-by: default avatarDan Williams <dcbw@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      0081426e
    • Malcolm Priestley's avatar
      staging: vt6656: Fix oops on resume from suspend. · 847beac7
      Malcolm Priestley authored
      commit 6987a6da upstream.
      
      Remove usb_put_dev from vt6656_suspend and usb_get_dev
      from vt6566_resume.
      
      These are not normally in suspend/resume functions.
      Signed-off-by: default avatarMalcolm Priestley <tvboxspy@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      847beac7
    • Matwey V. Kornilov's avatar
      usb: cp210x new Vendor/Device IDs · a4e0e072
      Matwey V. Kornilov authored
      commit be3101c2 upstream.
      
      This patch adds support for the Lake Shore Cryotronics devices to
      the CP210x driver.
      
      These lines are ported from cp210x driver distributed by Lake Shore web site:
         http://www.lakeshore.com/Documents/Lake%20Shore%20cp210x-3.0.0.tar.gz
      and licensed under the terms of GPLv2.
      
      Moreover, I've tested this changes with Lake Shore 335 in my labs.
      Signed-off-by: default avatarMatwey V. Kornilov <matwey@sai.msu.ru>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      a4e0e072
    • Takashi Iwai's avatar
      ALSA: seq: Fix missing error handling in snd_seq_timer_open() · 276f1b19
      Takashi Iwai authored
      commit 66efdc71 upstream.
      
      snd_seq_timer_open() didn't catch the whole error path but let through
      if the timer id is a slave.  This may lead to Oops by accessing the
      uninitialized pointer.
      
       BUG: unable to handle kernel NULL pointer dereference at 00000000000002ae
       IP: [<ffffffff819b3477>] snd_seq_timer_open+0xe7/0x130
       PGD 785cd067 PUD 76964067 PMD 0
       Oops: 0002 [#4] SMP
       CPU 0
       Pid: 4288, comm: trinity-child7 Tainted: G      D W 3.9.0-rc1+ #100 Bochs Bochs
       RIP: 0010:[<ffffffff819b3477>]  [<ffffffff819b3477>] snd_seq_timer_open+0xe7/0x130
       RSP: 0018:ffff88006ece7d38  EFLAGS: 00010246
       RAX: 0000000000000286 RBX: ffff88007851b400 RCX: 0000000000000000
       RDX: 000000000000ffff RSI: ffff88006ece7d58 RDI: ffff88006ece7d38
       RBP: ffff88006ece7d98 R08: 000000000000000a R09: 000000000000fffe
       R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
       R13: ffff8800792c5400 R14: 0000000000e8f000 R15: 0000000000000007
       FS:  00007f7aaa650700(0000) GS:ffff88007f800000(0000) GS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
       CR2: 00000000000002ae CR3: 000000006efec000 CR4: 00000000000006f0
       DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
       DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
       Process trinity-child7 (pid: 4288, threadinfo ffff88006ece6000, task ffff880076a8a290)
       Stack:
        0000000000000286 ffffffff828f2be0 ffff88006ece7d58 ffffffff810f354d
        65636e6575716573 2065756575712072 ffff8800792c0030 0000000000000000
        ffff88006ece7d98 ffff8800792c5400 ffff88007851b400 ffff8800792c5520
       Call Trace:
        [<ffffffff810f354d>] ? trace_hardirqs_on+0xd/0x10
        [<ffffffff819b17e9>] snd_seq_queue_timer_open+0x29/0x70
        [<ffffffff819ae01a>] snd_seq_ioctl_set_queue_timer+0xda/0x120
        [<ffffffff819acb9b>] snd_seq_do_ioctl+0x9b/0xd0
        [<ffffffff819acbe0>] snd_seq_ioctl+0x10/0x20
        [<ffffffff811b9542>] do_vfs_ioctl+0x522/0x570
        [<ffffffff8130a4b3>] ? file_has_perm+0x83/0xa0
        [<ffffffff810f354d>] ? trace_hardirqs_on+0xd/0x10
        [<ffffffff811b95ed>] sys_ioctl+0x5d/0xa0
        [<ffffffff813663fe>] ? trace_hardirqs_on_thunk+0x3a/0x3f
        [<ffffffff81faed69>] system_call_fastpath+0x16/0x1b
      Reported-and-tested-by: default avatarTommi Rantala <tt.rantala@gmail.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      276f1b19
    • Amit Shah's avatar
      virtio: rng: disallow multiple device registrations, fixes crashes · e9a1e5cd
      Amit Shah authored
      commit e84e7a56 upstream.
      
      The code currently only supports one virtio-rng device at a time.
      Invoking guests with multiple devices causes the guest to blow up.
      
      Check if we've already registered and initialised the driver.  Also
      cleanup in case of registration errors or hot-unplug so that a new
      device can be used.
      Reported-by: default avatarPeter Krempa <pkrempa@redhat.com>
      Reported-by: <yunzheng@redhat.com>
      Signed-off-by: default avatarAmit Shah <amit.shah@redhat.com>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      e9a1e5cd
    • Konstantin Khlebnikov's avatar
      e1000e: fix pci-device enable-counter balance · e4922fdd
      Konstantin Khlebnikov authored
      commit 4e0855df upstream.
      
      This patch removes redundant and unbalanced pci_disable_device() from
      __e1000_shutdown(). pci_clear_master() is enough, device can go into
      suspended state with elevated enable_cnt.
      
      Bug was introduced in commit 23606cf5
      ("e1000e / PCI / PM: Add basic runtime PM support (rev. 4)") in v2.6.35
      
      Cc: Bruce Allan <bruce.w.allan@intel.com>
      Signed-off-by: default avatarKonstantin Khlebnikov <khlebnikov@openvz.org>
      Acked-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: default avatarBorislav Petkov <bp@suse.de>
      Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      e4922fdd
    • Christian Schmiedl's avatar
      USB: added support for Cinterion's products AH6 and PLS8 · 5369b4e3
      Christian Schmiedl authored
      commit 1941138e upstream.
      
      add support for Cinterion's products AH6 and PLS8 by adding Product IDs
      and USB_DEVICE tuples.
      Signed-off-by: default avatarChristian Schmiedl <christian.schmiedl@gemalto.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      5369b4e3
    • Bjørn Mork's avatar
      USB: storage: fix Huawei mode switching regression · 8bcbe613
      Bjørn Mork authored
      commit ab4b7164 upstream.
      
      This reverts commit 200e0d99 ("USB: storage: optimize to match the
      Huawei USB storage devices and support new switch command" and the
      followup bugfix commit cd060956 ("USB: storage: properly handle
      the endian issues of idProduct").
      
      The commit effectively added a large number of Huawei devices to
      the deprecated usb-storage mode switching logic.  Many of these
      devices have been in use and supported by the userspace
      usb_modeswitch utility for years.  Forcing the switching inside
      the kernel causes a number of regressions as a result of ignoring
      existing onfigurations, and also completely takes away the ability
      to configure mode switching per device/system/user.
      
      Known regressions caused by this:
       - Some of the devices support multiple modes, using different
        switching commands.  There are existing configurations taking
        advantage of this.
      
       - There is a real use case for disabling mode switching and
        instead mounting the exposed storage device. This becomes
        impossible with switching logic inside the usb-storage driver.
      
       - At least on device fail as a result of the usb-storage switching
        command, becoming completely unswitchable. This is possibly a
        firmware bug, but still a regression because the device work as
        expected using usb_modeswitch defaults.
      
      In-kernel mode switching was deprecated years ago with the
      development of the more user friendly userspace alternatives. The
      existing list of devices in usb-storage was only kept to prevent
      breaking already working systems.  The long term plan is to remove
      the list, not to add to it. Ref:
      http://permalink.gmane.org/gmane.linux.usb.general/28543
      
      Cc: <fangxiaozhi@huawei.com>
      Signed-off-by: default avatarBjørn Mork <bjorn@mork.no>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      8bcbe613
    • Bjørn Mork's avatar
      USB: option: add Huawei E5331 · 25648934
      Bjørn Mork authored
      commit daec90e7 upstream.
      
      Another device using CDC ACM with vendor specific protocol to mark
      serial functions.
      Signed-off-by: default avatarBjørn Mork <bjorn@mork.no>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      25648934
    • Konrad Rzeszutek Wilk's avatar
      xen/pciback: Don't disable a PCI device that is already disabled. · 7eb2731c
      Konrad Rzeszutek Wilk authored
      commit bdc5c181 upstream.
      
      While shuting down a HVM guest with pci devices passed through we
      get this:
      
      pciback 0000:04:00.0: restoring config space at offset 0x4 (was 0x100000, writing 0x100002)
      ------------[ cut here ]------------
      WARNING: at drivers/pci/pci.c:1397 pci_disable_device+0x88/0xa0()
      Hardware name: MS-7640
      Device pciback
      disabling already-disabled device
      Modules linked in:
      Pid: 53, comm: xenwatch Not tainted 3.9.0-rc1-20130304a+ #1
      Call Trace:
       [<ffffffff8106994a>] warn_slowpath_common+0x7a/0xc0
       [<ffffffff81069a31>] warn_slowpath_fmt+0x41/0x50
       [<ffffffff813cf288>] pci_disable_device+0x88/0xa0
       [<ffffffff814554a7>] xen_pcibk_reset_device+0x37/0xd0
       [<ffffffff81454b6f>] ? pcistub_put_pci_dev+0x6f/0x120
       [<ffffffff81454b8d>] pcistub_put_pci_dev+0x8d/0x120
       [<ffffffff814582a9>] __xen_pcibk_release_devices+0x59/0xa0
      
      This fixes the bug.
      Reported-and-Tested-by: default avatarSander Eikelenboom <linux@eikelenboom.it>
      Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      7eb2731c
    • Al Viro's avatar
      vfs: fix pipe counter breakage · 0edb34d8
      Al Viro authored
      commit a930d879 upstream.
      
      If you open a pipe for neither read nor write, the pipe code will not
      add any usage counters to the pipe, causing the 'struct pipe_inode_info"
      to be potentially released early.
      
      That doesn't normally matter, since you cannot actually use the pipe,
      but the pipe release code - particularly fasync handling - still expects
      the actual pipe infrastructure to all be there.  And rather than adding
      NULL pointer checks, let's just disallow this case, the same way we
      already do for the named pipe ("fifo") case.
      
      This is ancient going back to pre-2.4 days, and until trinity, nobody
      naver noticed.
      Reported-by: default avatarDave Jones <davej@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      0edb34d8
    • Tu, Xiaobing's avatar
      Fix memory leak in cpufreq stats. · 8885a539
      Tu, Xiaobing authored
      commit e3773677 upstream.
      
      When system enters sleep, non-boot CPUs will be disabled.
      Cpufreq stats sysfs is created when the CPU is up, but it is not
      freed when the CPU is going down. This will cause memory leak.
      Signed-off-by: default avatarxiaobing tu <xiaobing.tu@intel.com>
      Signed-off-by: default avatarguifang tang <guifang.tang@intel.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      8885a539
    • Eric W. Biederman's avatar
      decnet: Fix disappearing sysctl entries · 3125bdd6
      Eric W. Biederman authored
      When decnet is built as a module a simple:
      echo 0.0 >/proc/sys/net/decnet/node_address
      
      results in most of the sysctl entries under /proc/sys/net/decnet and
      /proc/sys/net/decnet/conf disappearing.
      
      For more details see http://www.spinics.net/lists/netdev/msg226123.html.
      
      This change applies the same workaround used in
      net/core/sysctl_net_core.c and net/ipv6/sysctl_net_ipv6.c of creating
      a skeleton of decnet sysctl entries before doing anything else.
      
      The problem first appeared in kernel 2.6.27.  The later rewrite of
      sysctl in kernel 3.4 restored the previous behavior and eliminated the
      need for this workaround.
      
      This patch was heavily inspired by a similar but more complex patch by
      Larry Baker.
      Reported-by: default avatarLarry Baker <baker@usgs.gov>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      3125bdd6
    • Steven Rostedt's avatar
      ftrace: Update the kconfig for DYNAMIC_FTRACE · 3ac94a54
      Steven Rostedt authored
      commit db05021d upstream.
      
      The prompt to enable DYNAMIC_FTRACE (the ability to nop and
      enable function tracing at run time) had a confusing statement:
      
       "enable/disable ftrace tracepoints dynamically"
      
      This was written before tracepoints were added to the kernel,
      but now that tracepoints have been added, this is very confusing
      and has confused people enough to give wrong information during
      presentations.
      
      Not only that, I looked at the help text, and it still references
      that dreaded daemon that use to wake up once a second to update
      the nop locations and brick NICs, that hasn't been around for over
      five years.
      
      Time to bring the text up to the current decade.
      Reported-by: default avatarEzequiel Garcia <elezegarcia@gmail.com>
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      3ac94a54
    • Josh Boyer's avatar
      efi: be more paranoid about available space when creating variables · 7feecf3f
      Josh Boyer authored
      commit 68d92986 upstream.
      
      UEFI variables are typically stored in flash. For various reasons, avaiable
      space is typically not reclaimed immediately upon the deletion of a
      variable - instead, the system will garbage collect during initialisation
      after a reboot.
      
      Some systems appear to handle this garbage collection extremely poorly,
      failing if more than 50% of the system flash is in use. This can result in
      the machine refusing to boot. The safest thing to do for the moment is to
      forbid writes if they'd end up using more than half of the storage space.
      We can make this more finegrained later if we come up with a method for
      identifying the broken machines.
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
      [bwh: Backported to 3.2:
       - Drop efivarfs changes and unused check_var_size()
       - Add error codes to include/linux/efi.h, added upstream by
         commit 5d9db883 ('efi: Add support for a UEFI variable filesystem')
       - Add efi_status_to_err(), added upstream by commit 7253eaba
         ('efivarfs: Return an error if we fail to read a variable')]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      7feecf3f
    • Josh Boyer's avatar
      efivars: Disable external interrupt while holding efivars->lock · 3b048fc1
      Josh Boyer authored
      commit 81fa4e58 upstream.
      
      [Problem]
      There is a scenario which efi_pstore fails to log messages in a panic case.
      
       - CPUA holds an efi_var->lock in either efivarfs parts
         or efi_pstore with interrupt enabled.
       - CPUB panics and sends IPI to CPUA in smp_send_stop().
       - CPUA stops with holding the lock.
       - CPUB kicks efi_pstore_write() via kmsg_dump(KSMG_DUMP_PANIC)
         but it returns without logging messages.
      
      [Patch Description]
      This patch disables an external interruption while holding efivars->lock
      as follows.
      
      In efi_pstore_write() and get_var_data(), spin_lock/spin_unlock is
      replaced by spin_lock_irqsave/spin_unlock_irqrestore because they may
      be called in an interrupt context.
      
      In other functions, they are replaced by spin_lock_irq/spin_unlock_irq.
      because they are all called from a process context.
      
      By applying this patch, we can avoid the problem above with
      a following senario.
      
       - CPUA holds an efi_var->lock with interrupt disabled.
       - CPUB panics and sends IPI to CPUA in smp_send_stop().
       - CPUA receives the IPI after releasing the lock because it is
         disabling interrupt while holding the lock.
       - CPUB waits for one sec until CPUA releases the lock.
       - CPUB kicks efi_pstore_write() via kmsg_dump(KSMG_DUMP_PANIC)
         And it can hold the lock successfully.
      Signed-off-by: default avatarSeiji Aguchi <seiji.aguchi@hds.com>
      Acked-by: default avatarMike Waychison <mikew@google.com>
      Acked-by: default avatarMatt Fleming <matt.fleming@intel.com>
      Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
      [bwh: Backported to 3.2:
       - Drop efivarfs changes
       - Adjust context
       - Drop change to efi_pstore_erase(), which is implemented using
         efi_pstore_write() here]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      3b048fc1