30 May, 2018

6 commits

  • commit 79f546a696bff2590169fb5684e23d65f4d9f591 upstream.

    We recently had an oops reported on a 4.14 kernel in
    xfs_reclaim_inodes_count() where sb->s_fs_info pointed to garbage
    and so the m_perag_tree lookup walked into lala land. It produces
    an oops down this path during the failed mount:

    radix_tree_gang_lookup_tag+0xc4/0x130
    xfs_perag_get_tag+0x37/0xf0
    xfs_reclaim_inodes_count+0x32/0x40
    xfs_fs_nr_cached_objects+0x11/0x20
    super_cache_count+0x35/0xc0
    shrink_slab.part.66+0xb1/0x370
    shrink_node+0x7e/0x1a0
    try_to_free_pages+0x199/0x470
    __alloc_pages_slowpath+0x3a1/0xd20
    __alloc_pages_nodemask+0x1c3/0x200
    cache_grow_begin+0x20b/0x2e0
    fallback_alloc+0x160/0x200
    kmem_cache_alloc+0x111/0x4e0

    The problem is that the superblock shrinker is running before the
    filesystem structures it depends on have been fully set up. i.e.
    the shrinker is registered in sget(), before ->fill_super() has been
    called, and the shrinker can call into the filesystem before
    fill_super() does it's setup work. Essentially we are exposed to
    both use-after-free and use-before-initialisation bugs here.

    To fix this, add a check for the SB_BORN flag in super_cache_count.
    In general, this flag is not set until ->fs_mount() completes
    successfully, so we know that it is set after the filesystem
    setup has completed. This matches the trylock_super() behaviour
    which will not let super_cache_scan() run if SB_BORN is not set, and
    hence will not allow the superblock shrinker from entering the
    filesystem while it is being set up or after it has failed setup
    and is being torn down.

    Cc: stable@kernel.org
    Signed-Off-By: Dave Chinner
    Signed-off-by: Al Viro
    Signed-off-by: Greg Kroah-Hartman

    Dave Chinner
     
  • commit 30da870ce4a4e007c901858a96e9e394a1daa74a upstream.

    we unlock the directory hash too early - if we are looking at secondary
    link and primary (in another directory) gets removed just as we unlock,
    we could have the old primary moved in place of the secondary, leaving
    us to look into freed entry (and leaving our dentry with ->d_fsdata
    pointing to a freed entry).

    Cc: stable@vger.kernel.org # 2.4.4+
    Acked-by: David Sterba
    Signed-off-by: Al Viro
    Signed-off-by: Greg Kroah-Hartman

    Al Viro
     
  • commit ba3696e94d9d590d9a7e55f68e81c25dba515191 upstream.

    Trivial fix to spelling mistake in debugfs_entries text.

    Fixes: 669e846e6c4e ("KVM/MIPS32: MIPS arch specific APIs for KVM")
    Signed-off-by: Colin Ian King
    Cc: Ralf Baechle
    Cc: linux-mips@linux-mips.org
    Cc: kernel-janitors@vger.kernel.org
    Cc: # 3.10+
    Signed-off-by: James Hogan
    Signed-off-by: Greg Kroah-Hartman

    Colin Ian King
     
  • commit 9a3a92ccfe3620743d4ae57c987dc8e9c5f88996 upstream.

    Check the TIF_32BIT_FPREGS task setting of the tracee rather than the
    tracer in determining the layout of floating-point general registers in
    the floating-point context, correcting access to odd-numbered registers
    for o32 tracees where the setting disagrees between the two processes.

    Fixes: 597ce1723e0f ("MIPS: Support for 64-bit FP with O32 binaries")
    Signed-off-by: Maciej W. Rozycki
    Cc: Ralf Baechle
    Cc: linux-mips@linux-mips.org
    Cc: # 3.14+
    Signed-off-by: James Hogan
    Signed-off-by: Greg Kroah-Hartman

    Maciej W. Rozycki
     
  • commit 71e909c0cdad28a1df1fa14442929e68615dee45 upstream.

    Correct commit 7aeb753b5353 ("MIPS: Implement task_user_regset_view.")
    and expose the FIR register using the unused 4 bytes at the end of the
    NT_PRFPREG regset. Without that register included clients cannot use
    the PTRACE_GETREGSET request to retrieve the complete FPU register set
    and have to resort to one of the older interfaces, either PTRACE_PEEKUSR
    or PTRACE_GETFPREGS, to retrieve the missing piece of data. Also the
    register is irreversibly missing from core dumps.

    This register is architecturally hardwired and read-only so the write
    path does not matter. Ignore data supplied on writes then.

    Fixes: 7aeb753b5353 ("MIPS: Implement task_user_regset_view.")
    Signed-off-by: James Hogan
    Signed-off-by: Maciej W. Rozycki
    Cc: Ralf Baechle
    Cc: linux-mips@linux-mips.org
    Cc: # 3.13+
    Patchwork: https://patchwork.linux-mips.org/patch/19273/
    Signed-off-by: James Hogan
    Signed-off-by: Greg Kroah-Hartman

    Maciej W. Rozycki
     
  • commit 55a2aa08b3af519a9693f99cdf7fa6d8b62d9f65 upstream.

    When DMA will be performed to a MIPS32 1004K CPS, the L1-cache for the
    range needs to be flushed and invalidated first.
    The code currently takes one of two approaches.
    1/ If the range is less than the size of the dcache, then HIT type
    requests flush/invalidate cache lines for the particular addresses.
    HIT-type requests a globalised by the CPS so this is safe on SMP.

    2/ If the range is larger than the size of dcache, then INDEX type
    requests flush/invalidate the whole cache. INDEX type requests affect
    the local cache only. CPS does not propagate them in any way. So this
    invalidation is not safe on SMP CPS systems.

    Data corruption due to '2' can quite easily be demonstrated by
    repeatedly "echo 3 > /proc/sys/vm/drop_caches" and then sha1sum a file
    that is several times the size of available memory. Dropping caches
    means that large contiguous extents (large than dcache) are more likely.

    This was not a problem before Linux-4.8 because option 2 was never used
    if CONFIG_MIPS_CPS was defined. The commit which removed that apparently
    didn't appreciate the full consequence of the change.

    We could, in theory, globalize the INDEX based flush by sending an IPI
    to other cores. These cache invalidation routines can be called with
    interrupts disabled and synchronous IPI require interrupts to be
    enabled. Asynchronous IPI may not trigger writeback soon enough. So we
    cannot use IPI in practice.

    We can already test if IPI would be needed for an INDEX operation with
    r4k_op_needs_ipi(R4K_INDEX). If this is true then we mustn't try the
    INDEX approach as we cannot use IPI. If this is false (e.g. when there
    is only one core and hence one L1 cache) then it is safe to use the
    INDEX approach without IPI.

    This patch avoids options 2 if r4k_op_needs_ipi(R4K_INDEX), and so
    eliminates the corruption.

    Fixes: c00ab4896ed5 ("MIPS: Remove cpu_has_safe_index_cacheops")
    Signed-off-by: NeilBrown
    Cc: Ralf Baechle
    Cc: Paul Burton
    Cc: linux-mips@linux-mips.org
    Cc: # 4.8+
    Patchwork: https://patchwork.linux-mips.org/patch/19259/
    Signed-off-by: James Hogan
    Signed-off-by: Greg Kroah-Hartman

    NeilBrown
     

25 May, 2018

34 commits

  • Greg Kroah-Hartman
     
  • [ Upstream commit 82d632b85eb89f97051530f556cb49ee1c04bde7 ]

    Fix the following warning in MIPS allmodconfig by adding a
    MODULE_LICENSE() at the end of rtc-goldfish.c, based on the file header
    comment which says GNU General Public License version 2:

    WARNING: modpost: missing MODULE_LICENSE() in drivers/rtc/rtc-goldfish.o

    Fixes: f22d9cdcb5eb ("rtc: goldfish: Add RTC driver for Android emulator")
    Signed-off-by: James Hogan
    Cc: Miodrag Dinic
    Cc: Alessandro Zummo
    Cc: Alexandre Belloni
    Cc: linux-rtc@vger.kernel.org
    Signed-off-by: Alexandre Belloni
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    James Hogan
     
  • [ Upstream commit bcdd559268039d8340d38fa58668393596e29fdc ]

    The probe function is not allowed to fail after registering the RTC because
    the following may happen:

    CPU0: CPU1:
    sys_load_module()
    do_init_module()
    do_one_initcall()
    cmos_do_probe()
    rtc_device_register()
    __register_chrdev()
    cdev->owner = struct module*
    open("/dev/rtc0")
    rtc_device_unregister()
    module_put()
    free_module()
    module_free(mod->module_core)
    /* struct module *module is now
    freed */
    chrdev_open()
    spin_lock(cdev_lock)
    cdev_get()
    try_module_get()
    module_is_live()
    /* dereferences already
    freed struct module* */

    Switch to devm_rtc_allocate_device/rtc_register_device to register the rtc
    as late as possible.

    Signed-off-by: Alexandre Belloni
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Alexandre Belloni
     
  • [ Upstream commit 347876ad47b9923ce26e686173bbf46581802ffa ]

    The shifting of buf[5] by 24 bits to the left will be promoted to
    a 32 bit signed int and then sign-extended to an unsigned long. If
    the top bit of buf[5] is set then all then all the upper bits sec
    end up as also being set because of the sign-extension. Fix this by
    casting buf[5] to an unsigned long before the shift.

    Detected by CoverityScan, CID#1465292 ("Unintended sign extension")

    Fixes: 0e1492330cd2 ("rtc: add rtc-tx4939 driver")
    Signed-off-by: Colin Ian King
    Signed-off-by: Alexandre Belloni
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Colin Ian King
     
  • [ Upstream commit 10d0c768cc6d581523d673b9d1b54213f8a5eb24 ]

    The IRQ is requested before the struct rtc is allocated and registered, but
    this struct is used in the IRQ handler, leading to:

    Unable to handle kernel NULL pointer dereference at virtual address 0000017c
    pgd = a38a2f9b
    [0000017c] *pgd=00000000
    Internal error: Oops: 5 [#1] ARM
    Modules linked in:
    CPU: 0 PID: 613 Comm: irq/48-m41t80 Not tainted 4.16.0-rc1+ #42
    Hardware name: Atmel SAMA5
    PC is at mutex_lock+0x14/0x38
    LR is at m41t80_handle_irq+0x1c/0x9c
    pc : [] lr : [] psr: 20000013
    sp : dec73f30 ip : 00000000 fp : dec56d98
    r10: df437cf0 r9 : c0a03008 r8 : c0145ffc
    r7 : df5c4300 r6 : dec568d0 r5 : df593000 r4 : 0000017c
    r3 : df592800 r2 : 60000013 r1 : df593000 r0 : 0000017c
    Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none
    Control: 10c53c7d Table: 20004059 DAC: 00000051
    Process irq/48-m41t80 (pid: 613, stack limit = 0xb52d091e)
    Stack: (0xdec73f30 to 0xdec74000)
    3f20: dec56840 df5c4300 00000001 df5c4300
    3f40: c0145ffc c0146018 dec56840 ffffe000 00000001 c0146290 dec567c0 00000000
    3f60: c0146084 ed7c9a62 c014615c dec56d80 dec567c0 00000000 dec72000 dec56840
    3f80: c014615c c012ffc0 dec72000 dec567c0 c012fe80 00000000 00000000 00000000
    3fa0: 00000000 00000000 00000000 c01010e8 00000000 00000000 00000000 00000000
    3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
    3fe0: 00000000 00000000 00000000 00000000 00000013 00000000 29282726 2d2c2b2a
    [] (mutex_lock) from [] (m41t80_handle_irq+0x1c/0x9c)
    [] (m41t80_handle_irq) from [] (irq_thread_fn+0x1c/0x54)
    [] (irq_thread_fn) from [] (irq_thread+0x134/0x1c0)
    [] (irq_thread) from [] (kthread+0x140/0x148)
    [] (kthread) from [] (ret_from_fork+0x14/0x2c)
    Exception stack(0xdec73fb0 to 0xdec73ff8)
    3fa0: 00000000 00000000 00000000 00000000
    3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
    3fe0: 00000000 00000000 00000000 00000000 00000013 00000000
    Code: e3c33d7f e3c3303f f5d0f000 e593300c (e1901f9f)
    ---[ end trace 22b027302eb7c604 ]---
    genirq: exiting task "irq/48-m41t80" (613) is an active IRQ thread (irq 48)

    Also, there is another possible race condition. The probe function is not
    allowed to fail after the RTC is registered because the following may
    happen:

    CPU0: CPU1:
    sys_load_module()
    do_init_module()
    do_one_initcall()
    cmos_do_probe()
    rtc_device_register()
    __register_chrdev()
    cdev->owner = struct module*
    open("/dev/rtc0")
    rtc_device_unregister()
    module_put()
    free_module()
    module_free(mod->module_core)
    /* struct module *module is now
    freed */
    chrdev_open()
    spin_lock(cdev_lock)
    cdev_get()
    try_module_get()
    module_is_live()
    /* dereferences already
    freed struct module* */

    Switch to devm_rtc_allocate_device/rtc_register_device to allocate the rtc
    before requesting the IRQ and register it as late as possible.

    Signed-off-by: Alexandre Belloni

    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Alexandre Belloni
     
  • [ Upstream commit 201fac95e799c3d0304ec724d555e1251b9f6e84 ]

    The probe function is not allowed to fail after registering the RTC because
    the following may happen:

    CPU0: CPU1:
    sys_load_module()
    do_init_module()
    do_one_initcall()
    cmos_do_probe()
    rtc_device_register()
    __register_chrdev()
    cdev->owner = struct module*
    open("/dev/rtc0")
    rtc_device_unregister()
    module_put()
    free_module()
    module_free(mod->module_core)
    /* struct module *module is now
    freed */
    chrdev_open()
    spin_lock(cdev_lock)
    cdev_get()
    try_module_get()
    module_is_live()
    /* dereferences already
    freed struct module* */

    Switch to devm_rtc_allocate_device/rtc_register_device to register the rtc
    as late as possible.

    Signed-off-by: Alexandre Belloni
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Alexandre Belloni
     
  • [ Upstream commit b3a5ac42ab18b7d1a8f2f072ca0ee76a3b754a43 ]

    On 32bit platforms, time_t is still a signed 32bit long. If it is
    overflowed, userspace and the kernel cant agree on the current system time.
    This causes multiple issues, in particular with systemd:
    https://github.com/systemd/systemd/issues/1143

    A good workaround is to simply avoid using hctosys which is something I
    greatly encourage as the time is better set by userspace.

    However, many distribution enable it and use systemd which is rendering the
    system unusable in case the RTC holds a date after 2038 (and more so after
    2106). Many drivers have workaround for this case and they should be
    eliminated so there is only one place left to fix when userspace is able to
    cope with dates after the 31bit overflow.

    Acked-by: Arnd Bergmann
    Signed-off-by: Alexandre Belloni
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Alexandre Belloni
     
  • [ Upstream commit 1485991c024603b2fb4ae77beb7a0d741128a48e ]

    commit 179a502f8c46 ("rtc: snvs: add Freescale rtc-snvs driver") introduces
    the SNVS RTC driver with a function snvs_rtc_enable().

    snvs_rtc_enable() can return an error on the enable path however this
    driver does not currently trap that failure on the probe() path and
    consequently if enabling the RTC fails we encounter a later error spinning
    forever in rtc_write_sync_lp().

    [ 36.093481] [] (__irq_svc) from [] (_raw_spin_unlock_irqrestore+0x34/0x44)
    [ 36.102122] [] (_raw_spin_unlock_irqrestore) from [] (regmap_read+0x4c/0x5c)
    [ 36.110938] [] (regmap_read) from [] (rtc_write_sync_lp+0x6c/0x98)
    [ 36.118881] [] (rtc_write_sync_lp) from [] (snvs_rtc_alarm_irq_enable+0x40/0x4c)
    [ 36.128041] [] (snvs_rtc_alarm_irq_enable) from [] (rtc_timer_do_work+0xd8/0x1a8)
    [ 36.137291] [] (rtc_timer_do_work) from [] (process_one_work+0x28c/0x76c)
    [ 36.145840] [] (process_one_work) from [] (worker_thread+0x34/0x58c)
    [ 36.153961] [] (worker_thread) from [] (kthread+0x138/0x150)
    [ 36.161388] [] (kthread) from [] (ret_from_fork+0x14/0x20)
    [ 36.168635] rcu_sched kthread starved for 2602 jiffies! g496 c495 f0x2 RCU_GP_WAIT_FQS(3) ->state=0x0 ->cpu=0
    [ 36.178564] rcu_sched R running task 0 8 2 0x00000000
    [ 36.185664] [] (__schedule) from [] (schedule+0x3c/0xa0)
    [ 36.192739] [] (schedule) from [] (schedule_timeout+0x78/0x4e0)
    [ 36.200422] [] (schedule_timeout) from [] (rcu_gp_kthread+0x648/0x1864)
    [ 36.208800] [] (rcu_gp_kthread) from [] (kthread+0x138/0x150)
    [ 36.216309] [] (kthread) from [] (ret_from_fork+0x14/0x20)

    This patch fixes by parsing the result of rtc_write_sync_lp() and
    propagating both in the probe and elsewhere. If the RTC doesn't start we
    don't proceed loading the driver and don't get into this loop mess later
    on.

    Fixes: 179a502f8c46 ("rtc: snvs: add Freescale rtc-snvs driver")
    Signed-off-by: Bryan O'Donoghue
    Acked-by: Shawn Guo
    Signed-off-by: Alexandre Belloni
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Bryan O'Donoghue
     
  • [ Upstream commit 0e254963b6ba4d63ac911e79537fea38dd03dc50 ]

    Most register accesses in the altera driver honor port->regshift by
    using altera_uart_writel(). There are a few accesses however that were
    missed when the driver was converted to use port->regshift and some
    others were added later in commit 4d9d7d896d77 ("serial: altera_uart:
    add earlycon support").

    Fixes: 2780ad42f5fe ("tty: serial: altera_uart: Use port->regshift to store bus shift")
    Signed-off-by: Uwe Kleine-König
    Acked-by: Tobias Klauser
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Uwe Kleine-König
     
  • [ Upstream commit 2e9fe539108320820016f78ca7704a7342788380 ]

    Currently, data in RX FIFO is read based on UART_LSR register state even
    if RDI and RLSI interrupts are disabled in UART_IER register.
    This is because when IRQ handler is called due to TX FIFO empty event,
    RX FIFO is serviced based on UART_LSR register status instead of
    UART_IIR status. This defeats the purpose of disabling UART RX
    FIFO interrupts during throttling(see, omap_8250_throttle()) as IRQ
    handler continues to drain UART RX FIFO resulting in overflow of buffer
    at tty layer.
    Fix this by making sure that driver drains UART RX FIFO only when
    UART_IIR_RDI is set along with UART_LSR_BI or UART_LSR_DR bits.

    Signed-off-by: Vignesh R
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Vignesh R
     
  • [ Upstream commit f9f5786987e81d166c60833edcb7d1836aa16944 ]

    The arc_uart_ports[] array is indexed using a value derived from the
    "serialN" alias in DT, which may lead to an out-of-bounds access.

    Fix this by adding a range check.

    Note that the array size is defined by a Kconfig symbol
    (CONFIG_SERIAL_ARC_NR_PORTS), so this can even be triggered using a
    legitimate DTB.

    Fixes: ea28fd56fcde69af ("serial/arc-uart: switch to devicetree based probing")
    Signed-off-by: Geert Uytterhoeven
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Geert Uytterhoeven
     
  • [ Upstream commit ffab87fdecc655cc676f8be8dd1a2c5e22bd6d47 ]

    The lpuart_ports[] array is indexed using a value derived from the
    "serialN" alias in DT, which may lead to an out-of-bounds access.

    Fix this by adding a range check.

    Fixes: c9e2e946fb0ba5d2 ("tty: serial: add Freescale lpuart driver support")
    Signed-off-by: Geert Uytterhoeven
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Geert Uytterhoeven
     
  • [ Upstream commit 5673444821406dda5fc25e4b52aca419f8065a19 ]

    The imx_ports[] array is indexed using a value derived from the
    "serialN" alias in DT, or from platform data, which may lead to an
    out-of-bounds access.

    Fix this by adding a range check.

    Fixes: ff05967a07225ab6 ("serial/imx: add of_alias_get_id() reference back")
    Signed-off-by: Geert Uytterhoeven
    Reviewed-by: Uwe Kleine-König
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Geert Uytterhoeven
     
  • [ Upstream commit dd345a31bfdec350d2593e6de5964e55c7f19c76 ]

    The auart_port[] array is indexed using a value derived from the
    "serialN" alias in DT, or from platform data, which may lead to an
    out-of-bounds access.

    Fix this by adding a range check.

    Fixes: 1ea6607d4cdc9179 ("serial: mxs-auart: Allow device tree probing")
    Signed-off-by: Geert Uytterhoeven
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Geert Uytterhoeven
     
  • [ Upstream commit 49ee23b71877831ac087d6083f6f397dc19c9664 ]

    The s3c24xx_serial_ports[] array is indexed using a value derived from
    the "serialN" alias in DT, or from an incrementing probe index, which
    may lead to an out-of-bounds access.

    Fix this by adding a range check.

    Note that the array size is defined by a Kconfig symbol
    (CONFIG_SERIAL_SAMSUNG_UARTS), so this can even be triggered using
    a legitimate DTB or legitimate board code.

    Fixes: 13a9f6c64fdc55eb ("serial: samsung: Consider DT alias when probing ports")
    Signed-off-by: Geert Uytterhoeven
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Geert Uytterhoeven
     
  • [ Upstream commit 090fa4b0dccfa3d04e1c5ab0fe4eba16e6713895 ]

    The sci_ports[] array is indexed using a value derived from the
    "serialN" alias in DT, which may lead to an out-of-bounds access.

    Fix this by adding a range check.

    Note that the array size is defined by a Kconfig symbol
    (CONFIG_SERIAL_SH_SCI_NR_UARTS), so this can even be triggered using a
    legitimate DTB.

    Fixes: 97ed9790c514066b ("serial: sh-sci: Remove unused platform data capabilities field")
    Signed-off-by: Geert Uytterhoeven
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Geert Uytterhoeven
     
  • [ Upstream commit e7d75e18d0fc3f7193b65282b651f980c778d935 ]

    The cdns_uart_port[] array is indexed using a value derived from the
    "serialN" alias in DT, which may lead to an out-of-bounds access.

    Fix this by adding a range check.

    Fixes: 928e9263492069ee ("tty: xuartps: Initialize ports according to aliases")
    Signed-off-by: Geert Uytterhoeven
    Reviewed-by: Michal Simek
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Geert Uytterhoeven
     
  • [ Upstream commit 67300abdbe9f1717532aaf4e037222762716d0f6 ]

    Currently an out of range dev->nr is detected by just reporting the
    issue and later on an out-of-bounds read on array card occurs because
    of this. Fix this by checking the upper range of dev->nr with the size
    of array card (removes the hard coded size), move this check earlier
    and also exit with the error -ENOSYS to avoid the later out-of-bounds
    array read.

    Detected by CoverityScan, CID#711191 ("Out-of-bounds-read")

    Fixes: commit 02b20b0b4cde ("V4L/DVB (12730): Add conexant cx25821 driver")

    Signed-off-by: Colin Ian King
    Signed-off-by: Hans Verkuil
    [hans.verkuil@cisco.com: %ld -> %zd]
    Signed-off-by: Mauro Carvalho Chehab
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Colin Ian King
     
  • [ Upstream commit 65243386f41d38460bfd4375d231a7c0346d0401 ]

    The vivid driver has two custom controls that change the behavior of RDS.
    Depending on the control setting the V4L2_CAP_READWRITE capability is toggled.
    However, after an earlier commit the capability was no longer set correctly.
    This is now fixed.

    Fixes: 9765a32cd8 ("vivid: set device_caps in video_device")

    Signed-off-by: Hans Verkuil
    Signed-off-by: Mauro Carvalho Chehab
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Hans Verkuil
     
  • [ Upstream commit d13a0139d7874a0577b5955d6eed895517d23b72 ]

    Fixes vb2_vmalloc_get_userptr() to ioremap correct area.
    Since the current code does ioremap the page address, if the offset > 0,
    it does not do ioremap the last page and results in kernel panic.

    This fixes to pass the size + offset to ioremap so that ioremap
    can map correct area. Also, this uses __pfn_to_phys() to get the physical
    address of given PFN.

    Signed-off-by: Masami Hiramatsu
    Reported-by: Takao Orito
    Reported-by: Fumihiro ATSUMI
    Reviewed-by: Marek Szyprowski
    Signed-off-by: Hans Verkuil
    Signed-off-by: Mauro Carvalho Chehab
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Masami Hiramatsu
     
  • [ Upstream commit 9f564184e6cc21a86c26bab920afac1bab7653ff ]

    The ADV748x handles interlaced media using V4L2_FIELD_ALTERNATE field
    types. The correct specification for the height on the mbus is the
    image height, in this instance, the field height.

    The AFE component already correctly adjusts the height on the mbus, but
    the HDMI component got left behind.

    Adjust the mbus height to correctly describe the image height of the
    fields when processing interlaced video for HDMI pipelines.

    Fixes: 3e89586a64df ("media: i2c: adv748x: add adv748x driver")

    Reviewed-by: Niklas Söderlund
    Signed-off-by: Kieran Bingham
    Signed-off-by: Hans Verkuil
    Signed-off-by: Mauro Carvalho Chehab
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Kieran Bingham
     
  • [ Upstream commit 5e3e4cb5e24b92773b194aa90066170b12133bc6 ]

    Make sure we don't accept more inputs than the hardware can handle. This
    is a temporary fix to avoid display stall, we need to instead allocate
    the BRU or BRS to display pipelines dynamically based on the number of
    planes they each use.

    Signed-off-by: Laurent Pinchart
    Reviewed-by: Kieran Bingham
    Signed-off-by: Mauro Carvalho Chehab
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Laurent Pinchart
     
  • [ Upstream commit f2a326c928cca1f5e36a3dceaf66e8c6b34e9cb8 ]

    Add additional pids to driver list

    Signed-off-by: Brad Love
    Reviewed-by: Michael Ira Krufky
    Signed-off-by: Mauro Carvalho Chehab
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Brad Love
     
  • [ Upstream commit 94448e21cf08b10f7dc7acdaca387594370396b0 ]

    Both lgdt33606a_release and lgdt3306a_remove kfree state, but _release is
    called first, then _remove operates on states members before kfree'ing it.
    This can lead to random oops/GPF/etc on USB disconnect.

    Signed-off-by: Brad Love
    Signed-off-by: Mauro Carvalho Chehab
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Brad Love
     
  • [ Upstream commit a398e043637a4819a0e96467bfecaabf3224dd62 ]

    While experimenting with older compiler versions, I ran
    into a warning that no longer shows up on gcc-4.8 or newer:

    drivers/media/platform/s3c-camif/camif-capture.c: In function '__camif_subdev_try_format':
    drivers/media/platform/s3c-camif/camif-capture.c:1265:25: error: array subscript is below array bounds

    This is an off-by-one bug, leading to an access before the start of the
    array, while newer compilers silently assume this undefined behavior
    cannot happen and leave the loop at index 0 if no other entry matches.

    As Sylvester explains, we actually need to ensure that the
    value is within the range, so this reworks the loop to be
    easier to parse correctly, and an additional check to fall
    back on the first format value for any unexpected input.

    I found an existing gcc bug for it and added a reduced version
    of the function there.

    Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69249#c3
    Fixes: babde1c243b2 ("[media] V4L: Add driver for S3C24XX/S3C64XX SoC series camera interface")

    Signed-off-by: Arnd Bergmann
    Reviewed-by: Laurent Pinchart
    Acked-by: Sakari Ailus
    Signed-off-by: Mauro Carvalho Chehab
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Arnd Bergmann
     
  • [ Upstream commit 5ceade1d97fc6687e050c44c257382c192f56276 ]

    Currently clk_freq is ignored entirely, because the cx235840 driver
    configures the xtal at the chip defaults. This is an issue if a
    board is produced with a non-default frequency crystal. If clk_freq
    is not zero the cx25840 will attempt to use the setting provided,
    or fall back to defaults otherwise.

    Signed-off-by: Brad Love
    Signed-off-by: Mauro Carvalho Chehab
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Brad Love
     
  • [ Upstream commit 779c79d4b833ec646b0aed878da38edb45bbe156 ]

    Hauppauge produced a revision of ImpactVCBe using an 888,
    with a 25MHz crystal, instead of using the default third
    overtone 50Mhz crystal. This overrides that frequency so
    that the cx25840 is properly configured. Without the proper
    crystal setup the cx25840 cannot load the firmware or
    decode video.

    Signed-off-by: Brad Love
    Signed-off-by: Mauro Carvalho Chehab
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Brad Love
     
  • [ Upstream commit 06fe932307d58108a11c3e603517dd2a73a57b80 ]

    The device node obtained with of_graph_get_next_endpoint() should be
    released by calling of_node_put(). But it was not released when
    v4l2_fwnode_endpoint_parse() failed.

    This change moves the of_node_put() call before the error check and
    fixes the issue.

    Cc: Mauro Carvalho Chehab
    Signed-off-by: Akinobu Mita
    Acked-by: Todor Tomov
    Signed-off-by: Sakari Ailus
    Signed-off-by: Mauro Carvalho Chehab
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Akinobu Mita
     
  • [ Upstream commit 3dd6b560dc5d59e7cb6dbda6e85dc9af7925fcf8 ]

    As pointed by Dan, possible values for bits[3:0] of te Line Mode Registers
    can range from 0x0 to 0xf, but the check logic allow values ranging
    from 0x0 to 0xe.

    As static arrays are initialized with zero, using a value without
    an explicit initializer at the array won't cause any harm.

    Reported-by: Dan Carpenter
    Signed-off-by: Mauro Carvalho Chehab
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Mauro Carvalho Chehab
     
  • [ Upstream commit a145f64c6107d3aa5a7cec9f8977d04ac2a896c9 ]

    Returning -EINVAL when an ioctl is not implemented is a very
    bad idea, as it is hard to distinguish from other error
    contitions that an ioctl could lead. Replace it by its
    right error code: -ENOTTY.

    Signed-off-by: Mauro Carvalho Chehab
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Mauro Carvalho Chehab
     
  • [ Upstream commit a8321e7887410a2b2e80ab89d1ef7b30562658ea ]

    Rates declared in PLL rate tables should match exactly rates calculated
    from PLL coefficients. If that is not the case, rate of the PLL's child clock
    might be set not as expected. For instance, if in the PLL rates table we have
    a 393216000 Hz entry and the real value as returned by the PLL's recalc_rate
    callback is 393216003, after setting PLL's clk rate to 393216000 clk_get_rate
    will return 393216003. If we now attempt to set rate of a PLL's child divider
    clock to 393216000/2 its rate will be 131072001, rather than 196608000.
    That is, the divider will be set to 3 instead of 2, because 393216003/2 is
    greater than 196608000.

    To fix this issue declared rates are changed to exactly match rates generated
    by the PLL, as calculated from the P, M, S, K coefficients.

    In this patch an erroneous P value for 74176002 output frequency is also
    corrected.

    Signed-off-by: Andrzej Hajda
    Acked-by: Chanwoo Choi
    Acked-by: Tomasz Figa
    Signed-off-by: Sylwester Nawrocki
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Andrzej Hajda
     
  • [ Upstream commit 2ac051eeabaa411ef89ae7cd5bb8e60cb41ad780 ]

    Rates declared in PLL rate tables should match exactly rates calculated
    from PLL coefficients. If that is not the case, rate of the PLL's child clock
    might be set not as expected. For instance, if in the PLL rates table we have
    a 393216000 Hz entry and the real value as returned by the PLL's recalc_rate
    callback is 393216003, after setting PLL's clk rate to 393216000 clk_get_rate
    will return 393216003. If we now attempt to set rate of a PLL's child divider
    clock to 393216000/2 its rate will be 131072001, rather than 196608000.
    That is, the divider will be set to 3 instead of 2, because 393216003/2 is
    greater than 196608000.

    To fix this issue declared rates are changed to exactly match rates generated
    by the PLL, as calculated from the P, M, S, K coefficients.

    Signed-off-by: Andrzej Hajda
    Acked-by: Chanwoo Choi
    Acked-by: Tomasz Figa
    Signed-off-by: Sylwester Nawrocki
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Andrzej Hajda
     
  • [ Upstream commit ab0447845cffc0fd752df2ccd6b4e34006000ce4 ]

    Rates declared in PLL rate tables should match exactly rates calculated from
    the PLL coefficients. If that is not the case, rate of the PLL's child clock
    might be set not as expected. For instance, if in the PLL rates table we have
    a 393216000 Hz entry and the real value as returned by the PLL's recalc_rate
    callback is 393216003, after setting PLL's clk rate to 393216000 clk_get_rate
    will return 393216003. If we now attempt to set rate of a PLL's child divider
    clock to 393216000/2 its rate will be 131072001, rather than 196608000.
    That is, the divider will be set to 3 instead of 2, because 393216003/2 is
    greater than 196608000.

    To fix this issue declared rates are changed to exactly match rates generated
    by the PLL, as calculated from the P, M, S, K coefficients.

    Signed-off-by: Andrzej Hajda
    Acked-by: Tomasz Figa
    Acked-by: Chanwoo Choi
    Signed-off-by: Sylwester Nawrocki
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Andrzej Hajda
     
  • [ Upstream commit cdb68fbd4e7962be742c4f29475220c5bf28d8a5 ]

    Rates declared in PLL rate tables should match exactly rates calculated from
    the PLL coefficients. If that is not the case, rate of the PLL's child clock
    might be set not as expected. For instance, if in the PLL rates table we have
    a 393216000 Hz entry and the real value as returned by the PLL's recalc_rate
    callback is 393216003, after setting PLL's clk rate to 393216000 clk_get_rate
    will return 393216003. If we now attempt to set rate of a PLL's child divider
    clock to 393216000/2 its rate will be 131072001, rather than 196608000.
    That is, the divider will be set to 3 instead of 2, because 393216003/2 is
    greater than 196608000.

    To fix this issue declared rates are changed to exactly match rates generated
    by the PLL, as calculated from the P, M, S, K coefficients.

    Signed-off-by: Andrzej Hajda
    Acked-by: Tomasz Figa
    Acked-by: Chanwoo Choi
    Signed-off-by: Sylwester Nawrocki
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Andrzej Hajda