1. 16 Jul, 2014 40 commits
    • Alex Smith's avatar
      recordmcount/MIPS: Fix possible incorrect mcount_loc table entries in modules · daf05306
      Alex Smith authored
      commit 91ad11d7 upstream.
      
      On MIPS calls to _mcount in modules generate 2 instructions to load
      the _mcount address (and therefore 2 relocations). The mcount_loc
      table should only reference the first of these, so the second is
      filtered out by checking the relocation offset and ignoring ones that
      immediately follow the previous one seen.
      
      However if a module has an _mcount call at offset 0, the second
      relocation would not be filtered out due to old_r_offset == 0
      being taken to mean that the current relocation is the first one
      seen, and both would end up in the mcount_loc table.
      
      This results in ftrace_make_nop() patching both (adjacent)
      instructions to branches over the _mcount call sequence like so:
      
        0xffffffffc08a8000:  04 00 00 10     b       0xffffffffc08a8014
        0xffffffffc08a8004:  04 00 00 10     b       0xffffffffc08a8018
        0xffffffffc08a8008:  2d 08 e0 03     move    at,ra
        ...
      
      The second branch is in the delay slot of the first, which is
      defined to be unpredictable - on the platform on which this bug was
      encountered, it triggers a reserved instruction exception.
      
      Fix by initializing old_r_offset to ~0 and using that instead of 0
      to determine whether the current relocation is the first seen.
      Signed-off-by: default avatarAlex Smith <alex.smith@imgtec.com>
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/7098/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      daf05306
    • Takashi Iwai's avatar
      ALSA: usb-audio: Fix races at disconnection and PCM closing · 1cd17669
      Takashi Iwai authored
      commit 92a586bd upstream.
      
      When a USB-audio device is disconnected while PCM is still running, we
      still see some race: the disconnect callback calls
      snd_usb_endpoint_free() that calls release_urbs() and then kfree()
      while a PCM stream would be closed at the same time and calls
      stop_endpoints() that leads to wait_clear_urbs().  That is, the EP
      object might be deallocated while a PCM stream is syncing with
      wait_clear_urbs() with the same EP.
      
      Basically calling multiple wait_clear_urbs() would work fine, also
      calling wait_clear_urbs() and release_urbs() would work, too, as
      wait_clear_urbs() just reads some fields in ep.  The problem is the
      succeeding kfree() in snd_pcm_endpoint_free().
      
      This patch moves out the EP deallocation into the later point, the
      destructor callback.  At this stage, all PCMs must have been already
      closed, so it's safe to free the objects.
      Reported-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      1cd17669
    • Maxime Ripard's avatar
      net: allwinner: emac: Add missing free_irq · 2f06796a
      Maxime Ripard authored
      commit b9111328 upstream.
      
      If the mdio probe function fails in emac_open, the interrupt we just requested
      isn't freed. If emac_open is called again, for example because we try to set up
      the interface again, the kernel will oops because the interrupt wasn't properly
      released.
      Signed-off-by: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      2f06796a
    • Scott Wood's avatar
      powerpc: Don't skip ePAPR spin-table CPUs · 59a6c7b1
      Scott Wood authored
      commit 6663a4fa upstream.
      
      Commit 59a53afe "powerpc: Don't setup
      CPUs with bad status" broke ePAPR SMP booting.  ePAPR says that CPUs
      that aren't presently running shall have status of disabled, with
      enable-method being used to determine whether the CPU can be enabled.
      
      Fix by checking for spin-table, which is currently the only supported
      enable-method.
      Signed-off-by: default avatarScott Wood <scottwood@freescale.com>
      Cc: Michael Neuling <mikey@neuling.org>
      Cc: Emil Medve <Emilian.Medve@Freescale.com>
      Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      59a6c7b1
    • Scott Mayhew's avatar
      nfs: Fix cache_validity check in nfs_write_pageuptodate() · 22eb5097
      Scott Mayhew authored
      commit 18dd78c4 upstream.
      
      NFS_INO_INVALID_DATA cannot be ignored, even if we have a delegation.
      
      We're still having some problems with data corruption when multiple
      clients are appending to a file and those clients are being granted
      write delegations on open.
      
      To reproduce:
      
      Client A:
      vi /mnt/`hostname -s`
      while :; do echo "XXXXXXXXXXXXXXX" >>/mnt/file; sleep $(( $RANDOM % 5 )); done
      
      Client B:
      vi /mnt/`hostname -s`
      while :; do echo "YYYYYYYYYYYYYYY" >>/mnt/file; sleep $(( $RANDOM % 5 )); done
      
      What's happening is that in nfs_update_inode() we're recognizing that
      the file size has changed and we're setting NFS_INO_INVALID_DATA
      accordingly, but then we ignore the cache_validity flags in
      nfs_write_pageuptodate() because we have a delegation.  As a result,
      in nfs_updatepage() we're extending the write to cover the full page
      even though we've not read in the data to begin with.
      Signed-off-by: default avatarScott Mayhew <smayhew@redhat.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
      [ kamal: backport to 3.13-stable ]
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      22eb5097
    • Benjamin LaHaise's avatar
      aio: fix kernel memory disclosure in io_getevents() introduced in v3.10 · 65cc017e
      Benjamin LaHaise authored
      commit edfbbf38 upstream.
      
      A kernel memory disclosure was introduced in aio_read_events_ring() in v3.10
      by commit a31ad380.  The changes made to
      aio_read_events_ring() failed to correctly limit the index into
      ctx->ring_pages[], allowing an attacked to cause the subsequent kmap() of
      an arbitrary page with a copy_to_user() to copy the contents into userspace.
      This vulnerability has been assigned CVE-2014-0206.  Thanks to Mateusz and
      Petr for disclosing this issue.
      
      This patch applies to v3.12+.  A separate backport is needed for 3.10/3.11.
      Signed-off-by: default avatarBenjamin LaHaise <bcrl@kvack.org>
      Cc: Mateusz Guzik <mguzik@redhat.com>
      Cc: Petr Matousek <pmatouse@redhat.com>
      Cc: Kent Overstreet <kmo@daterainc.com>
      Cc: Jeff Moyer <jmoyer@redhat.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      65cc017e
    • Benjamin LaHaise's avatar
      aio: fix aio request leak when events are reaped by userspace · 78e79039
      Benjamin LaHaise authored
      commit f8567a38 upstream.
      
      The aio cleanups and optimizations by kmo that were merged into the 3.10
      tree added a regression for userspace event reaping.  Specifically, the
      reference counts are not decremented if the event is reaped in userspace,
      leading to the application being unable to submit further aio requests.
      This patch applies to 3.12+.  A separate backport is required for 3.10/3.11.
      This issue was uncovered as part of CVE-2014-0206.
      Signed-off-by: default avatarBenjamin LaHaise <bcrl@kvack.org>
      Cc: Kent Overstreet <kmo@daterainc.com>
      Cc: Mateusz Guzik <mguzik@redhat.com>
      Cc: Petr Matousek <pmatouse@redhat.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      78e79039
    • Steve French's avatar
      [CIFS] fix mount failure with broken pathnames when smb3 mount with mapchars option · edb83595
      Steve French authored
      commit ce36d9ab upstream.
      
      When we SMB3 mounted with mapchars (to allow reserved characters : \ / > < * ?
      via the Unicode Windows to POSIX remap range) empty paths
      (eg when we open "" to query the root of the SMB3 directory on mount) were not
      null terminated so we sent garbarge as a path name on empty paths which caused
      SMB2/SMB2.1/SMB3 mounts to fail when mapchars was specified.  mapchars is
      particularly important since Unix Extensions for SMB3 are not supported (yet)
      Signed-off-by: default avatarSteve French <smfrench@gmail.com>
      Reviewed-by: default avatarDavid Disseldorp <ddiss@suse.de>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      edb83595
    • Chris Wilson's avatar
      drm/i915: Hold the table lock whilst walking the file's idr and counting the objects in debugfs · 3e970038
      Chris Wilson authored
      commit 5b5ffff0 upstream.
      
      Fixes an issue whereby we may race with the table updates (before the
      core takes the struct_mutex) and so risk dereferencing a stale pointer in
      the iterator for /debugfs/.../i915_gem_objects. For example,
      
      [ 1524.757545] BUG: unable to handle kernel paging request at f53af748
      [ 1524.757572] IP: [<c1406982>] per_file_stats+0x12/0x100
      [ 1524.757599] *pdpt = 0000000001b13001 *pde = 00000000379fb067 *pte = 80000000353af060
      [ 1524.757621] Oops: 0000 [#1] SMP DEBUG_PAGEALLOC
      [ 1524.757637] Modules linked in: ctr ccm arc4 ath9k ath9k_common ath9k_hw ath snd_hda_codec_conexant mac80211 snd_hda_codec_generic snd_hda_intel snd_hda_controller snd_hda_codec bnep snd_hwdep rfcomm snd_pcm gpio_ich dell_wmi sparse_keymap snd_seq_midi hid_multitouch uvcvideo snd_seq_midi_event dell_laptop snd_rawmidi dcdbas snd_seq videobuf2_vmalloc videobuf2_memops videobuf2_core usbhid videodev snd_seq_device coretemp snd_timer hid joydev kvm_intel cfg80211 ath3k kvm btusb bluetooth serio_raw snd microcode soundcore lpc_ich wmi mac_hid parport_pc ppdev lp parport psmouse ahci libahci
      [ 1524.757825] CPU: 3 PID: 1911 Comm: intel-gpu-overl Tainted: G        W  OE 3.15.0-rc3+ #96
      [ 1524.757840] Hardware name: Dell Inc. Inspiron 1090/Inspiron 1090, BIOS A06 08/23/2011
      [ 1524.757855] task: f52f36c0 ti: f4cbc000 task.ti: f4cbc000
      [ 1524.757869] EIP: 0060:[<c1406982>] EFLAGS: 00210202 CPU: 3
      [ 1524.757884] EIP is at per_file_stats+0x12/0x100
      [ 1524.757896] EAX: 0000002d EBX: 00000000 ECX: f4cbdefc EDX: f53af700
      [ 1524.757909] ESI: c1406970 EDI: f53af700 EBP: f4cbde6c ESP: f4cbde5c
      [ 1524.757922]  DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
      [ 1524.757934] CR0: 80050033 CR2: f53af748 CR3: 356af000 CR4: 000007f0
      [ 1524.757945] Stack:
      [ 1524.757957]  f4cbdefc 00000000 c1406970 f53af700 f4cbdea8 c12e5f15 f4cbdefc c1406970
      [ 1524.757993]  0000ffff f4cbde90 0000002d f5dc5cd0 e4e80438 c1181d59 f4cbded8 f4d89900
      [ 1524.758027]  f5631b40 e5131074 c1903f37 f4cbdf28 c14068e6 f52648a0 c1927748 c1903f37
      [ 1524.758062] Call Trace:
      [ 1524.758084]  [<c1406970>] ? i915_gem_object_info+0x510/0x510
      [ 1524.758106]  [<c12e5f15>] idr_for_each+0xa5/0x100
      [ 1524.758126]  [<c1406970>] ? i915_gem_object_info+0x510/0x510
      [ 1524.758148]  [<c1181d59>] ? seq_vprintf+0x29/0x50
      [ 1524.758168]  [<c14068e6>] i915_gem_object_info+0x486/0x510
      [ 1524.758189]  [<c11823a6>] seq_read+0xd6/0x380
      [ 1524.758208]  [<c116d11d>] ? final_putname+0x1d/0x40
      [ 1524.758227]  [<c11822d0>] ? seq_hlist_next_percpu+0x90/0x90
      [ 1524.758246]  [<c1163e52>] vfs_read+0x82/0x150
      [ 1524.758265]  [<c11645d6>] SyS_read+0x46/0x90
      [ 1524.758285]  [<c16b8d8c>] sysenter_do_call+0x12/0x22
      [ 1524.758298] Code: f5 8f 2a 00 83 c4 6c 31 c0 5b 5e 5f 5d c3 8d 74 26 00 8d bc 27 00 00 00 00 55 89 e5 57 56 53 83 ec 04 3e 8d 74 26 00 83 41 04 01 <8b> 42 48 01 41 08 8b 42 4c 89 d7 85 c0 75 07 8b 42 60 85 c0 74
      [ 1524.758461] EIP: [<c1406982>] per_file_stats+0x12/0x100 SS:ESP 0068:f4cbde5c
      [ 1524.758485] CR2: 00000000f53af748
      Reported-by: default avatarSam Jansen <sam.jansen@starleaf.com>
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Cc: Sam Jansen <sam.jansen@starleaf.com>
      Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      3e970038
    • Hugh Dickins's avatar
      mm: fix crashes from mbind() merging vmas · 9192395d
      Hugh Dickins authored
      commit d05f0cdc upstream.
      
      In v2.6.34 commit 9d8cebd4 ("mm: fix mbind vma merge problem")
      introduced vma merging to mbind(), but it should have also changed the
      convention of passing start vma from queue_pages_range() (formerly
      check_range()) to new_vma_page(): vma merging may have already freed
      that structure, resulting in BUG at mm/mempolicy.c:1738 and probably
      worse crashes.
      
      Fixes: 9d8cebd4 ("mm: fix mbind vma merge problem")
      Reported-by: default avatarNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>
      Tested-by: default avatarNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>
      Signed-off-by: default avatarHugh Dickins <hughd@google.com>
      Acked-by: default avatarChristoph Lameter <cl@linux.com>
      Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Cc: Minchan Kim <minchan.kim@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      [ kamal: backport to 3.13-stable: context ]
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      9192395d
    • Joonsoo Kim's avatar
      DMA, CMA: fix possible memory leak · 70994ab8
      Joonsoo Kim authored
      commit fe8eea4f upstream.
      
      We should free memory for bitmap when we find zone mismatch, otherwise
      this memory will leak.
      
      Additionally, I copy code comment from PPC KVM's CMA code to inform why
      we need to check zone mis-match.
      Signed-off-by: default avatarJoonsoo Kim <iamjoonsoo.kim@lge.com>
      Acked-by: default avatarZhang Yanfei <zhangyanfei@cn.fujitsu.com>
      Reviewed-by: default avatarMichal Nazarewicz <mina86@mina86.com>
      Reviewed-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Acked-by: default avatarMinchan Kim <minchan@kernel.org>
      Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
      Cc: Marek Szyprowski <m.szyprowski@samsung.com>
      Cc: Michal Nazarewicz <mina86@mina86.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Gleb Natapov <gleb@kernel.org>
      Cc: Alexander Graf <agraf@suse.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      70994ab8
    • David Rientjes's avatar
      mm, pcp: allow restoring percpu_pagelist_fraction default · 91b79d41
      David Rientjes authored
      commit 7cd2b0a3 upstream.
      
      Oleg reports a division by zero error on zero-length write() to the
      percpu_pagelist_fraction sysctl:
      
          divide error: 0000 [#1] SMP DEBUG_PAGEALLOC
          CPU: 1 PID: 9142 Comm: badarea_io Not tainted 3.15.0-rc2-vm-nfs+ #19
          Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
          task: ffff8800d5aeb6e0 ti: ffff8800d87a2000 task.ti: ffff8800d87a2000
          RIP: 0010: percpu_pagelist_fraction_sysctl_handler+0x84/0x120
          RSP: 0018:ffff8800d87a3e78  EFLAGS: 00010246
          RAX: 0000000000000f89 RBX: ffff88011f7fd000 RCX: 0000000000000000
          RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000010
          RBP: ffff8800d87a3e98 R08: ffffffff81d002c8 R09: ffff8800d87a3f50
          R10: 000000000000000b R11: 0000000000000246 R12: 0000000000000060
          R13: ffffffff81c3c3e0 R14: ffffffff81cfddf8 R15: ffff8801193b0800
          FS:  00007f614f1e9740(0000) GS:ffff88011f440000(0000) knlGS:0000000000000000
          CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
          CR2: 00007f614f1fa000 CR3: 00000000d9291000 CR4: 00000000000006e0
          Call Trace:
            proc_sys_call_handler+0xb3/0xc0
            proc_sys_write+0x14/0x20
            vfs_write+0xba/0x1e0
            SyS_write+0x46/0xb0
            tracesys+0xe1/0xe6
      
      However, if the percpu_pagelist_fraction sysctl is set by the user, it
      is also impossible to restore it to the kernel default since the user
      cannot write 0 to the sysctl.
      
      This patch allows the user to write 0 to restore the default behavior.
      It still requires a fraction equal to or larger than 8, however, as
      stated by the documentation for sanity.  If a value in the range [1, 7]
      is written, the sysctl will return EINVAL.
      
      This successfully solves the divide by zero issue at the same time.
      Signed-off-by: default avatarDavid Rientjes <rientjes@google.com>
      Reported-by: default avatarOleg Drokin <green@linuxhacker.ru>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      91b79d41
    • Don Zickus's avatar
      kernel/watchdog.c: remove preemption restrictions when restarting lockup detector · c1944378
      Don Zickus authored
      commit bde92cf4 upstream.
      
      Peter Wu noticed the following splat on his machine when updating
      /proc/sys/kernel/watchdog_thresh:
      
        BUG: sleeping function called from invalid context at mm/slub.c:965
        in_atomic(): 1, irqs_disabled(): 0, pid: 1, name: init
        3 locks held by init/1:
         #0:  (sb_writers#3){.+.+.+}, at: [<ffffffff8117b663>] vfs_write+0x143/0x180
         #1:  (watchdog_proc_mutex){+.+.+.}, at: [<ffffffff810e02d3>] proc_dowatchdog+0x33/0x110
         #2:  (cpu_hotplug.lock){.+.+.+}, at: [<ffffffff810589c2>] get_online_cpus+0x32/0x80
        Preemption disabled at:[<ffffffff810e0384>] proc_dowatchdog+0xe4/0x110
      
        CPU: 0 PID: 1 Comm: init Not tainted 3.16.0-rc1-testing #34
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
        Call Trace:
          dump_stack+0x4e/0x7a
          __might_sleep+0x11d/0x190
          kmem_cache_alloc_trace+0x4e/0x1e0
          perf_event_alloc+0x55/0x440
          perf_event_create_kernel_counter+0x26/0xe0
          watchdog_nmi_enable+0x75/0x140
          update_timers_all_cpus+0x53/0xa0
          proc_dowatchdog+0xe4/0x110
          proc_sys_call_handler+0xb3/0xc0
          proc_sys_write+0x14/0x20
          vfs_write+0xad/0x180
          SyS_write+0x49/0xb0
          system_call_fastpath+0x16/0x1b
        NMI watchdog: disabled (cpu0): hardware events not enabled
      
      What happened is after updating the watchdog_thresh, the lockup detector
      is restarted to utilize the new value.  Part of this process involved
      disabling preemption.  Once preemption was disabled, perf tried to
      allocate a new event (as part of the restart).  This caused the above
      BUG_ON as you can't sleep with preemption disabled.
      
      The preemption restriction seemed agressive as we are not doing anything
      on that particular cpu, but with all the online cpus (which are
      protected by the get_online_cpus lock).  Remove the restriction and the
      BUG_ON goes away.
      Signed-off-by: default avatarDon Zickus <dzickus@redhat.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.cz>
      Reported-by: default avatarPeter Wu <peter@lekensteyn.nl>
      Tested-by: default avatarPeter Wu <peter@lekensteyn.nl>
      Acked-by: default avatarDavid Rientjes <rientjes@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 avatarKamal Mostafa <kamal@canonical.com>
      c1944378
    • Naoya Horiguchi's avatar
      hugetlb: fix copy_hugetlb_page_range() to handle migration/hwpoisoned entry · 3d11b1c7
      Naoya Horiguchi authored
      commit 4a705fef upstream.
      
      There's a race between fork() and hugepage migration, as a result we try
      to "dereference" a swap entry as a normal pte, causing kernel panic.
      The cause of the problem is that copy_hugetlb_page_range() can't handle
      "swap entry" family (migration entry and hwpoisoned entry) so let's fix
      it.
      
      [akpm@linux-foundation.org: coding-style fixes]
      Signed-off-by: default avatarNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>
      Acked-by: default avatarHugh Dickins <hughd@google.com>
      Cc: Christoph Lameter <cl@linux.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 avatarKamal Mostafa <kamal@canonical.com>
      3d11b1c7
    • Andy Lutomirski's avatar
      x86_32, entry: Do syscall exit work on badsys (CVE-2014-4508) · 4bb712f2
      Andy Lutomirski authored
      commit 554086d8 upstream.
      
      The bad syscall nr paths are their own incomprehensible route
      through the entry control flow.  Rearrange them to work just like
      syscalls that return -ENOSYS.
      
      This fixes an OOPS in the audit code when fast-path auditing is
      enabled and sysenter gets a bad syscall nr (CVE-2014-4508).
      
      This has probably been broken since Linux 2.6.27:
      af0575bb i386 syscall audit fast-path
      
      Cc: Roland McGrath <roland@redhat.com>
      Reported-by: default avatarToralf Förster <toralf.foerster@gmx.de>
      Signed-off-by: default avatarAndy Lutomirski <luto@amacapital.net>
      Link: http://lkml.kernel.org/r/e09c499eade6fc321266dd6b54da7beb28d6991c.1403558229.git.luto@amacapital.netSigned-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      4bb712f2
    • Greg Kroah-Hartman's avatar
      lz4: ensure length does not wrap · 97c47548
      Greg Kroah-Hartman authored
      commit 206204a1 upstream.
      
      Given some pathologically compressed data, lz4 could possibly decide to
      wrap a few internal variables, causing unknown things to happen.  Catch
      this before the wrapping happens and abort the decompression.
      Reported-by: default avatar"Don A. Bailey" <donb@securitymouse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      97c47548
    • Greg Kroah-Hartman's avatar
      lzo: properly check for overruns · b91d50ce
      Greg Kroah-Hartman authored
      commit 206a81c1 upstream.
      
      The lzo decompressor can, if given some really crazy data, possibly
      overrun some variable types.  Modify the checking logic to properly
      detect overruns before they happen.
      Reported-by: default avatar"Don A. Bailey" <donb@securitymouse.com>
      Tested-by: default avatar"Don A. Bailey" <donb@securitymouse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      b91d50ce
    • Pierre Ossman's avatar
      ALSA: hda - hdmi: call overridden init on resume · a5c2670a
      Pierre Ossman authored
      commit a2833683 upstream.
      
      We need to call the proper init function in case it has been
      overridden, as it might restore things that the generic routing
      doesn't know anything about. E.g. AMD cards have special verbs
      that need resetting.
      
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=77901
      Fixes: 5a613584 ('ALSA: hda - hdmi: Add ATI/AMD multi-channel audio support')
      Signed-off-by: default avatarPierre Ossman <pierre@ossman.eu>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      a5c2670a
    • Ilya Dryomov's avatar
      rbd: handle parent_overlap on writes correctly · ee07d0cb
      Ilya Dryomov authored
      commit 9638556a upstream.
      
      The following check in rbd_img_obj_request_submit()
      
          rbd_dev->parent_overlap <= obj_request->img_offset
      
      allows the fall through to the non-layered write case even if both
      parent_overlap and obj_request->img_offset belong to the same RADOS
      object.  This leads to data corruption, because the area to the left of
      parent_overlap ends up unconditionally zero-filled instead of being
      populated with parent data.  Suppose we want to write 1M to offset 6M
      of image bar, which is a clone of foo@snap; object_size is 4M,
      parent_overlap is 5M:
      
          rbd_data.<id>.0000000000000001
           ---------------------|----------------------|------------
          | should be copyup'ed | should be zeroed out | write ...
           ---------------------|----------------------|------------
         4M                    5M                     6M
                          parent_overlap    obj_request->img_offset
      
      4..5M should be copyup'ed from foo, yet it is zero-filled, just like
      5..6M is.
      
      Given that the only striping mode kernel client currently supports is
      chunking (i.e. stripe_unit == object_size, stripe_count == 1), round
      parent_overlap up to the next object boundary for the purposes of the
      overlap check.
      Signed-off-by: default avatarIlya Dryomov <ilya.dryomov@inktank.com>
      Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      ee07d0cb
    • Tejun Heo's avatar
      blkcg: fix use-after-free in __blkg_release_rcu() by making blkcg_gq refcnt an atomic_t · 87c68c00
      Tejun Heo authored
      commit a5049a8a upstream.
      
      Hello,
      
      So, this patch should do.  Joe, Vivek, can one of you guys please
      verify that the oops goes away with this patch?
      
      Jens, the original thread can be read at
      
        http://thread.gmane.org/gmane.linux.kernel/1720729
      
      The fix converts blkg->refcnt from int to atomic_t.  It does some
      overhead but it should be minute compared to everything else which is
      going on and the involved cacheline bouncing, so I think it's highly
      unlikely to cause any noticeable difference.  Also, the refcnt in
      question should be converted to a perpcu_ref for blk-mq anyway, so the
      atomic_t is likely to go away pretty soon anyway.
      
      Thanks.
      
      ------- 8< -------
      __blkg_release_rcu() may be invoked after the associated request_queue
      is released with a RCU grace period inbetween.  As such, the function
      and callbacks invoked from it must not dereference the associated
      request_queue.  This is clearly indicated in the comment above the
      function.
      
      Unfortunately, while trying to fix a different issue, 2a4fd070
      ("blkcg: move bulk of blkcg_gq release operations to the RCU
      callback") ignored this and added [un]locking of @blkg->q->queue_lock
      to __blkg_release_rcu().  This of course can cause oops as the
      request_queue may be long gone by the time this code gets executed.
      
        general protection fault: 0000 [#1] SMP
        CPU: 21 PID: 30 Comm: rcuos/21 Not tainted 3.15.0 #1
        Hardware name: Stratus ftServer 6400/G7LAZ, BIOS BIOS Version 6.3:57 12/25/2013
        task: ffff880854021de0 ti: ffff88085403c000 task.ti: ffff88085403c000
        RIP: 0010:[<ffffffff8162e9e5>]  [<ffffffff8162e9e5>] _raw_spin_lock_irq+0x15/0x60
        RSP: 0018:ffff88085403fdf0  EFLAGS: 00010086
        RAX: 0000000000020000 RBX: 0000000000000010 RCX: 0000000000000000
        RDX: 000060ef80008248 RSI: 0000000000000286 RDI: 6b6b6b6b6b6b6b6b
        RBP: ffff88085403fdf0 R08: 0000000000000286 R09: 0000000000009f39
        R10: 0000000000020001 R11: 0000000000020001 R12: ffff88103c17a130
        R13: ffff88103c17a080 R14: 0000000000000000 R15: 0000000000000000
        FS:  0000000000000000(0000) GS:ffff88107fca0000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 00000000006e5ab8 CR3: 000000000193d000 CR4: 00000000000407e0
        Stack:
         ffff88085403fe18 ffffffff812cbfc2 ffff88103c17a130 0000000000000000
         ffff88103c17a130 ffff88085403fec0 ffffffff810d1d28 ffff880854021de0
         ffff880854021de0 ffff88107fcaec58 ffff88085403fe80 ffff88107fcaec30
        Call Trace:
         [<ffffffff812cbfc2>] __blkg_release_rcu+0x72/0x150
         [<ffffffff810d1d28>] rcu_nocb_kthread+0x1e8/0x300
         [<ffffffff81091d81>] kthread+0xe1/0x100
         [<ffffffff8163813c>] ret_from_fork+0x7c/0xb0
        Code: ff 47 04 48 8b 7d 08 be 00 02 00 00 e8 55 48 a4 ff 5d c3 0f 1f 00 66 66 66 66 90 55 48 89 e5
        +fa 66 66 90 66 66 90 b8 00 00 02 00 <f0> 0f c1 07 89 c2 c1 ea 10 66 39 c2 75 02 5d c3 83 e2 fe 0f
        +b7
        RIP  [<ffffffff8162e9e5>] _raw_spin_lock_irq+0x15/0x60
         RSP <ffff88085403fdf0>
      
      The request_queue locking was added because blkcg_gq->refcnt is an int
      protected with the queue lock and __blkg_release_rcu() needs to put
      the parent.  Let's fix it by making blkcg_gq->refcnt an atomic_t and
      dropping queue locking in the function.
      
      Given the general heavy weight of the current request_queue and blkcg
      operations, this is unlikely to cause any noticeable overhead.
      Moreover, blkcg_gq->refcnt is likely to be converted to percpu_ref in
      the near future, so whatever (most likely negligible) overhead it may
      add is temporary.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reported-by: default avatarJoe Lawrence <joe.lawrence@stratus.com>
      Acked-by: default avatarVivek Goyal <vgoyal@redhat.com>
      Link: http://lkml.kernel.org/g/alpine.DEB.2.02.1406081816540.17948@jlaw-desktop.mno.stratus.comSigned-off-by: default avatarJens Axboe <axboe@fb.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      87c68c00
    • Stanislaw Gruszka's avatar
      rt2x00: fix rfkill regression on rt2500pci · 62a1e429
      Stanislaw Gruszka authored
      commit 616a8394 upstream.
      
      As reported by Niels, starting rfkill polling during device probe
      (commit e2bc7c5f, generally sane change) broke rfkill on rt2500pci
      device. I considered that bug as some initalization issue, which
      should be fixed on rt2500pci specific code. But after several
      attempts (see bug report for details) we fail to find working solution.
      Hence I decided to revert to old behaviour on rt2500pci to fix
      regression.
      
      Additionally patch also unregister rfkill on device remove instead
      of ifconfig down, what was another issue introduced by bad commit.
      
      Bug report:
      https://bugzilla.kernel.org/show_bug.cgi?id=73821
      
      Fixes: e2bc7c5f ("rt2x00: Fix rfkill_polling register function.")
      Bisected-by: default avatarNiels <nille0386@googlemail.com>
      Reported-and-tested-by: default avatarNiels <nille0386@googlemail.com>
      Signed-off-by: default avatarStanislaw Gruszka <stf_xl@wp.pl>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      62a1e429
    • Rafał Miłecki's avatar
      b43: fix frequency reported on G-PHY with /new/ firmware · 922587ec
      Rafał Miłecki authored
      commit 2fc68eb1 upstream.
      
      Support for firmware rev 508+ was added years ago, but we never noticed
      it reports channel in a different way for G-PHY devices. Instead of
      offset from 2400 MHz it simply passes channel id (AKA hw_value).
      
      So far it was (most probably) affecting monitor mode users only, but
      the following recent commit made it noticeable for quite everybody:
      
      commit 3afc2167
      Author: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
      Date:   Tue Mar 4 16:50:13 2014 +0200
      
          cfg80211/mac80211: ignore signal if the frame was heard on wrong channel
      Reported-by: default avatarAaro Koskinen <aaro.koskinen@iki.fi>
      Signed-off-by: default avatarRafał Miłecki <zajec5@gmail.com>
      Tested-by: default avatarAaro Koskinen <aaro.koskinen@iki.fi>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      922587ec
    • Stanislaw Gruszka's avatar
      rt2x00: disable TKIP on USB · a7580944
      Stanislaw Gruszka authored
      commit 8edcb0ba upstream.
      
      On USB we can not get atomically TKIP key. We have to disable support
      for TKIP acceleration on USB hardware to avoid bug as showed bellow.
      
      [  860.827243] BUG: scheduling while atomic: hostapd/3397/0x00000002
      <snip>
      [  860.827280] Call Trace:
      [  860.827282]  [<ffffffff81682ea6>] dump_stack+0x4d/0x66
      [  860.827284]  [<ffffffff8167eb9b>] __schedule_bug+0x47/0x55
      [  860.827285]  [<ffffffff81685bb3>] __schedule+0x733/0x7b0
      [  860.827287]  [<ffffffff81685c59>] schedule+0x29/0x70
      [  860.827289]  [<ffffffff81684f8a>] schedule_timeout+0x15a/0x2b0
      [  860.827291]  [<ffffffff8105ac50>] ? ftrace_raw_event_tick_stop+0xc0/0xc0
      [  860.827294]  [<ffffffff810c13c2>] ? __module_text_address+0x12/0x70
      [  860.827296]  [<ffffffff81686823>] wait_for_completion_timeout+0xb3/0x140
      [  860.827298]  [<ffffffff81080fc0>] ? wake_up_state+0x20/0x20
      [  860.827301]  [<ffffffff814d5b3d>] usb_start_wait_urb+0x7d/0x150
      [  860.827303]  [<ffffffff814d5cd5>] usb_control_msg+0xc5/0x110
      [  860.827305]  [<ffffffffa02fb0c6>] rt2x00usb_vendor_request+0xc6/0x160  [rt2x00usb]
      [  860.827307]  [<ffffffffa02fb215>] rt2x00usb_vendor_req_buff_lock+0x75/0x150 [rt2x00usb]
      [  860.827309]  [<ffffffffa02fb393>] rt2x00usb_vendor_request_buff+0xa3/0xe0 [rt2x00usb]
      [  860.827311]  [<ffffffffa023d1a3>] rt2x00usb_register_multiread+0x33/0x40 [rt2800usb]
      [  860.827314]  [<ffffffffa05805f9>] rt2800_get_tkip_seq+0x39/0x50  [rt2800lib]
      [  860.827321]  [<ffffffffa0480f88>] ieee80211_get_key+0x218/0x2a0  [mac80211]
      [  860.827322]  [<ffffffff815cc68c>] ? __nlmsg_put+0x6c/0x80
      [  860.827329]  [<ffffffffa051b02e>] nl80211_get_key+0x22e/0x360 [cfg80211]
      Reported-and-tested-by: default avatarPeter Wu <lekensteyn@gmail.com>
      Reported-and-tested-by: default avatarPontus Fuchs <pontus.fuchs@gmail.com>
      Signed-off-by: default avatarStanislaw Gruszka <sgruszka@redhat.com>
      Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      a7580944
    • Marcin Kraglak's avatar
      Bluetooth: Allow change security level on ATT_CID in slave role · cfc72bbd
      Marcin Kraglak authored
      commit 92d1372e upstream.
      
      Kernel supports SMP Security Request so don't block increasing security
      when we are slave.
      Signed-off-by: default avatarMarcin Kraglak <marcin.kraglak@tieto.com>
      Acked-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      cfc72bbd
    • Johan Hedberg's avatar
      Bluetooth: Fix locking of hdev when calling into SMP code · c5538512
      Johan Hedberg authored
      commit c73f94b8 upstream.
      
      The SMP code expects hdev to be unlocked since e.g. crypto functions
      will try to (re)lock it. Therefore, we need to release the lock before
      calling into smp.c from mgmt.c. Without this we risk a deadlock whenever
      the smp_user_confirm_reply() function is called.
      Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
      Tested-by: default avatarLukasz Rymanowski <lukasz.rymanowski@tieto.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      c5538512
    • Johan Hedberg's avatar
      Bluetooth: Fix indicating discovery state when canceling inquiry · bdc535d8
      Johan Hedberg authored
      commit 50143a43 upstream.
      
      When inquiry is canceled through the HCI_Cancel_Inquiry command there is
      no Inquiry Complete event generated. Instead, all we get is the command
      complete for the HCI_Inquiry_Cancel command. This means that we must
      call the hci_discovery_set_state() function from the respective command
      complete handler in order to ensure that user space knows the correct
      discovery state.
      Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      bdc535d8
    • Johan Hedberg's avatar
      Bluetooth: Fix setting correct authentication information for SMP STK · 36fd71b7
      Johan Hedberg authored
      commit fff3490f upstream.
      
      When we store the STK in slave role we should set the correct
      authentication information for it. If the pairing is producing a HIGH
      security level the STK is considered authenticated, and otherwise it's
      considered unauthenticated. This patch fixes the value passed to the
      hci_add_ltk() function when adding the STK on the slave side.
      Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
      Tested-by: default avatarMarcin Kraglak <marcin.kraglak@tieto.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      [ kamal: backport to 3.13-stable: context ]
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      36fd71b7
    • Johan Hedberg's avatar
      Bluetooth: Fix SSP acceptor just-works confirmation without MITM · 5c13e473
      Johan Hedberg authored
      commit ba15a58b upstream.
      
      From the Bluetooth Core Specification 4.1 page 1958:
      
      "if both devices have set the Authentication_Requirements parameter to
      one of the MITM Protection Not Required options, authentication stage 1
      shall function as if both devices set their IO capabilities to
      DisplayOnly (e.g., Numeric comparison with automatic confirmation on
      both devices)"
      
      So far our implementation has done user confirmation for all just-works
      cases regardless of the MITM requirements, however following the
      specification to the word means that we should not be doing confirmation
      when neither side has the MITM flag set.
      Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
      Tested-by: default avatarSzymon Janc <szymon.janc@tieto.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      5c13e473
    • Lars-Peter Clausen's avatar
      ALSA: control: Make sure that id->index does not overflow · d8bad75a
      Lars-Peter Clausen authored
      commit 883a1d49 upstream.
      
      The ALSA control code expects that the range of assigned indices to a control is
      continuous and does not overflow. Currently there are no checks to enforce this.
      If a control with a overflowing index range is created that control becomes
      effectively inaccessible and unremovable since snd_ctl_find_id() will not be
      able to find it. This patch adds a check that makes sure that controls with a
      overflowing index range can not be created.
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Acked-by: default avatarJaroslav Kysela <perex@perex.cz>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      d8bad75a
    • Lars-Peter Clausen's avatar
      ALSA: control: Handle numid overflow · dfc3d7fa
      Lars-Peter Clausen authored
      commit ac902c11 upstream.
      
      Each control gets automatically assigned its numids when the control is created.
      The allocation is done by incrementing the numid by the amount of allocated
      numids per allocation. This means that excessive creation and destruction of
      controls (e.g. via SNDRV_CTL_IOCTL_ELEM_ADD/REMOVE) can cause the id to
      eventually overflow. Currently when this happens for the control that caused the
      overflow kctl->id.numid + kctl->count will also over flow causing it to be
      smaller than kctl->id.numid. Most of the code assumes that this is something
      that can not happen, so we need to make sure that it won't happen
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Acked-by: default avatarJaroslav Kysela <perex@perex.cz>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      dfc3d7fa
    • Lars-Peter Clausen's avatar
      ALSA: control: Don't access controls outside of protected regions · 235458a1
      Lars-Peter Clausen authored
      commit fd9f26e4 upstream.
      
      A control that is visible on the card->controls list can be freed at any time.
      This means we must not access any of its memory while not holding the
      controls_rw_lock. Otherwise we risk a use after free access.
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Acked-by: default avatarJaroslav Kysela <perex@perex.cz>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      235458a1
    • Lars-Peter Clausen's avatar
      ALSA: control: Fix replacing user controls · 43566a53
      Lars-Peter Clausen authored
      commit 82262a46 upstream.
      
      There are two issues with the current implementation for replacing user
      controls. The first is that the code does not check if the control is actually a
      user control and neither does it check if the control is owned by the process
      that tries to remove it. That allows userspace applications to remove arbitrary
      controls, which can cause a user after free if a for example a driver does not
      expect a control to be removed from under its feed.
      
      The second issue is that on one hand when a control is replaced the
      user_ctl_count limit is not checked and on the other hand the user_ctl_count is
      increased (even though the number of user controls does not change). This allows
      userspace, once the user_ctl_count limit as been reached, to repeatedly replace
      a control until user_ctl_count overflows. Once that happens new controls can be
      added effectively bypassing the user_ctl_count limit.
      
      Both issues can be fixed by instead of open-coding the removal of the control
      that is to be replaced to use snd_ctl_remove_user_ctl(). This function does
      proper permission checks as well as decrements user_ctl_count after the control
      has been removed.
      
      Note that by using snd_ctl_remove_user_ctl() the check which returns -EBUSY at
      beginning of the function if the control already exists is removed. This is not
      a problem though since the check is quite useless, because the lock that is
      protecting the control list is released between the check and before adding the
      new control to the list, which means that it is possible that a different
      control with the same settings is added to the list after the check. Luckily
      there is another check that is done while holding the lock in snd_ctl_add(), so
      we'll rely on that to make sure that the same control is not added twice.
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Acked-by: default avatarJaroslav Kysela <perex@perex.cz>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      43566a53
    • Lars-Peter Clausen's avatar
      ALSA: control: Protect user controls against concurrent access · 2e069147
      Lars-Peter Clausen authored
      commit 07f4d9d7 upstream.
      
      The user-control put and get handlers as well as the tlv do not protect against
      concurrent access from multiple threads. Since the state of the control is not
      updated atomically it is possible that either two write operations or a write
      and a read operation race against each other. Both can lead to arbitrary memory
      disclosure. This patch introduces a new lock that protects user-controls from
      concurrent access. Since applications typically access controls sequentially
      than in parallel a single lock per card should be fine.
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Acked-by: default avatarJaroslav Kysela <perex@perex.cz>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      2e069147
    • Suravee Suthikulpanit's avatar
      arm64/dma: Removing ARCH_HAS_DMA_GET_REQUIRED_MASK macro · 27b9720a
      Suravee Suthikulpanit authored
      commit f3a183cb upstream.
      
      Arm64 does not define dma_get_required_mask() function.
      Therefore, it should not define the ARCH_HAS_DMA_GET_REQUIRED_MASK.
      This causes build errors in some device drivers (e.g. mpt2sas)
      Signed-off-by: default avatarSuravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      27b9720a
    • Victor Kamensky's avatar
      arm64: ptrace: fix empty registers set in prstatus of aarch32 process core · 0b3f295d
      Victor Kamensky authored
      commit 2227901a upstream.
      
      Currently core file of aarch32 process prstatus note has empty
      registers set. As result aarch32 core files create by V8 kernel are
      not very useful.
      
      It happens because compat_gpr_get and compat_gpr_set functions can
      copy registers values to/from either kbuf or ubuf. ELF core file
      collection function fill_thread_core_info calls compat_gpr_get
      with kbuf set and ubuf set to 0. But current compat_gpr_get and
      compat_gpr_set function handle copy to/from only ubuf case.
      
      Fix is to handle kbuf and ubuf as two separate cases in similar
      way as other functions like user_regset_copyout, user_regset_copyin do.
      Signed-off-by: default avatarVictor Kamensky <victor.kamensky@linaro.org>
      Acked-by: default avatarWill Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      0b3f295d
    • Will Deacon's avatar
      arm64: uid16: fix __kernel_old_{gid,uid}_t definitions · 8879974c
      Will Deacon authored
      commit 34c65c43 upstream.
      
      Whilst native arm64 applications don't have the 16-bit UID/GID syscalls
      wired up, compat tasks can still access them. The 16-bit wrappers for
      these syscalls use __kernel_old_uid_t and __kernel_old_gid_t, which must
      be 16-bit data types to maintain compatibility with the 16-bit UIDs used
      by compat applications.
      
      This patch defines 16-bit __kernel_old_{gid,uid}_t types for arm64
      instead of using the 32-bit types provided by asm-generic.
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      8879974c
    • Will Deacon's avatar
      arm64: ptrace: change fs when passing kernel pointer to regset code · e394cba1
      Will Deacon authored
      commit c1688707 upstream.
      
      Our compat PTRACE_POKEUSR implementation simply passes the user data to
      regset_copy_from_user after some simple range checking. Unfortunately,
      the data in question has already been copied to the kernel stack by this
      point, so the subsequent access_ok check fails and the ptrace request
      returns -EFAULT. This causes problems tracing fork() with older versions
      of strace.
      
      This patch briefly changes the fs to KERNEL_DS, so that the access_ok
      check passes even with a kernel address.
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      e394cba1
    • ChiaHao's avatar
      arm64: Bug fix in stack alignment exception · 0f2e513f
      ChiaHao authored
      commit 3906c2b5 upstream.
      
      The value of ESR has been stored into x1, and should be directly pass to
      do_sp_pc_abort function, "MOV x1, x25" is an extra operation and do_sp_pc_abort
      will get the wrong value of ESR.
      Signed-off-by: default avatarChiaHao <andy.jhshiu@gmail.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      0f2e513f
    • Alan Stern's avatar
      USB: EHCI: avoid BIOS handover on the HASEE E200 · b3fa7062
      Alan Stern authored
      commit b0a50e92 upstream.
      
      Leandro Liptak reports that his HASEE E200 computer hangs when we ask
      the BIOS to hand over control of the EHCI host controller.  This
      definitely sounds like a bug in the BIOS, but at the moment there is
      no way to fix it.
      
      This patch works around the problem by avoiding the handoff whenever
      the motherboard and BIOS version match those of Leandro's computer.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Reported-by: default avatarLeandro Liptak <leandroliptak@gmail.com>
      Tested-by: default avatarLeandro Liptak <leandroliptak@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      b3fa7062
    • Jason Cooper's avatar
      ARM: mvebu: DT: fix OpenBlocks AX3-4 RAM size · 2fa4ec06
      Jason Cooper authored
      commit e47043ae upstream.
      
      The OpenBlocks AX3-4 has a non-DT bootloader.  It also comes with 1GB of
      soldered on RAM, and a DIMM slot for expansion.
      
      Unfortunately, atags_to_fdt() doesn't work in big-endian mode, so we see
      the following failure when attempting to boot a big-endian kernel:
      
        686 slab pages
        17 pages shared
        0 pages swap cached
        [ pid ]   uid  tgid total_vm      rss nr_ptes swapents oom_score_adj name
        Kernel panic - not syncing: Out of memory and no killable processes...
      
        CPU: 1 PID: 351 Comm: kworker/u4:0 Not tainted 3.15.0-rc8-next-20140603 #1
        [<c0215a54>] (unwind_backtrace) from [<c021160c>] (show_stack+0x10/0x14)
        [<c021160c>] (show_stack) from [<c0802500>] (dump_stack+0x78/0x94)
        [<c0802500>] (dump_stack) from [<c0800068>] (panic+0x90/0x21c)
        [<c0800068>] (panic) from [<c02b5704>] (out_of_memory+0x320/0x340)
        [<c02b5704>] (out_of_memory) from [<c02b93a0>] (__alloc_pages_nodemask+0x874/0x930)
        [<c02b93a0>] (__alloc_pages_nodemask) from [<c02d446c>] (handle_mm_fault+0x744/0x96c)
        [<c02d446c>] (handle_mm_fault) from [<c02cf250>] (__get_user_pages+0xd0/0x4c0)
        [<c02cf250>] (__get_user_pages) from [<c02f3598>] (get_arg_page+0x54/0xbc)
        [<c02f3598>] (get_arg_page) from [<c02f3878>] (copy_strings+0x278/0x29c)
        [<c02f3878>] (copy_strings) from [<c02f38bc>] (copy_strings_kernel+0x20/0x28)
        [<c02f38bc>] (copy_strings_kernel) from [<c02f4f1c>] (do_execve+0x3a8/0x4c8)
        [<c02f4f1c>] (do_execve) from [<c025ac10>] (____call_usermodehelper+0x15c/0x194)
        [<c025ac10>] (____call_usermodehelper) from [<c020e9b8>] (ret_from_fork+0x14/0x3c)
        CPU0: stopping
        CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.15.0-rc8-next-20140603 #1
        [<c0215a54>] (unwind_backtrace) from [<c021160c>] (show_stack+0x10/0x14)
        [<c021160c>] (show_stack) from [<c0802500>] (dump_stack+0x78/0x94)
        [<c0802500>] (dump_stack) from [<c021429c>] (handle_IPI+0x138/0x174)
        [<c021429c>] (handle_IPI) from [<c02087f0>] (armada_370_xp_handle_irq+0xb0/0xcc)
        [<c02087f0>] (armada_370_xp_handle_irq) from [<c0212100>] (__irq_svc+0x40/0x50)
        Exception stack(0xc0b6bf68 to 0xc0b6bfb0)
        bf60:                   e9fad598 00000000 00f509a3 00000000 c0b6a000 c0b724c4
        bf80: c0b72458 c0b6a000 00000000 00000000 c0b66da0 c0b6a000 00000000 c0b6bfb0
        bfa0: c027bb94 c027bb24 60000313 ffffffff
        [<c0212100>] (__irq_svc) from [<c027bb24>] (cpu_startup_entry+0x54/0x214)
        [<c027bb24>] (cpu_startup_entry) from [<c0ac5b30>] (start_kernel+0x318/0x37c)
        [<c0ac5b30>] (start_kernel) from [<00208078>] (0x208078)
        ---[ end Kernel panic - not syncing: Out of memory and no killable processes...
      
      A similar failure will also occur if ARM_ATAG_DTB_COMPAT isn't selected.
      
      Fix this by setting a sane default (1 GB) in the dts file.
      Signed-off-by: default avatarJason Cooper <jason@lakedaemon.net>
      Tested-by: default avatarKevin Hilman <khilman@linaro.org>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      2fa4ec06