1. 10 Aug, 2016 40 commits
    • Alan Stern's avatar
      SCSI: fix new bug in scsi_dev_info_list string matching · 224d3cc7
      Alan Stern authored
      commit 5e7ff2ca upstream.
      
      Commit b704f70c ("SCSI: fix bug in scsi_dev_info_list matching")
      changed the way vendor- and model-string matching was carried out in the
      routine that looks up entries in a SCSI devinfo list.  The new matching
      code failed to take into account the case of a maximum-length string; in
      such cases it could end up testing for a terminating '\0' byte beyond
      the end of the memory allocated to the string.  This out-of-bounds bug
      was detected by UBSAN.
      
      I don't know if anybody has actually encountered this bug.  The symptom
      would be that a device entry in the blacklist might not be matched
      properly if it contained an 8-character vendor name or a 16-character
      model name.  Such entries certainly exist in scsi_static_device_list.
      
      This patch fixes the problem by adding a check for a maximum-length
      string before the '\0' test.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Fixes: b704f70c ("SCSI: fix bug in scsi_dev_info_list matching")
      Tested-by: default avatarWilfried Klaebe <linux-kernel@lebenslange-mailadresse.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      224d3cc7
    • Bruno Prémont's avatar
      qla2xxx: Fix NULL pointer deref in QLA interrupt · ddb2bdc5
      Bruno Prémont authored
      commit 262e2bfd upstream.
      
      In qla24xx_process_response_queue() rsp->msix->cpuid may trigger NULL
      pointer dereference when rsp->msix is NULL:
      
      [    5.622457] NULL pointer dereference at 0000000000000050
      [    5.622457] IP: [<ffffffff8155e614>] qla24xx_process_response_queue+0x44/0x4b0
      [    5.622457] PGD 0
      [    5.622457] Oops: 0000 [#1] SMP
      [    5.622457] Modules linked in:
      [    5.622457] CPU: 2 PID: 0 Comm: swapper/2 Not tainted 4.6.3-x86_64 #1
      [    5.622457] Hardware name: HP ProLiant DL360 G5, BIOS P58 05/02/2011
      [    5.622457] task: ffff8801a88f3740 ti: ffff8801a8954000 task.ti: ffff8801a8954000
      [    5.622457] RIP: 0010:[<ffffffff8155e614>]  [<ffffffff8155e614>] qla24xx_process_response_queue+0x44/0x4b0
      [    5.622457] RSP: 0000:ffff8801afb03de8  EFLAGS: 00010002
      [    5.622457] RAX: 0000000000000000 RBX: 0000000000000032 RCX: 00000000ffffffff
      [    5.622457] RDX: 0000000000000002 RSI: ffff8801a79bf8c8 RDI: ffff8800c8f7e7c0
      [    5.622457] RBP: ffff8801afb03e68 R08: 0000000000000000 R09: 0000000000000000
      [    5.622457] R10: 00000000ffff8c47 R11: 0000000000000002 R12: ffff8801a79bf8c8
      [    5.622457] R13: ffff8800c8f7e7c0 R14: ffff8800c8f60000 R15: 0000000000018013
      [    5.622457] FS:  0000000000000000(0000) GS:ffff8801afb00000(0000) knlGS:0000000000000000
      [    5.622457] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [    5.622457] CR2: 0000000000000050 CR3: 0000000001e07000 CR4: 00000000000006e0
      [    5.622457] Stack:
      [    5.622457]  ffff8801afb03e30 ffffffff810c0f2d 0000000000000086 0000000000000002
      [    5.622457]  ffff8801afb03e28 ffffffff816570e1 ffff8800c8994628 0000000000000002
      [    5.622457]  ffff8801afb03e60 ffffffff816772d4 b47c472ad6955e68 0000000000000032
      [    5.622457] Call Trace:
      [    5.622457]  <IRQ>
      [    5.622457]  [<ffffffff810c0f2d>] ? __wake_up_common+0x4d/0x80
      [    5.622457]  [<ffffffff816570e1>] ? usb_hcd_resume_root_hub+0x51/0x60
      [    5.622457]  [<ffffffff816772d4>] ? uhci_hub_status_data+0x64/0x240
      [    5.622457]  [<ffffffff81560d00>] qla24xx_intr_handler+0xf0/0x2e0
      [    5.622457]  [<ffffffff810d569e>] ? get_next_timer_interrupt+0xce/0x200
      [    5.622457]  [<ffffffff810c89b4>] handle_irq_event_percpu+0x64/0x100
      [    5.622457]  [<ffffffff810c8a77>] handle_irq_event+0x27/0x50
      [    5.622457]  [<ffffffff810cb965>] handle_edge_irq+0x65/0x140
      [    5.622457]  [<ffffffff8101a498>] handle_irq+0x18/0x30
      [    5.622457]  [<ffffffff8101a276>] do_IRQ+0x46/0xd0
      [    5.622457]  [<ffffffff817f8fff>] common_interrupt+0x7f/0x7f
      [    5.622457]  <EOI>
      [    5.622457]  [<ffffffff81020d38>] ? mwait_idle+0x68/0x80
      [    5.622457]  [<ffffffff8102114a>] arch_cpu_idle+0xa/0x10
      [    5.622457]  [<ffffffff810c1b97>] default_idle_call+0x27/0x30
      [    5.622457]  [<ffffffff810c1d3b>] cpu_startup_entry+0x19b/0x230
      [    5.622457]  [<ffffffff810324c6>] start_secondary+0x136/0x140
      [    5.622457] Code: 00 00 65 48 8b 04 25 28 00 00 00 48 89 45 d0 31 c0 48 8b 47 58 a8 02 0f 84 c5 00 00 00 48 8b 46 50 49 89 f4 65 8b 15 34 bb aa 7e <39> 50 50 74 11 89 50 50 48 8b 46 50 8b 40 50 41 89 86 60 8b 00
      [    5.622457] RIP  [<ffffffff8155e614>] qla24xx_process_response_queue+0x44/0x4b0
      [    5.622457]  RSP <ffff8801afb03de8>
      [    5.622457] CR2: 0000000000000050
      [    5.622457] ---[ end trace fa2b19c25106d42b ]---
      [    5.622457] Kernel panic - not syncing: Fatal exception in interrupt
      
      The affected code was introduced by commit cdb898c5
      (qla2xxx: Add irq affinity notification).
      
      Only dereference rsp->msix when it has been set so the machine can boot
      fine. Possibly rsp->msix is unset because:
      [    3.479679] qla2xxx [0000:00:00.0]-0005: : QLogic Fibre Channel HBA Driver: 8.07.00.33-k.
      [    3.481839] qla2xxx [0000:13:00.0]-001d: : Found an ISP2432 irq 17 iobase 0xffffc90000038000.
      [    3.484081] qla2xxx [0000:13:00.0]-0035:0: MSI-X; Unsupported ISP2432 (0x2, 0x3).
      [    3.485804] qla2xxx [0000:13:00.0]-0037:0: Falling back-to MSI mode -258.
      [    3.890145] scsi host0: qla2xxx
      [    3.891956] qla2xxx [0000:13:00.0]-00fb:0: QLogic QLE2460 - PCI-Express Single Channel 4Gb Fibre Channel HBA.
      [    3.894207] qla2xxx [0000:13:00.0]-00fc:0: ISP2432: PCIe (2.5GT/s x4) @ 0000:13:00.0 hdma+ host#=0 fw=7.03.00 (9496).
      [    5.714774] qla2xxx [0000:13:00.0]-500a:0: LOOP UP detected (4 Gbps).
      Signed-off-by: default avatarBruno Prémont <bonbons@linux-vserver.org>
      Acked-by: default avatarQuinn Tran <quinn.tran@qlogic.com>
      Fixes: cdb898c5Signed-off-by: default avatarJames Bottomley <jejb@linux.vnet.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ddb2bdc5
    • Paul Burton's avatar
      irqchip/mips-gic: Match IPI IRQ domain by bus token only · 4406733d
      Paul Burton authored
      commit 547aefc4 upstream.
      
      Commit fbde2d7d ("MIPS: Add generic SMP IPI support") introduced
      code which calls irq_find_matching_host with a NULL node parameter in
      order to discover IPI IRQ domains which are not associated with the DT
      root node's interrupt parent. This suggests that implementations of IPI
      IRQ domains should effectively ignore the node parameter if it is NULL
      and search purely based upon the bus token. Commit 2af70a96
      ("irqchip/mips-gic: Add a IPI hierarchy domain") did not do this when
      implementing the GIC IPI IRQ domain, and on MIPS Boston boards this
      leads to no IPI domain being discovered and a NULL pointer dereference
      when attempting to send an IPI:
      
        CPU 0 Unable to handle kernel paging request at virtual address 0000000000000040, epc == ffffffff8016e70c, ra == ffffffff8010ff5c
        Oops[#1]:
        CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.7.0-rc6-00223-gad0d1b6 #945
        task: a8000000ff066fc0 ti: a8000000ff068000 task.ti: a8000000ff068000
        $ 0   : 0000000000000000 0000000000000001 ffffffff80730000 0000000000000003
        $ 4   : 0000000000000000 ffffffff8057e5b0 a800000001e3ee00 0000000000000000
        $ 8   : 0000000000000000 0000000000000023 0000000000000001 0000000000000001
        $12   : 0000000000000000 ffffffff803323d0 0000000000000000 0000000000000000
        $16   : 0000000000000000 0000000000000000 0000000000000001 ffffffff801108fc
        $20   : 0000000000000000 ffffffff8057e5b0 0000000000000001 0000000000000000
        $24   : 0000000000000000 ffffffff8012de28
        $28   : a8000000ff068000 a8000000ff06fbc0 0000000000000000 ffffffff8010ff5c
        Hi    : ffffffff8014c174
        Lo    : a800000001e1e140
        epc   : ffffffff8016e70c __ipi_send_mask+0x24/0x11c
        ra    : ffffffff8010ff5c mips_smp_send_ipi_mask+0x68/0x178
        Status: 140084e2        KX SX UX KERNEL EXL
        Cause : 00800008 (ExcCode 02)
        BadVA : 0000000000000040
        PrId  : 0001a920 (MIPS I6400)
        Process swapper/0 (pid: 1, threadinfo=a8000000ff068000, task=a8000000ff066fc0, tls=0000000000000000)
        Stack : 0000000000000000 0000000000000000 0000000000000001 ffffffff801108fc
                  0000000000000000 ffffffff8057e5b0 0000000000000001 ffffffff8010ff5c
                  0000000000000001 0000000000000020 0000000000000000 0000000000000000
                  0000000000000000 ffffffff801108fc 0000000000000000 0000000000000001
                  0000000000000001 0000000000000000 0000000000000000 ffffffff801865e8
                  a8000000ff0c7500 a8000000ff06fc90 0000000000000001 0000000000000002
                  ffffffff801108fc ffffffff801868b8 0000000000000000 ffffffff801108fc
                  0000000000000000 0000000000000003 ffffffff8068c700 0000000000000001
                  ffffffff80730000 0000000000000001 a8000000ff00a290 ffffffff80110c50
                  0000000000000003 a800000001e48308 0000000000000003 0000000000000008
                  ...
        Call Trace:
        [<ffffffff8016e70c>] __ipi_send_mask+0x24/0x11c
        [<ffffffff8010ff5c>] mips_smp_send_ipi_mask+0x68/0x178
        [<ffffffff801865e8>] generic_exec_single+0x150/0x170
        [<ffffffff801868b8>] smp_call_function_single+0x108/0x160
        [<ffffffff80110c50>] cps_boot_secondary+0x328/0x394
        [<ffffffff80110534>] __cpu_up+0x38/0x90
        [<ffffffff8012de4c>] bringup_cpu+0x24/0xac
        [<ffffffff8012df40>] cpuhp_up_callbacks+0x58/0xdc
        [<ffffffff8012e648>] cpu_up+0x118/0x18c
        [<ffffffff806dc158>] smp_init+0xbc/0xe8
        [<ffffffff806d4c18>] kernel_init_freeable+0xa0/0x228
        [<ffffffff8056c908>] kernel_init+0x10/0xf0
        [<ffffffff80105098>] ret_from_kernel_thread+0x14/0x1c
      
      Fix this by allowing the GIC IPI IRQ domain to match purely based upon
      the bus token if the node provided is NULL.
      
      Fixes: 2af70a96 ("irqchip/mips-gic: Add a IPI hierarchy domain")
      Signed-off-by: default avatarPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: Jason Cooper <jason@lakedaemon.net>
      Cc: Qais Yousef <qsyousef@gmail.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Link: http://lkml.kernel.org/r/20160705132600.27730-2-paul.burton@imgtec.comSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4406733d
    • Paul Burton's avatar
      irqchip/mips-gic: Map to VPs using HW VPNum · 42c33fde
      Paul Burton authored
      commit 99ec8a36 upstream.
      
      When mapping an interrupt to a VP(E) we must use the identifier for the
      VP that the hardware expects, and this does not always match up with the
      Linux CPU number. Commit d46812bb ("irqchip: mips-gic: Use HW IDs
      for VPE_OTHER_ADDR") corrected this for the cases that existed at the
      time it was written, but commit 2af70a96 ("irqchip/mips-gic: Add a
      IPI hierarchy domain") added another case before the former patch was
      merged. This leads to incorrectly using Linux CPU numbers when mapping
      interrupts to VPs, which breaks on certain systems such as those with
      multi-core I6400 CPUs. Fix by adding the appropriate call to
      mips_cm_vp_id() to retrieve the expected VP identifier.
      
      Fixes: d46812bb ("irqchip: mips-gic: Use HW IDs for VPE_OTHER_ADDR")
      Fixes: 2af70a96 ("irqchip/mips-gic: Add a IPI hierarchy domain")
      Signed-off-by: default avatarPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: Jason Cooper <jason@lakedaemon.net>
      Cc: Qais Yousef <qsyousef@gmail.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Link: http://lkml.kernel.org/r/20160705132600.27730-1-paul.burton@imgtec.comSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      42c33fde
    • Vegard Nossum's avatar
      RDS: fix rds_tcp_init() error path · d71872a9
      Vegard Nossum authored
      commit 3dad5424 upstream.
      
      If register_pernet_subsys() fails, we shouldn't try to call
      unregister_pernet_subsys().
      
      Fixes: 467fa153 ("RDS-TCP: Support multiple RDS-TCP listen endpoints, one per netns.")
      Cc: Sowmini Varadhan <sowmini.varadhan@oracle.com>
      Cc: David S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarVegard Nossum <vegard.nossum@oracle.com>
      Acked-by: default avatarSowmini Varadhan <sowmini.varadhan@oracle.com>
      Acked-by: default avatarSantosh Shilimkar <santosh.shilimkar@oracle.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d71872a9
    • Oliver Hartkopp's avatar
      can: fix oops caused by wrong rtnl dellink usage · f3f8ae8b
      Oliver Hartkopp authored
      commit 25e1ed6e upstream.
      
      For 'real' hardware CAN devices the netlink interface is used to set CAN
      specific communication parameters. Real CAN hardware can not be created nor
      removed with the ip tool ...
      
      This patch adds a private dellink function for the CAN device driver interface
      that does just nothing.
      
      It's a follow up to commit 993e6f2f ("can: fix oops caused by wrong rtnl
      newlink usage") but for dellink.
      Reported-by: default avatarajneu <ajneu1@gmail.com>
      Signed-off-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f3f8ae8b
    • Oliver Hartkopp's avatar
      can: fix handling of unmodifiable configuration options fix · 171cf1dc
      Oliver Hartkopp authored
      commit bce271f2 upstream.
      
      With upstream commit bb208f14 (can: fix handling of unmodifiable
      configuration options) a new can_validate() function was introduced.
      
      When invoking 'ip link set can0 type can' without any configuration data
      can_validate() tries to validate the content without taking into account that
      there's totally no content. This patch adds a check for missing content.
      Reported-by: default avatarajneu <ajneu1@gmail.com>
      Signed-off-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      171cf1dc
    • Thor Thayer's avatar
      can: c_can: Update D_CAN TX and RX functions to 32 bit - fix Altera Cyclone access · 07562cc2
      Thor Thayer authored
      commit 427460c8 upstream.
      
      When testing CAN write floods on Altera's CycloneV, the first 2 bytes
      are sometimes 0x00, 0x00 or corrupted instead of the values sent. Also
      observed bytes 4 & 5 were corrupted in some cases.
      
      The D_CAN Data registers are 32 bits and changing from 16 bit writes to
      32 bit writes fixes the problem.
      
      Testing performed on Altera CycloneV (D_CAN).  Requesting tests on other
      C_CAN & D_CAN platforms.
      Reported-by: default avatarRichard Andrysek <richard.andrysek@gomtec.de>
      Signed-off-by: default avatarThor Thayer <tthayer@opensource.altera.com>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      07562cc2
    • Wolfgang Grandegger's avatar
      can: at91_can: RX queue could get stuck at high bus load · 88e08b41
      Wolfgang Grandegger authored
      commit 43200a44 upstream.
      
      At high bus load it could happen that "at91_poll()" enters with all RX
      message boxes filled up. If then at the end the "quota" is exceeded as
      well, "rx_next" will not be reset to the first RX mailbox and hence the
      interrupts remain disabled.
      Signed-off-by: default avatarWolfgang Grandegger <wg@grandegger.com>
      Tested-by: default avatarAmr Bekhit <amrbekhit@gmail.com>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      88e08b41
    • Peter Zijlstra's avatar
      sched/fair: Fix effective_load() to consistently use smoothed load · 81dc1601
      Peter Zijlstra authored
      commit 7dd49125 upstream.
      
      Starting with the following commit:
      
        fde7d22e ("sched/fair: Fix overly small weight for interactive group entities")
      
      calc_tg_weight() doesn't compute the right value as expected by effective_load().
      
      The difference is in the 'correction' term. In order to ensure \Sum
      rw_j >= rw_i we cannot use tg->load_avg directly, since that might be
      lagging a correction on the current cfs_rq->avg.load_avg value.
      Therefore we use tg->load_avg - cfs_rq->tg_load_avg_contrib +
      cfs_rq->avg.load_avg.
      
      Now, per the referenced commit, calc_tg_weight() doesn't use
      cfs_rq->avg.load_avg, as is later used in @w, but uses
      cfs_rq->load.weight instead.
      
      So stop using calc_tg_weight() and do it explicitly.
      
      The effects of this bug are wake_affine() making randomly
      poor choices in cgroup-intense workloads.
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Fixes: fde7d22e ("sched/fair: Fix overly small weight for interactive group entities")
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      81dc1601
    • Taras Kondratiuk's avatar
      mmc: block: fix packed command header endianness · 8815298c
      Taras Kondratiuk authored
      commit f68381a7 upstream.
      
      The code that fills packed command header assumes that CPU runs in
      little-endian mode. Hence the header is malformed in big-endian mode
      and causes MMC data transfer errors:
      
      [  563.200828] mmcblk0: error -110 transferring data, sector 2048, nr 8, cmd response 0x900, card status 0xc40
      [  563.219647] mmcblk0: packed cmd failed, nr 2, sectors 16, failure index: -1
      
      Convert header data to LE.
      Signed-off-by: default avatarTaras Kondratiuk <takondra@cisco.com>
      Fixes: ce39f9d1 ("mmc: support packed write command for eMMC4.5 devices")
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8815298c
    • Ville Viinikka's avatar
      mmc: block: fix free of uninitialized 'idata->buf' · 5e8087b3
      Ville Viinikka authored
      commit bfe5b1b1 upstream.
      
      Set 'idata->buf' to NULL so that it never gets returned without
      initialization. This fixes a bug where mmc_blk_ioctl_cmd() would
      free both 'idata' and 'idata->buf' but 'idata->buf' was returned
      uninitialized.
      
      Fixes: 1ff8950c ("mmc: block: change to use kmalloc when copy data from userspace")
      Signed-off-by: default avatarVille Viinikka <ville@tuxera.com>
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5e8087b3
    • Omar Sandoval's avatar
      block: fix use-after-free in sys_ioprio_get() · 5c72cc56
      Omar Sandoval authored
      commit 8ba86821 upstream.
      
      get_task_ioprio() accesses the task->io_context without holding the task
      lock and thus can race with exit_io_context(), leading to a
      use-after-free. The reproducer below hits this within a few seconds on
      my 4-core QEMU VM:
      
      #define _GNU_SOURCE
      #include <assert.h>
      #include <unistd.h>
      #include <sys/syscall.h>
      #include <sys/wait.h>
      
      int main(int argc, char **argv)
      {
      	pid_t pid, child;
      	long nproc, i;
      
      	/* ioprio_set(IOPRIO_WHO_PROCESS, 0, IOPRIO_PRIO_VALUE(IOPRIO_CLASS_IDLE, 0)); */
      	syscall(SYS_ioprio_set, 1, 0, 0x6000);
      
      	nproc = sysconf(_SC_NPROCESSORS_ONLN);
      
      	for (i = 0; i < nproc; i++) {
      		pid = fork();
      		assert(pid != -1);
      		if (pid == 0) {
      			for (;;) {
      				pid = fork();
      				assert(pid != -1);
      				if (pid == 0) {
      					_exit(0);
      				} else {
      					child = wait(NULL);
      					assert(child == pid);
      				}
      			}
      		}
      
      		pid = fork();
      		assert(pid != -1);
      		if (pid == 0) {
      			for (;;) {
      				/* ioprio_get(IOPRIO_WHO_PGRP, 0); */
      				syscall(SYS_ioprio_get, 2, 0);
      			}
      		}
      	}
      
      	for (;;) {
      		/* ioprio_get(IOPRIO_WHO_PGRP, 0); */
      		syscall(SYS_ioprio_get, 2, 0);
      	}
      
      	return 0;
      }
      
      This gets us KASAN dumps like this:
      
      [   35.526914] ==================================================================
      [   35.530009] BUG: KASAN: out-of-bounds in get_task_ioprio+0x7b/0x90 at addr ffff880066f34e6c
      [   35.530009] Read of size 2 by task ioprio-gpf/363
      [   35.530009] =============================================================================
      [   35.530009] BUG blkdev_ioc (Not tainted): kasan: bad access detected
      [   35.530009] -----------------------------------------------------------------------------
      
      [   35.530009] Disabling lock debugging due to kernel taint
      [   35.530009] INFO: Allocated in create_task_io_context+0x2b/0x370 age=0 cpu=0 pid=360
      [   35.530009] 	___slab_alloc+0x55d/0x5a0
      [   35.530009] 	__slab_alloc.isra.20+0x2b/0x40
      [   35.530009] 	kmem_cache_alloc_node+0x84/0x200
      [   35.530009] 	create_task_io_context+0x2b/0x370
      [   35.530009] 	get_task_io_context+0x92/0xb0
      [   35.530009] 	copy_process.part.8+0x5029/0x5660
      [   35.530009] 	_do_fork+0x155/0x7e0
      [   35.530009] 	SyS_clone+0x19/0x20
      [   35.530009] 	do_syscall_64+0x195/0x3a0
      [   35.530009] 	return_from_SYSCALL_64+0x0/0x6a
      [   35.530009] INFO: Freed in put_io_context+0xe7/0x120 age=0 cpu=0 pid=1060
      [   35.530009] 	__slab_free+0x27b/0x3d0
      [   35.530009] 	kmem_cache_free+0x1fb/0x220
      [   35.530009] 	put_io_context+0xe7/0x120
      [   35.530009] 	put_io_context_active+0x238/0x380
      [   35.530009] 	exit_io_context+0x66/0x80
      [   35.530009] 	do_exit+0x158e/0x2b90
      [   35.530009] 	do_group_exit+0xe5/0x2b0
      [   35.530009] 	SyS_exit_group+0x1d/0x20
      [   35.530009] 	entry_SYSCALL_64_fastpath+0x1a/0xa4
      [   35.530009] INFO: Slab 0xffffea00019bcd00 objects=20 used=4 fp=0xffff880066f34ff0 flags=0x1fffe0000004080
      [   35.530009] INFO: Object 0xffff880066f34e58 @offset=3672 fp=0x0000000000000001
      [   35.530009] ==================================================================
      
      Fix it by grabbing the task lock while we poke at the io_context.
      Reported-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Signed-off-by: default avatarOmar Sandoval <osandov@fb.com>
      Signed-off-by: default avatarJens Axboe <axboe@fb.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5c72cc56
    • Randy Dunlap's avatar
      init/Kconfig: keep Expert users menu together · ad2591f0
      Randy Dunlap authored
      commit 076501ff upstream.
      
      The "expert" menu was broken (split) such that all entries in it after
      KALLSYMS were displayed in the "General setup" area instead of in the
      "Expert users" area.  Fix this by adding one kconfig dependency.
      
      Yes, the Expert users menu is fragile.  Problems like this have happened
      several times in the past.  I will attempt to isolate the Expert users
      menu if there is interest in that.
      
      Fixes: 4d5d5664 ("x86: kallsyms: disable absolute percpu symbols on !SMP")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ad2591f0
    • Ursula Braun's avatar
      qeth: delete napi struct when removing a qeth device · 635814d2
      Ursula Braun authored
      commit 7831b4ff upstream.
      
      A qeth_card contains a napi_struct linked to the net_device during
      device probing. This struct must be deleted when removing the qeth
      device, otherwise Panic on oops can occur when qeth devices are
      repeatedly removed and added.
      
      Fixes: a1c3ed4c ("qeth: NAPI support for l2 and l3 discipline")
      Signed-off-by: default avatarUrsula Braun <ubraun@linux.vnet.ibm.com>
      Tested-by: default avatarAlexander Klein <ALKL@de.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      635814d2
    • Dan Carpenter's avatar
      platform/chrome: cros_ec_dev - double fetch bug in ioctl · 68b0cefc
      Dan Carpenter authored
      commit 096cdc6f upstream.
      
      We verify "u_cmd.outsize" and "u_cmd.insize" but we need to make sure
      that those values have not changed between the two copy_from_user()
      calls.  Otherwise it could lead to a buffer overflow.
      
      Additionally, cros_ec_cmd_xfer() can set s_cmd->insize to a lower value.
      We should use the new smaller value so we don't copy too much data to
      the user.
      Reported-by: default avatarPengfei Wang <wpengfeinudt@gmail.com>
      Fixes: a8411784 ('mfd: cros_ec: Use a zero-length array for command data')
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Tested-by: default avatarGwendal Grignou <gwendal@chromium.org>
      Signed-off-by: default avatarOlof Johansson <olof@lixom.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      68b0cefc
    • Scott Mayhew's avatar
      lockd: unregister notifier blocks if the service fails to come up completely · f54a878c
      Scott Mayhew authored
      commit cb7d224f upstream.
      
      If the lockd service fails to start up then we need to be sure that the
      notifier blocks are not registered, otherwise a subsequent start of the
      service could cause the same notifier to be registered twice, leading to
      soft lockups.
      Signed-off-by: default avatarScott Mayhew <smayhew@redhat.com>
      Fixes: 0751ddf7 "lockd: Register callbacks on the inetaddr_chain..."
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f54a878c
    • Boris Brezillon's avatar
      clk: at91: fix clk_programmable_set_parent() · 3e70b591
      Boris Brezillon authored
      commit f96423f4 upstream.
      
      Since commit 1bdf0232 ("clk: at91: make use of syscon/regmap
      internally"), clk_programmable_set_parent() is always selecting the
      first parent (AKA slow_clk), no matter what's passed in the 'index'
      parameter.
      
      Fix that by initializing the pckr variable to the index value.
      Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
      Reported-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Fixes: 1bdf0232 ("clk: at91: make use of syscon/regmap internally")
      Signed-off-by: default avatarMichael Turquette <mturquette@baylibre.com>
      Link: lkml.kernel.org/r/1468828152-18389-1-git-send-email-boris.brezillon@free-electrons.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3e70b591
    • Heiko Stuebner's avatar
      clk: rockchip: initialize flags of clk_init_data in mmc-phase clock · 690a5f1e
      Heiko Stuebner authored
      commit 595144c1 upstream.
      
      The flags element of clk_init_data was never initialized for mmc-
      phase-clocks resulting in the element containing a random value
      and thus possibly enabling unwanted clock flags.
      
      Fixes: 89bf26cb ("clk: rockchip: Add support for the mmc clock phases using the framework")
      Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      690a5f1e
    • Michal Suchanek's avatar
      spi: sun4i: fix FIFO limit · bb70d865
      Michal Suchanek authored
      commit 6d9fe44b upstream.
      
      When testing SPI without DMA I noticed that filling the FIFO on the
      spi controller causes timeout.
      
      Always leave room for one byte in the FIFO.
      Signed-off-by: default avatarMichal Suchanek <hramrach@gmail.com>
      Acked-by: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bb70d865
    • Michal Suchanek's avatar
      spi: sunxi: fix transfer timeout · 3fe82d1e
      Michal Suchanek authored
      commit 719bd654 upstream.
      
      The trasfer timeout is fixed at 1000 ms. Reading a 4Mbyte flash over
      1MHz SPI bus takes way longer than that. Calculate the timeout from the
      actual time the transfer is supposed to take and multiply by 2 for good
      measure.
      Signed-off-by: default avatarMichal Suchanek <hramrach@gmail.com>
      Acked-by: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3fe82d1e
    • Tomeu Vizoso's avatar
      spi: rockchip: Signal unfinished DMA transfers · ef40d3f3
      Tomeu Vizoso authored
      commit 4dc0dd83 upstream.
      
      When using DMA, the transfer_one callback should return 1 because the
      transfer hasn't finished yet.
      
      A previous commit changed the function to return 0 when the DMA channels
      were correctly prepared.
      
      This manifested in Veyron boards with this message:
      
      [ 1.983605] cros-ec-spi spi0.0: EC failed to respond in time
      
      Fixes: ea984911 ("spi: rockchip: check return value of dmaengine_prep_slave_sg")
      Signed-off-by: default avatarTomeu Vizoso <tomeu.vizoso@collabora.com>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ef40d3f3
    • Andrey Ulanov's avatar
      namespace: update event counter when umounting a deleted dentry · 7b1789f9
      Andrey Ulanov authored
      commit e06b933e upstream.
      
      - m_start() in fs/namespace.c expects that ns->event is incremented each
        time a mount added or removed from ns->list.
      - umount_tree() removes items from the list but does not increment event
        counter, expecting that it's done before the function is called.
      - There are some codepaths that call umount_tree() without updating
        "event" counter. e.g. from __detach_mounts().
      - When this happens m_start may reuse a cached mount structure that no
        longer belongs to ns->list (i.e. use after free which usually leads
        to infinite loop).
      
      This change fixes the above problem by incrementing global event counter
      before invoking umount_tree().
      
      Change-Id: I622c8e84dcb9fb63542372c5dbf0178ee86bb589
      Signed-off-by: default avatarAndrey Ulanov <andreyu@google.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7b1789f9
    • Colin Ian King's avatar
      devpts: fix null pointer dereference on failed memory allocation · a0292a0f
      Colin Ian King authored
      commit 5353ed8d upstream.
      
      An ENOMEM when creating a pair tty in tty_ldisc_setup causes a null
      pointer dereference in devpts_kill_index because tty->link->driver_data
      is NULL.  The oops was triggered with the pty stressor in stress-ng when
      in a low memory condition.
      
      tty_init_dev tries to clean up a tty_ldisc_setup ENOMEM error by calling
      release_tty, however, this ultimately tries to clean up the NULL pair'd
      tty in pty_unix98_remove, triggering the Oops.
      
      Add check to pty_unix98_remove to only clean up fsi if it is not NULL.
      
      Ooops:
      
      [   23.020961] Oops: 0000 [#1] SMP
      [   23.020976] Modules linked in: ppdev snd_hda_codec_generic snd_hda_intel snd_hda_codec parport_pc snd_hda_core snd_hwdep parport snd_pcm input_leds joydev snd_timer serio_raw snd soundcore i2c_piix4 mac_hid ib_iser rdma_cm iw_cm ib_cm ib_core configfs iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi autofs4 btrfs raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pq libcrc32c raid1 raid0 multipath linear crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel qxl aes_x86_64 ttm lrw gf128mul glue_helper ablk_helper drm_kms_helper cryptd syscopyarea sysfillrect psmouse sysimgblt floppy fb_sys_fops drm pata_acpi jitterentropy_rng drbg ansi_cprng
      [   23.020978] CPU: 0 PID: 1452 Comm: stress-ng-pty Not tainted 4.7.0-rc4+ #2
      [   23.020978] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
      [   23.020979] task: ffff88007ba30000 ti: ffff880078ea8000 task.ti: ffff880078ea8000
      [   23.020981] RIP: 0010:[<ffffffff813f11ff>]  [<ffffffff813f11ff>] ida_remove+0x1f/0x120
      [   23.020981] RSP: 0018:ffff880078eabb60  EFLAGS: 00010a03
      [   23.020982] RAX: 4444444444444567 RBX: 0000000000000000 RCX: 000000000000001f
      [   23.020982] RDX: 000000000000014c RSI: 000000000000026f RDI: 0000000000000000
      [   23.020982] RBP: ffff880078eabb70 R08: 0000000000000004 R09: 0000000000000036
      [   23.020983] R10: 000000000000026f R11: 0000000000000000 R12: 000000000000026f
      [   23.020983] R13: 000000000000026f R14: ffff88007c944b40 R15: 000000000000026f
      [   23.020984] FS:  00007f9a2f3cc700(0000) GS:ffff88007fc00000(0000) knlGS:0000000000000000
      [   23.020984] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   23.020985] CR2: 0000000000000010 CR3: 000000006c81b000 CR4: 00000000001406f0
      [   23.020988] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [   23.020988] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [   23.020988] Stack:
      [   23.020989]  0000000000000000 000000000000026f ffff880078eabb90 ffffffff812a5a99
      [   23.020990]  0000000000000000 00000000fffffff4 ffff880078eabba8 ffffffff814f9cbe
      [   23.020991]  ffff88007965c800 ffff880078eabbc8 ffffffff814eef43 fffffffffffffff4
      [   23.020991] Call Trace:
      [   23.021000]  [<ffffffff812a5a99>] devpts_kill_index+0x29/0x50
      [   23.021002]  [<ffffffff814f9cbe>] pty_unix98_remove+0x2e/0x50
      [   23.021006]  [<ffffffff814eef43>] release_tty+0xb3/0x1b0
      [   23.021007]  [<ffffffff814f18d4>] tty_init_dev+0xd4/0x1c0
      [   23.021011]  [<ffffffff814f9fae>] ptmx_open+0xae/0x190
      [   23.021013]  [<ffffffff812254ef>] chrdev_open+0xbf/0x1b0
      [   23.021015]  [<ffffffff8121d973>] do_dentry_open+0x203/0x310
      [   23.021016]  [<ffffffff81225430>] ? cdev_put+0x30/0x30
      [   23.021017]  [<ffffffff8121ee44>] vfs_open+0x54/0x80
      [   23.021018]  [<ffffffff8122b8fc>] ? may_open+0x8c/0x100
      [   23.021019]  [<ffffffff8122f26b>] path_openat+0x2eb/0x1440
      [   23.021020]  [<ffffffff81230534>] ? putname+0x54/0x60
      [   23.021022]  [<ffffffff814f6f97>] ? n_tty_ioctl_helper+0x27/0x100
      [   23.021023]  [<ffffffff81231651>] do_filp_open+0x91/0x100
      [   23.021024]  [<ffffffff81230596>] ? getname_flags+0x56/0x1f0
      [   23.021026]  [<ffffffff8123fc66>] ? __alloc_fd+0x46/0x190
      [   23.021027]  [<ffffffff8121f1e4>] do_sys_open+0x124/0x210
      [   23.021028]  [<ffffffff8121f2ee>] SyS_open+0x1e/0x20
      [   23.021035]  [<ffffffff81845576>] entry_SYSCALL_64_fastpath+0x1e/0xa8
      [   23.021044] Code: 63 28 45 31 e4 eb dd 0f 1f 44 00 00 55 4c 63 d6 48 ba 89 88 88 88 88 88 88 88 4c 89 d0 b9 1f 00 00 00 48 f7 e2 48 89 e5 41 54 53 <8b> 47 10 48 89 fb 8d 3c c5 00 00 00 00 48 c1 ea 09 b8 01 00 00
      [   23.021045] RIP  [<ffffffff813f11ff>] ida_remove+0x1f/0x120
      [   23.021045]  RSP <ffff880078eabb60>
      [   23.021046] CR2: 0000000000000010
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a0292a0f
    • Rafael J. Wysocki's avatar
      cpufreq: Avoid false-positive WARN_ON()s in cpufreq_update_policy() · 4be5c33b
      Rafael J. Wysocki authored
      commit 742c87bf upstream.
      
      CPU notifications from the firmware coming in when cpufreq is
      suspended cause cpufreq_update_current_freq() to return 0 which
      triggers the WARN_ON() in cpufreq_update_policy() for no reason.
      
      Avoid that by checking cpufreq_suspended before calling
      cpufreq_update_current_freq().
      
      Fixes: c9d9c929 (cpufreq: Abort cpufreq_update_current_freq() for cpufreq_suspended set)
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4be5c33b
    • Miklos Szeredi's avatar
      9p: use file_dentry() · 8b592e2a
      Miklos Szeredi authored
      commit b403f0e3 upstream.
      
      v9fs may be used as lower layer of overlayfs and accessing f_path.dentry
      can lead to a crash.  In this case it's a NULL pointer dereference in
      p9_fid_create().
      
      Fix by replacing direct access of file->f_path.dentry with the
      file_dentry() accessor, which will always return a native object.
      Reported-by: default avatarAlessio Igor Bogani <alessioigorbogani@gmail.com>
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Tested-by: default avatarAlessio Igor Bogani <alessioigorbogani@gmail.com>
      Fixes: 4bacc9c9 ("overlayfs: Make f_path always point to the overlay and f_inode to the underlay")
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8b592e2a
    • Vegard Nossum's avatar
      ext4: verify extent header depth · af2be3d2
      Vegard Nossum authored
      commit 7bc94916 upstream.
      
      Although the extent tree depth of 5 should enough be for the worst
      case of 2*32 extents of length 1, the extent tree code does not
      currently to merge nodes which are less than half-full with a sibling
      node, or to shrink the tree depth if possible.  So it's possible, at
      least in theory, for the tree depth to be greater than 5.  However,
      even in the worst case, a tree depth of 32 is highly unlikely, and if
      the file system is maliciously corrupted, an insanely large eh_depth
      can cause memory allocation failures that will trigger kernel warnings
      (here, eh_depth = 65280):
      
          JBD2: ext4.exe wants too many credits credits:195849 rsv_credits:0 max:256
          ------------[ cut here ]------------
          WARNING: CPU: 0 PID: 50 at fs/jbd2/transaction.c:293 start_this_handle+0x569/0x580
          CPU: 0 PID: 50 Comm: ext4.exe Not tainted 4.7.0-rc5+ #508
          Stack:
           604a8947 625badd8 0002fd09 00000000
           60078643 00000000 62623910 601bf9bc
           62623970 6002fc84 626239b0 900000125
          Call Trace:
           [<6001c2dc>] show_stack+0xdc/0x1a0
           [<601bf9bc>] dump_stack+0x2a/0x2e
           [<6002fc84>] __warn+0x114/0x140
           [<6002fdff>] warn_slowpath_null+0x1f/0x30
           [<60165829>] start_this_handle+0x569/0x580
           [<60165d4e>] jbd2__journal_start+0x11e/0x220
           [<60146690>] __ext4_journal_start_sb+0x60/0xa0
           [<60120a81>] ext4_truncate+0x131/0x3a0
           [<60123677>] ext4_setattr+0x757/0x840
           [<600d5d0f>] notify_change+0x16f/0x2a0
           [<600b2b16>] do_truncate+0x76/0xc0
           [<600c3e56>] path_openat+0x806/0x1300
           [<600c55c9>] do_filp_open+0x89/0xf0
           [<600b4074>] do_sys_open+0x134/0x1e0
           [<600b4140>] SyS_open+0x20/0x30
           [<6001ea68>] handle_syscall+0x88/0x90
           [<600295fd>] userspace+0x3fd/0x500
           [<6001ac55>] fork_handler+0x85/0x90
      
          ---[ end trace 08b0b88b6387a244 ]---
      
      [ Commit message modified and the extent tree depath check changed
      from 5 to 32 -- tytso ]
      
      Cc: Darrick J. Wong <darrick.wong@oracle.com>
      Signed-off-by: default avatarVegard Nossum <vegard.nossum@oracle.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      af2be3d2
    • Jeff Mahoney's avatar
      ecryptfs: don't allow mmap when the lower fs doesn't support it · f7803b2f
      Jeff Mahoney authored
      commit f0fe970d upstream.
      
      There are legitimate reasons to disallow mmap on certain files, notably
      in sysfs or procfs.  We shouldn't emulate mmap support on file systems
      that don't offer support natively.
      
      CVE-2016-1583
      Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
      [tyhicks: clean up f_op check by using ecryptfs_file_to_lower()]
      Signed-off-by: default avatarTyler Hicks <tyhicks@canonical.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f7803b2f
    • Jeff Mahoney's avatar
      Revert "ecryptfs: forbid opening files without mmap handler" · 9cd0ae8d
      Jeff Mahoney authored
      commit 78c4e172 upstream.
      
      This reverts commit 2f36db71.
      
      It fixed a local root exploit but also introduced a dependency on
      the lower file system implementing an mmap operation just to open a file,
      which is a bit of a heavy hammer.  The right fix is to have mmap depend
      on the existence of the mmap handler instead.
      Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
      Signed-off-by: default avatarTyler Hicks <tyhicks@canonical.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9cd0ae8d
    • Miklos Szeredi's avatar
      locks: use file_inode() · e629d6d9
      Miklos Szeredi authored
      commit 6343a212 upstream.
      
      (Another one for the f_path debacle.)
      
      ltp fcntl33 testcase caused an Oops in selinux_file_send_sigiotask.
      
      The reason is that generic_add_lease() used filp->f_path.dentry->inode
      while all the others use file_inode().  This makes a difference for files
      opened on overlayfs since the former will point to the overlay inode the
      latter to the underlying inode.
      
      So generic_add_lease() added the lease to the overlay inode and
      generic_delete_lease() removed it from the underlying inode.  When the file
      was released the lease remained on the overlay inode's lock list, resulting
      in use after free.
      Reported-by: default avatarEryu Guan <eguan@redhat.com>
      Fixes: 4bacc9c9 ("overlayfs: Make f_path always point to the overlay and f_inode to the underlay")
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Reviewed-by: default avatarJeff Layton <jlayton@redhat.com>
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e629d6d9
    • Rhyland Klein's avatar
      power_supply: power_supply_read_temp only if use_cnt > 0 · 3f0f77b6
      Rhyland Klein authored
      commit 5bc28b93 upstream.
      
      Change power_supply_read_temp() to use power_supply_get_property()
      so that it will check the use_cnt and ensure it is > 0. The use_cnt
      will be incremented at the end of __power_supply_register, so this
      will block to case where get_property can be called before the supply
      is fully registered. This fixes the issue show in the stack below:
      
      [    1.452598] power_supply_read_temp+0x78/0x80
      [    1.458680] thermal_zone_get_temp+0x5c/0x11c
      [    1.464765] thermal_zone_device_update+0x34/0xb4
      [    1.471195] thermal_zone_device_register+0x87c/0x8cc
      [    1.477974] __power_supply_register+0x364/0x424
      [    1.484317] power_supply_register_no_ws+0x10/0x18
      [    1.490833] bq27xxx_battery_setup+0x10c/0x164
      [    1.497003] bq27xxx_battery_i2c_probe+0xd0/0x1b0
      [    1.503435] i2c_device_probe+0x174/0x240
      [    1.509172] driver_probe_device+0x1fc/0x29c
      [    1.515167] __driver_attach+0xa4/0xa8
      [    1.520643] bus_for_each_dev+0x58/0x98
      [    1.526204] driver_attach+0x20/0x28
      [    1.531505] bus_add_driver+0x1c8/0x22c
      [    1.537067] driver_register+0x68/0x108
      [    1.542630] i2c_register_driver+0x38/0x7c
      [    1.548457] bq27xxx_battery_i2c_driver_init+0x18/0x20
      [    1.555321] do_one_initcall+0x38/0x12c
      [    1.560886] kernel_init_freeable+0x148/0x1ec
      [    1.566972] kernel_init+0x10/0xfc
      [    1.572101] ret_from_fork+0x10/0x40
      
      Also make the same change to ps_get_max_charge_cntl_limit() and
      ps_get_cur_chrage_cntl_limit() to be safe. Lastly, change the return
      value of power_supply_get_property() to -EAGAIN from -ENODEV if
      use_cnt <= 0.
      
      Fixes: 297d716f ("power_supply: Change ownership from driver to core")
      Signed-off-by: default avatarRhyland Klein <rklein@nvidia.com>
      Reviewed-by: default avatarKrzysztof Kozlowski <k.kozlowski@samsung.com>
      Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3f0f77b6
    • Daniel Bristot de Oliveira's avatar
      cgroup: Disable IRQs while holding css_set_lock · 2644b978
      Daniel Bristot de Oliveira authored
      commit 82d6489d upstream.
      
      While testing the deadline scheduler + cgroup setup I hit this
      warning.
      
      [  132.612935] ------------[ cut here ]------------
      [  132.612951] WARNING: CPU: 5 PID: 0 at kernel/softirq.c:150 __local_bh_enable_ip+0x6b/0x80
      [  132.612952] Modules linked in: (a ton of modules...)
      [  132.612981] CPU: 5 PID: 0 Comm: swapper/5 Not tainted 4.7.0-rc2 #2
      [  132.612981] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.8.2-20150714_191134- 04/01/2014
      [  132.612982]  0000000000000086 45c8bb5effdd088b ffff88013fd43da0 ffffffff813d229e
      [  132.612984]  0000000000000000 0000000000000000 ffff88013fd43de0 ffffffff810a652b
      [  132.612985]  00000096811387b5 0000000000000200 ffff8800bab29d80 ffff880034c54c00
      [  132.612986] Call Trace:
      [  132.612987]  <IRQ>  [<ffffffff813d229e>] dump_stack+0x63/0x85
      [  132.612994]  [<ffffffff810a652b>] __warn+0xcb/0xf0
      [  132.612997]  [<ffffffff810e76a0>] ? push_dl_task.part.32+0x170/0x170
      [  132.612999]  [<ffffffff810a665d>] warn_slowpath_null+0x1d/0x20
      [  132.613000]  [<ffffffff810aba5b>] __local_bh_enable_ip+0x6b/0x80
      [  132.613008]  [<ffffffff817d6c8a>] _raw_write_unlock_bh+0x1a/0x20
      [  132.613010]  [<ffffffff817d6c9e>] _raw_spin_unlock_bh+0xe/0x10
      [  132.613015]  [<ffffffff811388ac>] put_css_set+0x5c/0x60
      [  132.613016]  [<ffffffff8113dc7f>] cgroup_free+0x7f/0xa0
      [  132.613017]  [<ffffffff810a3912>] __put_task_struct+0x42/0x140
      [  132.613018]  [<ffffffff810e776a>] dl_task_timer+0xca/0x250
      [  132.613027]  [<ffffffff810e76a0>] ? push_dl_task.part.32+0x170/0x170
      [  132.613030]  [<ffffffff8111371e>] __hrtimer_run_queues+0xee/0x270
      [  132.613031]  [<ffffffff81113ec8>] hrtimer_interrupt+0xa8/0x190
      [  132.613034]  [<ffffffff81051a58>] local_apic_timer_interrupt+0x38/0x60
      [  132.613035]  [<ffffffff817d9b0d>] smp_apic_timer_interrupt+0x3d/0x50
      [  132.613037]  [<ffffffff817d7c5c>] apic_timer_interrupt+0x8c/0xa0
      [  132.613038]  <EOI>  [<ffffffff81063466>] ? native_safe_halt+0x6/0x10
      [  132.613043]  [<ffffffff81037a4e>] default_idle+0x1e/0xd0
      [  132.613044]  [<ffffffff810381cf>] arch_cpu_idle+0xf/0x20
      [  132.613046]  [<ffffffff810e8fda>] default_idle_call+0x2a/0x40
      [  132.613047]  [<ffffffff810e92d7>] cpu_startup_entry+0x2e7/0x340
      [  132.613048]  [<ffffffff81050235>] start_secondary+0x155/0x190
      [  132.613049] ---[ end trace f91934d162ce9977 ]---
      
      The warn is the spin_(lock|unlock)_bh(&css_set_lock) in the interrupt
      context. Converting the spin_lock_bh to spin_lock_irq(save) to avoid
      this problem - and other problems of sharing a spinlock with an
      interrupt.
      
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Li Zefan <lizefan@huawei.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Juri Lelli <juri.lelli@arm.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: cgroups@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Reviewed-by: default avatarRik van Riel <riel@redhat.com>
      Reviewed-by: default avatar"Luis Claudio R. Goncalves" <lgoncalv@redhat.com>
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@redhat.com>
      Acked-by: default avatarZefan Li <lizefan@huawei.com>
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2644b978
    • Tejun Heo's avatar
      cgroup: set css->id to -1 during init · 65856851
      Tejun Heo authored
      commit 8fa3b8d6 upstream.
      
      If percpu_ref initialization fails during css_create(), the free path
      can end up trying to free css->id of zero.  As ID 0 is unused, it
      doesn't cause a critical breakage but it does trigger a warning
      message.  Fix it by setting css->id to -1 from init_and_link_css().
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Wenwei Tao <ww.tao0320@gmail.com>
      Fixes: 01e58659 ("cgroup: release css->id after css_free")
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      65856851
    • Wenwei Tao's avatar
      cgroup: remove redundant cleanup in css_create · 64e7dc48
      Wenwei Tao authored
      commit b00c52da upstream.
      
      When create css failed, before call css_free_rcu_fn, we remove the css
      id and exit the percpu_ref, but we will do these again in
      css_free_work_fn, so they are redundant.  Especially the css id, that
      would cause problem if we remove it twice, since it may be assigned to
      another css after the first remove.
      
      tj: This was broken by two commits updating the free path without
          synchronizing the creation failure path.  This can be easily
          triggered by trying to create more than 64k memory cgroups.
      Signed-off-by: default avatarWenwei Tao <ww.tao0320@gmail.com>
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Vladimir Davydov <vdavydov@parallels.com>
      Fixes: 9a1049da ("percpu-refcount: require percpu_ref to be exited explicitly")
      Fixes: 01e58659 ("cgroup: release css->id after css_free")
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      64e7dc48
    • Alexander Shiyan's avatar
      pinctrl: imx: Do not treat a PIN without MUX register as an error · 03cbdca3
      Alexander Shiyan authored
      commit ba562d5e upstream.
      
      Some PINs do not have a MUX register, it is not an error.
      It is necessary to allow the continuation of the PINs configuration,
      otherwise the whole PIN-group will be configured incorrectly.
      Signed-off-by: default avatarAlexander Shiyan <shc_work@mail.ru>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      03cbdca3
    • Tony Lindgren's avatar
      pinctrl: single: Fix missing flush of posted write for a wakeirq · 4d5ce009
      Tony Lindgren authored
      commit 0ac3c0a4 upstream.
      
      With many repeated suspend resume cycles, the pin specific wakeirq
      may not always work on omaps. This is because the write to enable the
      pin interrupt may not have reached the device over the interconnect
      before suspend happens.
      
      Let's fix the issue with a flush of posted write with a readback.
      Reported-by: default avatarNishanth Menon <nm@ti.com>
      Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4d5ce009
    • Minfei Huang's avatar
      pvclock: Add CPU barriers to get correct version value · c02b2ac1
      Minfei Huang authored
      commit 749d088b upstream.
      
      Protocol for the "version" fields is: hypervisor raises it (making it
      uneven) before it starts updating the fields and raises it again (making
      it even) when it is done.  Thus the guest can make sure the time values
      it got are consistent by checking the version before and after reading
      them.
      
      Add CPU barries after getting version value just like what function
      vread_pvclock does, because all of callees in this function is inline.
      
      Fixes: 502dfeffSigned-off-by: default avatarMinfei Huang <mnghuan@gmail.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c02b2ac1
    • Michael Welling's avatar
      Input: tsc200x - report proper input_dev name · d056c1c7
      Michael Welling authored
      commit e9003c9c upstream.
      
      Passes input_id struct to the common probe function for the tsc200x drivers
      instead of just the bustype.
      
      This allows for the use of the product variable to set the input_dev->name
      variable according to the type of touchscreen used. Note that when we
      introduced support for TSC2004 we started calling everything TSC200X, so
      let's keep this quirk.
      Signed-off-by: default avatarMichael Welling <mwelling@ieee.org>
      Acked-by: default avatarPavel Machek <pavel@ucw.cz>
      Acked-by: default avatarPali Rohár <pali.rohar@gmail.com>
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d056c1c7
    • Andrew Duggan's avatar
      Input: synaptics-rmi4 - fix maximum size check for F12 control register 8 · 99d52327
      Andrew Duggan authored
      commit e4add7b6 upstream.
      
      According to the RMI4 spec the maximum size of F12 control register 8 is
      15 bytes. The current code incorrectly reports an error if control 8 is
      greater then 14. Making sensors with a control register 8 with 15 bytes
      unusable.
      Signed-off-by: default avatarAndrew Duggan <aduggan@synaptics.com>
      Reported-by: default avatarChris Healy <cphealy@gmail.com>
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      99d52327
    • Dmitry Torokhov's avatar
      Revert "Input: wacom_w8001 - drop use of ABS_MT_TOOL_TYPE" · 0cc1789c
      Dmitry Torokhov authored
      commit 3e9161bf upstream.
      
      This reverts commit 5f7e5445 because
      removal of input_mt_report_slot_state() means we no longer generate
      tracking IDs for the reported contacts.
      Acked-by: default avatarPeter Hutterer <peter.hutterer@who-t.net>
      Acked-by: default avatarPing Cheng <pinglinux@gmail.com>
      0cc1789c