1. 02 Dec, 2015 13 commits
    • Lukas Czerner's avatar
      ext4: fix potential use after free in __ext4_journal_stop · a2d0b92c
      Lukas Czerner authored
      commit 6934da92 upstream.
      
      There is a use-after-free possibility in __ext4_journal_stop() in the
      case that we free the handle in the first jbd2_journal_stop() because
      we're referencing handle->h_err afterwards. This was introduced in
      9705acd6 and it is wrong. Fix it by
      storing the handle->h_err value beforehand and avoid referencing
      potentially freed handle.
      
      Fixes: 9705acd6Signed-off-by: default avatarLukas Czerner <lczerner@redhat.com>
      Reviewed-by: default avatarAndreas Dilger <adilger@dilger.ca>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      a2d0b92c
    • David Woodhouse's avatar
      iommu/vt-d: Fix ATSR handling for Root-Complex integrated endpoints · 0af45b3b
      David Woodhouse authored
      commit d14053b3 upstream.
      
      The VT-d specification says that "Software must enable ATS on endpoint
      devices behind a Root Port only if the Root Port is reported as
      supporting ATS transactions."
      
      We walk up the tree to find a Root Port, but for integrated devices we
      don't find one — we get to the host bridge. In that case we *should*
      allow ATS. Currently we don't, which means that we are incorrectly
      failing to use ATS for the integrated graphics. Fix that.
      
      We should never break out of this loop "naturally" with bus==NULL,
      since we'll always find bridge==NULL in that case (and now return 1).
      
      So remove the check for (!bridge) after the loop, since it can never
      happen. If it did, it would be worthy of a BUG_ON(!bridge). But since
      it'll oops anyway in that case, that'll do just as well.
      Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      0af45b3b
    • Jiang Liu's avatar
      iommu/vt-d: Fix error in detect ATS capability · cb6349b4
      Jiang Liu authored
      commit b5f82ddf upstream.
      
      Current Intel IOMMU driver only matches a PCIe root port with the first
      DRHD unit with the samge segment number. It will report false result
      if there are multiple DRHD units with the same segment number, thus fail
      to detect ATS capability for some PCIe devices.
      
      This patch refines function dmar_find_matched_atsr_unit() to search all
      DRHD units with the same segment number.
      
      An example DMAR table entries as below:
      [1D0h 0464  2]                Subtable Type : 0002 <Root Port ATS Capability>
      [1D2h 0466  2]                       Length : 0028
      [1D4h 0468  1]                        Flags : 00
      [1D5h 0469  1]                     Reserved : 00
      [1D6h 0470  2]           PCI Segment Number : 0000
      
      [1D8h 0472  1]      Device Scope Entry Type : 02
      [1D9h 0473  1]                 Entry Length : 08
      [1DAh 0474  2]                     Reserved : 0000
      [1DCh 0476  1]               Enumeration ID : 00
      [1DDh 0477  1]               PCI Bus Number : 00
      [1DEh 0478  2]                     PCI Path : [02, 00]
      
      [1E0h 0480  1]      Device Scope Entry Type : 02
      [1E1h 0481  1]                 Entry Length : 08
      [1E2h 0482  2]                     Reserved : 0000
      [1E4h 0484  1]               Enumeration ID : 00
      [1E5h 0485  1]               PCI Bus Number : 00
      [1E6h 0486  2]                     PCI Path : [03, 00]
      
      [1E8h 0488  1]      Device Scope Entry Type : 02
      [1E9h 0489  1]                 Entry Length : 08
      [1EAh 0490  2]                     Reserved : 0000
      [1ECh 0492  1]               Enumeration ID : 00
      [1EDh 0493  1]               PCI Bus Number : 00
      [1EEh 0494  2]                     PCI Path : [03, 02]
      
      [1F0h 0496  1]      Device Scope Entry Type : 02
      [1F1h 0497  1]                 Entry Length : 08
      [1F2h 0498  2]                     Reserved : 0000
      [1F4h 0500  1]               Enumeration ID : 00
      [1F5h 0501  1]               PCI Bus Number : 00
      [1F6h 0502  2]                     PCI Path : [03, 03]
      
      [1F8h 0504  2]                Subtable Type : 0002 <Root Port ATS Capability>
      [1FAh 0506  2]                       Length : 0020
      [1FCh 0508  1]                        Flags : 00
      [1FDh 0509  1]                     Reserved : 00
      [1FEh 0510  2]           PCI Segment Number : 0000
      
      [200h 0512  1]      Device Scope Entry Type : 02
      [201h 0513  1]                 Entry Length : 08
      [202h 0514  2]                     Reserved : 0000
      [204h 0516  1]               Enumeration ID : 00
      [205h 0517  1]               PCI Bus Number : 40
      [206h 0518  2]                     PCI Path : [02, 00]
      
      [208h 0520  1]      Device Scope Entry Type : 02
      [209h 0521  1]                 Entry Length : 08
      [20Ah 0522  2]                     Reserved : 0000
      [20Ch 0524  1]               Enumeration ID : 00
      [20Dh 0525  1]               PCI Bus Number : 40
      [20Eh 0526  2]                     PCI Path : [02, 02]
      
      [210h 0528  1]      Device Scope Entry Type : 02
      [211h 0529  1]                 Entry Length : 08
      [212h 0530  2]                     Reserved : 0000
      [214h 0532  1]               Enumeration ID : 00
      [215h 0533  1]               PCI Bus Number : 40
      [216h 0534  2]                     PCI Path : [03, 00]
      
      [218h 0536  2]                Subtable Type : 0002 <Root Port ATS Capability>
      [21Ah 0538  2]                       Length : 0020
      [21Ch 0540  1]                        Flags : 00
      [21Dh 0541  1]                     Reserved : 00
      [21Eh 0542  2]           PCI Segment Number : 0000
      
      [220h 0544  1]      Device Scope Entry Type : 02
      [221h 0545  1]                 Entry Length : 08
      [222h 0546  2]                     Reserved : 0000
      [224h 0548  1]               Enumeration ID : 00
      [225h 0549  1]               PCI Bus Number : 80
      [226h 0550  2]                     PCI Path : [02, 00]
      
      [228h 0552  1]      Device Scope Entry Type : 02
      [229h 0553  1]                 Entry Length : 08
      [22Ah 0554  2]                     Reserved : 0000
      [22Ch 0556  1]               Enumeration ID : 00
      [22Dh 0557  1]               PCI Bus Number : 80
      [22Eh 0558  2]                     PCI Path : [02, 02]
      
      [230h 0560  1]      Device Scope Entry Type : 02
      [231h 0561  1]                 Entry Length : 08
      [232h 0562  2]                     Reserved : 0000
      [234h 0564  1]               Enumeration ID : 00
      [235h 0565  1]               PCI Bus Number : 80
      [236h 0566  2]                     PCI Path : [03, 00]
      
      [238h 0568  2]                Subtable Type : 0002 <Root Port ATS Capability>
      [23Ah 0570  2]                       Length : 0020
      [23Ch 0572  1]                        Flags : 00
      [23Dh 0573  1]                     Reserved : 00
      [23Eh 0574  2]           PCI Segment Number : 0000
      
      [240h 0576  1]      Device Scope Entry Type : 02
      [241h 0577  1]                 Entry Length : 08
      [242h 0578  2]                     Reserved : 0000
      [244h 0580  1]               Enumeration ID : 00
      [245h 0581  1]               PCI Bus Number : C0
      [246h 0582  2]                     PCI Path : [02, 00]
      
      [248h 0584  1]      Device Scope Entry Type : 02
      [249h 0585  1]                 Entry Length : 08
      [24Ah 0586  2]                     Reserved : 0000
      [24Ch 0588  1]               Enumeration ID : 00
      [24Dh 0589  1]               PCI Bus Number : C0
      [24Eh 0590  2]                     PCI Path : [02, 02]
      
      [250h 0592  1]      Device Scope Entry Type : 02
      [251h 0593  1]                 Entry Length : 08
      [252h 0594  2]                     Reserved : 0000
      [254h 0596  1]               Enumeration ID : 00
      [255h 0597  1]               PCI Bus Number : C0
      [256h 0598  2]                     PCI Path : [03, 00]
      Signed-off-by: default avatarJiang Liu <jiang.liu@linux.intel.com>
      Signed-off-by: default avatarJoerg Roedel <joro@8bytes.org>
      [ kamal: 3.13-stable prereq for
        d14053b iommu/vt-d: Fix ATSR handling for Root-Complex integrated endpoints ]
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      cb6349b4
    • Peter Ujfalusi's avatar
      ARM: common: edma: Fix channel parameter for irq callbacks · 1b88a695
      Peter Ujfalusi authored
      commit 696d8b70 upstream.
      
      In case when the interrupt happened for the second eDMA the channel
      number was incorrectly passed to the client driver.
      Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@ti.com>
      Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      1b88a695
    • Andrey Ryabinin's avatar
      lockd: create NSM handles per net namespace · 3ffa092f
      Andrey Ryabinin authored
      commit 0ad95472 upstream.
      
      Commit cb7323ff ("lockd: create and use per-net NSM
       RPC clients on MON/UNMON requests") introduced per-net
      NSM RPC clients. Unfortunately this doesn't make any sense
      without per-net nsm_handle.
      
      E.g. the following scenario could happen
      Two hosts (X and Y) in different namespaces (A and B) share
      the same nsm struct.
      
      1. nsm_monitor(host_X) called => NSM rpc client created,
      	nsm->sm_monitored bit set.
      2. nsm_mointor(host-Y) called => nsm->sm_monitored already set,
      	we just exit. Thus in namespace B ln->nsm_clnt == NULL.
      3. host X destroyed => nsm->sm_count decremented to 1
      4. host Y destroyed => nsm_unmonitor() => nsm_mon_unmon() => NULL-ptr
      	dereference of *ln->nsm_clnt
      
      So this could be fixed by making per-net nsm_handles list,
      instead of global. Thus different net namespaces will not be able
      share the same nsm_handle.
      Signed-off-by: default avatarAndrey Ryabinin <aryabinin@virtuozzo.com>
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      3ffa092f
    • Vignesh R's avatar
      spi: ti-qspi: Fix data corruption seen on r/w stress test · 17f8c910
      Vignesh R authored
      commit bc27a539 upstream.
      
      Writing invalid command to QSPI_SPI_CMD_REG will terminate current
      transfer and de-assert the chip select. This has to be done before
      calling spi_finalize_current_message(). Because
      spi_finalize_current_message() will mark the end of current message
      transfer and schedule the next transfer. If the chipselect is not
      de-asserted before calling spi_finalize_current_message() then the next
      transfer will overlap with the previous transfer leading to data
      corruption.
      __spi_pump_message() can be called either from kthread worker context or
      directly from the calling process's context. It is possible that these
      two calls can race against each other. But race is serialized by
      checking whether master->cur_msg == NULL (pointer to msg being handled
      by transfer_one() at present). The master->cur_msg is set to NULL when
      spi_finalize_current_message() is called on that message, which means
      calling spi_finalize_current_message() allows __spi_sync() to pump next
      message in calling process context.
      Now if spi-ti-qspi calls spi_finalize_current_message() before we
      terminate transfer at hardware side, if __spi_pump_message() is called
      from process context then the successive transactions can overlap.
      
      Fix this by moving writing invalid command to QSPI_SPI_CMD_REG to
      before calling spi_finalize_current_message() call.
      Signed-off-by: default avatarVignesh R <vigneshr@ti.com>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      17f8c910
    • Marek Szyprowski's avatar
      ARM: 8427/1: dma-mapping: add support for offset parameter in dma_mmap() · ca3c9021
      Marek Szyprowski authored
      commit 7e312103 upstream.
      
      IOMMU-based dma_mmap() implementation lacked proper support for offset
      parameter used in mmap call (it always assumed that mapping starts from
      offset zero). This patch adds support for offset parameter to IOMMU-based
      implementation.
      Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
      Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      ca3c9021
    • Marek Szyprowski's avatar
      ARM: 8426/1: dma-mapping: add missing range check in dma_mmap() · 38a8e7c0
      Marek Szyprowski authored
      commit 371f0f08 upstream.
      
      dma_mmap() function in IOMMU-based dma-mapping implementation lacked
      a check for valid range of mmap parameters (offset and buffer size), what
      might have caused access beyond the allocated buffer. This patch fixes
      this issue.
      Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
      Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      38a8e7c0
    • Ingo Molnar's avatar
      fs/proc, core/debug: Don't expose absolute kernel addresses via wchan · fddf5ac9
      Ingo Molnar authored
      commit b2f73922 upstream.
      
      So the /proc/PID/stat 'wchan' field (the 30th field, which contains
      the absolute kernel address of the kernel function a task is blocked in)
      leaks absolute kernel addresses to unprivileged user-space:
      
              seq_put_decimal_ull(m, ' ', wchan);
      
      The absolute address might also leak via /proc/PID/wchan as well, if
      KALLSYMS is turned off or if the symbol lookup fails for some reason:
      
      static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns,
                                struct pid *pid, struct task_struct *task)
      {
              unsigned long wchan;
              char symname[KSYM_NAME_LEN];
      
              wchan = get_wchan(task);
      
              if (lookup_symbol_name(wchan, symname) < 0) {
                      if (!ptrace_may_access(task, PTRACE_MODE_READ))
                              return 0;
                      seq_printf(m, "%lu", wchan);
              } else {
                      seq_printf(m, "%s", symname);
              }
      
              return 0;
      }
      
      This isn't ideal, because for example it trivially leaks the KASLR offset
      to any local attacker:
      
        fomalhaut:~> printf "%016lx\n" $(cat /proc/$$/stat | cut -d' ' -f35)
        ffffffff8123b380
      
      Most real-life uses of wchan are symbolic:
      
        ps -eo pid:10,tid:10,wchan:30,comm
      
      and procps uses /proc/PID/wchan, not the absolute address in /proc/PID/stat:
      
        triton:~/tip> strace -f ps -eo pid:10,tid:10,wchan:30,comm 2>&1 | grep wchan | tail -1
        open("/proc/30833/wchan", O_RDONLY)     = 6
      
      There's one compatibility quirk here: procps relies on whether the
      absolute value is non-zero - and we can provide that functionality
      by outputing "0" or "1" depending on whether the task is blocked
      (whether there's a wchan address).
      
      These days there appears to be very little legitimate reason
      user-space would be interested in  the absolute address. The
      absolute address is mostly historic: from the days when we
      didn't have kallsyms and user-space procps had to do the
      decoding itself via the System.map.
      
      So this patch sets all numeric output to "0" or "1" and keeps only
      symbolic output, in /proc/PID/wchan.
      
      ( The absolute sleep address can generally still be profiled via
        perf, by tasks with sufficient privileges. )
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Acked-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Andrey Konovalov <andreyknvl@google.com>
      Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Kostya Serebryany <kcc@google.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sasha Levin <sasha.levin@oracle.com>
      Cc: kasan-dev <kasan-dev@googlegroups.com>
      Cc: linux-kernel@vger.kernel.org
      Link: http://lkml.kernel.org/r/20150930135917.GA3285@gmail.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      [ kamal: backport to 3.13-stable: proc_pid_wchan context ]
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      fddf5ac9
    • Boris BREZILLON's avatar
      mtd: mtdpart: fix add_mtd_partitions error path · 4e9e0c87
      Boris BREZILLON authored
      commit e5bae867 upstream.
      
      If we fail to allocate a partition structure in the middle of the partition
      creation process, the already allocated partitions are never removed, which
      means they are still present in the partition list and their resources are
      never freed.
      Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
      Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      4e9e0c87
    • Maxime Ripard's avatar
      net: mvneta: Fix CPU_MAP registers initialisation · e55274c1
      Maxime Ripard authored
      commit 2502d0ef upstream.
      
      The CPU_MAP register is duplicated for each CPUs at different addresses,
      each instance being at a different address.
      
      However, the code so far was using CONFIG_NR_CPUS to initialise the CPU_MAP
      registers for each registers, while the SoCs embed at most 4 CPUs.
      
      This is especially an issue with multi_v7_defconfig, where CONFIG_NR_CPUS
      is currently set to 16, resulting in writes to registers that are not
      CPU_MAP.
      
      Fixes: c5aff182 ("net: mvneta: driver for Marvell Armada 370/XP network unit")
      Signed-off-by: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
      Signed-off-by: default avatarGregory CLEMENT <gregory.clement@free-electrons.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      e55274c1
    • Andrzej Hajda's avatar
      [media] v4l2-compat-ioctl32: fix alignment for ARM64 · 2beeada2
      Andrzej Hajda authored
      commit 655e9780 upstream.
      
      Alignment/padding rules on AMD64 and ARM64 differs. To allow properly match
      compatible ioctls on ARM64 kernels without breaking AMD64 some fields
      should be aligned using compat_s64 type and in one case struct should be
      unpacked.
      Signed-off-by: default avatarAndrzej Hajda <a.hajda@samsung.com>
      [hans.verkuil@cisco.com: use compat_u64 instead of compat_s64 in v4l2_input32]
      Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      2beeada2
    • Richard Purdie's avatar
      HID: core: Avoid uninitialized buffer access · 963535ae
      Richard Purdie authored
      commit 79b568b9 upstream.
      
      hid_connect adds various strings to the buffer but they're all
      conditional. You can find circumstances where nothing would be written
      to it but the kernel will still print the supposedly empty buffer with
      printk. This leads to corruption on the console/in the logs.
      
      Ensure buf is initialized to an empty string.
      Signed-off-by: default avatarRichard Purdie <richard.purdie@linuxfoundation.org>
      [dvhart: Initialize string to "" rather than assign buf[0] = NULL;]
      Cc: Jiri Kosina <jikos@kernel.org>
      Cc: linux-input@vger.kernel.org
      Signed-off-by: default avatarDarren Hart <dvhart@linux.intel.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      963535ae
  2. 01 Dec, 2015 1 commit
  3. 30 Nov, 2015 13 commits
  4. 18 Nov, 2015 1 commit
  5. 13 Nov, 2015 12 commits