1. 30 May, 2018 29 commits
  2. 25 May, 2018 11 commits
    • Greg Kroah-Hartman's avatar
      Linux 4.14.44 · 102b97d6
      Greg Kroah-Hartman authored
      102b97d6
    • James Hogan's avatar
      rtc: goldfish: Add missing MODULE_LICENSE · 6b73dfbd
      James Hogan authored
      [ Upstream commit 82d632b8 ]
      
      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: f22d9cdc ("rtc: goldfish: Add RTC driver for Android emulator")
      Signed-off-by: default avatarJames Hogan <jhogan@kernel.org>
      Cc: Miodrag Dinic <miodrag.dinic@mips.com>
      Cc: Alessandro Zummo <a.zummo@towertech.it>
      Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
      Cc: linux-rtc@vger.kernel.org
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6b73dfbd
    • Alexandre Belloni's avatar
      rtc: rp5c01: fix possible race condition · 6f34e436
      Alexandre Belloni authored
      [ Upstream commit bcdd5592 ]
      
      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: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6f34e436
    • Colin Ian King's avatar
      rtc: tx4939: avoid unintended sign extension on a 24 bit shift · 78227b67
      Colin Ian King authored
      [ Upstream commit 347876ad ]
      
      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: 0e149233 ("rtc: add rtc-tx4939 driver")
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      78227b67
    • Alexandre Belloni's avatar
      rtc: m41t80: fix race conditions · 459aa490
      Alexandre Belloni authored
      [ Upstream commit 10d0c768 ]
      
      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 : [<c06e864c>]    lr : [<c04b70f0>]    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
      [<c06e864c>] (mutex_lock) from [<c04b70f0>] (m41t80_handle_irq+0x1c/0x9c)
      [<c04b70f0>] (m41t80_handle_irq) from [<c0146018>] (irq_thread_fn+0x1c/0x54)
      [<c0146018>] (irq_thread_fn) from [<c0146290>] (irq_thread+0x134/0x1c0)
      [<c0146290>] (irq_thread) from [<c012ffc0>] (kthread+0x140/0x148)
      [<c012ffc0>] (kthread) from [<c01010e8>] (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: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      459aa490
    • Alexandre Belloni's avatar
      rtc: rk808: fix possible race condition · 6266010c
      Alexandre Belloni authored
      [ Upstream commit 201fac95 ]
      
      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: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6266010c
    • Alexandre Belloni's avatar
      rtc: hctosys: Ensure system time doesn't overflow time_t · 6c1c1711
      Alexandre Belloni authored
      [ Upstream commit b3a5ac42 ]
      
      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: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6c1c1711
    • Bryan O'Donoghue's avatar
      rtc: snvs: Fix usage of snvs_rtc_enable · 731d965a
      Bryan O'Donoghue authored
      [ Upstream commit 1485991c ]
      
      commit 179a502f ("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] [<c010d630>] (__irq_svc) from [<c0c2e9ec>] (_raw_spin_unlock_irqrestore+0x34/0x44)
      [   36.102122] [<c0c2e9ec>] (_raw_spin_unlock_irqrestore) from [<c072e32c>] (regmap_read+0x4c/0x5c)
      [   36.110938] [<c072e32c>] (regmap_read) from [<c085d0f4>] (rtc_write_sync_lp+0x6c/0x98)
      [   36.118881] [<c085d0f4>] (rtc_write_sync_lp) from [<c085d160>] (snvs_rtc_alarm_irq_enable+0x40/0x4c)
      [   36.128041] [<c085d160>] (snvs_rtc_alarm_irq_enable) from [<c08567b4>] (rtc_timer_do_work+0xd8/0x1a8)
      [   36.137291] [<c08567b4>] (rtc_timer_do_work) from [<c01441b8>] (process_one_work+0x28c/0x76c)
      [   36.145840] [<c01441b8>] (process_one_work) from [<c01446cc>] (worker_thread+0x34/0x58c)
      [   36.153961] [<c01446cc>] (worker_thread) from [<c014aee4>] (kthread+0x138/0x150)
      [   36.161388] [<c014aee4>] (kthread) from [<c0107e14>] (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] [<c0c288b0>] (__schedule) from [<c0c29134>] (schedule+0x3c/0xa0)
      [   36.192739] [<c0c29134>] (schedule) from [<c0c2db80>] (schedule_timeout+0x78/0x4e0)
      [   36.200422] [<c0c2db80>] (schedule_timeout) from [<c01a7ab0>] (rcu_gp_kthread+0x648/0x1864)
      [   36.208800] [<c01a7ab0>] (rcu_gp_kthread) from [<c014aee4>] (kthread+0x138/0x150)
      [   36.216309] [<c014aee4>] (kthread) from [<c0107e14>] (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: 179a502f ("rtc: snvs: add Freescale rtc-snvs driver")
      Signed-off-by: default avatarBryan O'Donoghue <pure.logic@nexus-software.ie>
      Acked-by: default avatarShawn Guo <shawn.guo@linaro.org>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      731d965a
    • Uwe Kleine-König's avatar
      serial: altera: ensure port->regshift is honored consistently · 8293e623
      Uwe Kleine-König authored
      [ Upstream commit 0e254963 ]
      
      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 4d9d7d89 ("serial: altera_uart:
      add earlycon support").
      
      Fixes: 2780ad42 ("tty: serial: altera_uart: Use port->regshift to store bus shift")
      Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Acked-by: default avatarTobias Klauser <tklauser@distanz.ch>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8293e623
    • Vignesh R's avatar
      serial: 8250: Don't service RX FIFO if interrupts are disabled · e10bbc22
      Vignesh R authored
      [ Upstream commit 2e9fe539 ]
      
      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: default avatarVignesh R <vigneshr@ti.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e10bbc22
    • Geert Uytterhoeven's avatar
      serial: arc_uart: Fix out-of-bounds access through DT alias · 1c447ea1
      Geert Uytterhoeven authored
      [ Upstream commit f9f57869 ]
      
      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: ea28fd56 ("serial/arc-uart: switch to devicetree based probing")
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1c447ea1