1. 06 Aug, 2019 6 commits
    • Prarit Bhargava's avatar
      kernel/module.c: Only return -EEXIST for modules that have finished loading · 10430769
      Prarit Bhargava authored
      [ Upstream commit 6e6de3de ]
      
      Microsoft HyperV disables the X86_FEATURE_SMCA bit on AMD systems, and
      linux guests boot with repeated errors:
      
      amd64_edac_mod: Unknown symbol amd_unregister_ecc_decoder (err -2)
      amd64_edac_mod: Unknown symbol amd_register_ecc_decoder (err -2)
      amd64_edac_mod: Unknown symbol amd_report_gart_errors (err -2)
      amd64_edac_mod: Unknown symbol amd_unregister_ecc_decoder (err -2)
      amd64_edac_mod: Unknown symbol amd_register_ecc_decoder (err -2)
      amd64_edac_mod: Unknown symbol amd_report_gart_errors (err -2)
      
      The warnings occur because the module code erroneously returns -EEXIST
      for modules that have failed to load and are in the process of being
      removed from the module list.
      
      module amd64_edac_mod has a dependency on module edac_mce_amd.  Using
      modules.dep, systemd will load edac_mce_amd for every request of
      amd64_edac_mod.  When the edac_mce_amd module loads, the module has
      state MODULE_STATE_UNFORMED and once the module load fails and the state
      becomes MODULE_STATE_GOING.  Another request for edac_mce_amd module
      executes and add_unformed_module() will erroneously return -EEXIST even
      though the previous instance of edac_mce_amd has MODULE_STATE_GOING.
      Upon receiving -EEXIST, systemd attempts to load amd64_edac_mod, which
      fails because of unknown symbols from edac_mce_amd.
      
      add_unformed_module() must wait to return for any case other than
      MODULE_STATE_LIVE to prevent a race between multiple loads of
      dependent modules.
      Signed-off-by: default avatarPrarit Bhargava <prarit@redhat.com>
      Signed-off-by: default avatarBarret Rhoden <brho@google.com>
      Cc: David Arcari <darcari@redhat.com>
      Cc: Jessica Yu <jeyu@kernel.org>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Signed-off-by: default avatarJessica Yu <jeyu@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      10430769
    • Cheng Jian's avatar
      ftrace: Enable trampoline when rec count returns back to one · 81c09bab
      Cheng Jian authored
      [ Upstream commit a124692b ]
      
      Custom trampolines can only be enabled if there is only a single ops
      attached to it. If there's only a single callback registered to a function,
      and the ops has a trampoline registered for it, then we can call the
      trampoline directly. This is very useful for improving the performance of
      ftrace and livepatch.
      
      If more than one callback is registered to a function, the general
      trampoline is used, and the custom trampoline is not restored back to the
      direct call even if all the other callbacks were unregistered and we are
      back to one callback for the function.
      
      To fix this, set FTRACE_FL_TRAMP flag if rec count is decremented
      to one, and the ops that left has a trampoline.
      
      Testing After this patch :
      
      insmod livepatch_unshare_files.ko
      cat /sys/kernel/debug/tracing/enabled_functions
      
      	unshare_files (1) R I	tramp: 0xffffffffc0000000(klp_ftrace_handler+0x0/0xa0) ->ftrace_ops_assist_func+0x0/0xf0
      
      echo unshare_files > /sys/kernel/debug/tracing/set_ftrace_filter
      echo function > /sys/kernel/debug/tracing/current_tracer
      cat /sys/kernel/debug/tracing/enabled_functions
      
      	unshare_files (2) R I ->ftrace_ops_list_func+0x0/0x150
      
      echo nop > /sys/kernel/debug/tracing/current_tracer
      cat /sys/kernel/debug/tracing/enabled_functions
      
      	unshare_files (1) R I	tramp: 0xffffffffc0000000(klp_ftrace_handler+0x0/0xa0) ->ftrace_ops_assist_func+0x0/0xf0
      
      Link: http://lkml.kernel.org/r/1556969979-111047-1-git-send-email-cj.chengjian@huawei.comSigned-off-by: default avatarCheng Jian <cj.chengjian@huawei.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      81c09bab
    • Douglas Anderson's avatar
      ARM: dts: rockchip: Mark that the rk3288 timer might stop in suspend · 614e14d6
      Douglas Anderson authored
      [ Upstream commit 8ef1ba39 ]
      
      This is similar to commit e6186820 ("arm64: dts: rockchip: Arch
      counter doesn't tick in system suspend").  Specifically on the rk3288
      it can be seen that the timer stops ticking in suspend if we end up
      running through the "osc_disable" path in rk3288_slp_mode_set().  In
      that path the 24 MHz clock will turn off and the timer stops.
      
      To test this, I ran this on a Chrome OS filesystem:
        before=$(date); \
        suspend_stress_test -c1 --suspend_min=30 --suspend_max=31; \
        echo ${before}; date
      
      ...and I found that unless I plug in a device that requests USB wakeup
      to be active that the two calls to "date" would show that fewer than
      30 seconds passed.
      
      NOTE: deep suspend (where the 24 MHz clock gets disabled) isn't
      supported yet on upstream Linux so this was tested on a downstream
      kernel.
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      614e14d6
    • Douglas Anderson's avatar
      ARM: dts: rockchip: Make rk3288-veyron-mickey's emmc work again · 2b0a7453
      Douglas Anderson authored
      [ Upstream commit 99fa0667 ]
      
      When I try to boot rk3288-veyron-mickey I totally fail to make the
      eMMC work.  Specifically my logs (on Chrome OS 4.19):
      
        mmc_host mmc1: card is non-removable.
        mmc_host mmc1: Bus speed (slot 0) = 400000Hz (slot req 400000Hz, actual 400000HZ div = 0)
        mmc_host mmc1: Bus speed (slot 0) = 50000000Hz (slot req 52000000Hz, actual 50000000HZ div = 0)
        mmc1: switch to bus width 8 failed
        mmc1: switch to bus width 4 failed
        mmc1: new high speed MMC card at address 0001
        mmcblk1: mmc1:0001 HAG2e 14.7 GiB
        mmcblk1boot0: mmc1:0001 HAG2e partition 1 4.00 MiB
        mmcblk1boot1: mmc1:0001 HAG2e partition 2 4.00 MiB
        mmcblk1rpmb: mmc1:0001 HAG2e partition 3 4.00 MiB, chardev (243:0)
        mmc_host mmc1: Bus speed (slot 0) = 400000Hz (slot req 400000Hz, actual 400000HZ div = 0)
        mmc_host mmc1: Bus speed (slot 0) = 50000000Hz (slot req 52000000Hz, actual 50000000HZ div = 0)
        mmc1: switch to bus width 8 failed
        mmc1: switch to bus width 4 failed
        mmc1: tried to HW reset card, got error -110
        mmcblk1: error -110 requesting status
        mmcblk1: recovery failed!
        print_req_error: I/O error, dev mmcblk1, sector 0
        ...
      
      When I remove the '/delete-property/mmc-hs200-1_8v' then everything is
      hunky dory.
      
      That line comes from the original submission of the mickey dts
      upstream, so presumably at the time the HS200 was failing and just
      enumerating things as a high speed device was fine.  ...or maybe it's
      just that some mickey devices work when enumerating at "high speed",
      just not mine?
      
      In any case, hs200 seems good now.  Let's turn it on.
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2b0a7453
    • Douglas Anderson's avatar
      ARM: dts: rockchip: Make rk3288-veyron-minnie run at hs200 · 1078e302
      Douglas Anderson authored
      [ Upstream commit 1c047902 ]
      
      As some point hs200 was failing on rk3288-veyron-minnie.  See commit
      98492678 ("ARM: dts: rockchip: temporarily remove emmc hs200 speed
      from rk3288 minnie").  Although I didn't track down exactly when it
      started working, it seems to work OK now, so let's turn it back on.
      
      To test this, I booted from SD card and then used this script to
      stress the enumeration process after fixing a memory leak [1]:
        cd /sys/bus/platform/drivers/dwmmc_rockchip
        for i in $(seq 1 3000); do
          echo "========================" $i
          echo ff0f0000.dwmmc > unbind
          sleep .5
          echo ff0f0000.dwmmc > bind
          while true; do
            if [ -e /dev/mmcblk2 ]; then
              break;
            fi
            sleep .1
          done
        done
      
      It worked fine.
      
      [1] https://lkml.kernel.org/r/20190503233526.226272-1-dianders@chromium.orgSigned-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1078e302
    • Russell King's avatar
      ARM: riscpc: fix DMA · 790fc2d3
      Russell King authored
      [ Upstream commit ffd9a1ba ]
      
      DMA got broken a while back in two different ways:
      1) a change in the behaviour of disable_irq() to wait for the interrupt
         to finish executing causes us to deadlock at the end of DMA.
      2) a change to avoid modifying the scatterlist left the first transfer
         uninitialised.
      
      DMA is only used with expansion cards, so has gone unnoticed.
      
      Fixes: fa4e9989 ("[ARM] dma: RiscPC: don't modify DMA SG entries")
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      790fc2d3
  2. 04 Aug, 2019 34 commits
    • Greg Kroah-Hartman's avatar
      Linux 4.9.187 · 97d7530b
      Greg Kroah-Hartman authored
      97d7530b
    • Yan, Zheng's avatar
      ceph: hold i_ceph_lock when removing caps for freeing inode · 370bb858
      Yan, Zheng authored
      commit d6e47819 upstream.
      
      ceph_d_revalidate(, LOOKUP_RCU) may call __ceph_caps_issued_mask()
      on a freeing inode.
      Signed-off-by: default avatar"Yan, Zheng" <zyan@redhat.com>
      Reviewed-by: default avatarJeff Layton <jlayton@redhat.com>
      Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      370bb858
    • Miroslav Lichvar's avatar
      drivers/pps/pps.c: clear offset flags in PPS_SETPARAMS ioctl · 91c5daaa
      Miroslav Lichvar authored
      commit 5515e9a6 upstream.
      
      The PPS assert/clear offset corrections are set by the PPS_SETPARAMS
      ioctl in the pps_ktime structs, which also contain flags.  The flags are
      not initialized by applications (using the timepps.h header) and they
      are not used by the kernel for anything except returning them back in
      the PPS_GETPARAMS ioctl.
      
      Set the flags to zero to make it clear they are unused and avoid leaking
      uninitialized data of the PPS_SETPARAMS caller to other applications
      that have a read access to the PPS device.
      
      Link: http://lkml.kernel.org/r/20190702092251.24303-1-mlichvar@redhat.comSigned-off-by: default avatarMiroslav Lichvar <mlichvar@redhat.com>
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: default avatarRodolfo Giometti <giometti@enneenne.com>
      Cc: Greg KH <greg@kroah.com>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      91c5daaa
    • Jann Horn's avatar
      sched/fair: Don't free p->numa_faults with concurrent readers · 837ffc97
      Jann Horn authored
      commit 16d51a59 upstream.
      
      When going through execve(), zero out the NUMA fault statistics instead of
      freeing them.
      
      During execve, the task is reachable through procfs and the scheduler. A
      concurrent /proc/*/sched reader can read data from a freed ->numa_faults
      allocation (confirmed by KASAN) and write it back to userspace.
      I believe that it would also be possible for a use-after-free read to occur
      through a race between a NUMA fault and execve(): task_numa_fault() can
      lead to task_numa_compare(), which invokes task_weight() on the currently
      running task of a different CPU.
      
      Another way to fix this would be to make ->numa_faults RCU-managed or add
      extra locking, but it seems easier to wipe the NUMA fault statistics on
      execve.
      Signed-off-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will@kernel.org>
      Fixes: 82727018 ("sched/numa: Call task_numa_free() from do_execve()")
      Link: https://lkml.kernel.org/r/20190716152047.14424-1-jannh@google.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      837ffc97
    • Vladis Dronov's avatar
      Bluetooth: hci_uart: check for missing tty operations · 58a01b0b
      Vladis Dronov authored
      commit b36a1552 upstream.
      
      Certain ttys operations (pty_unix98_ops) lack tiocmget() and tiocmset()
      functions which are called by the certain HCI UART protocols (hci_ath,
      hci_bcm, hci_intel, hci_mrvl, hci_qca) via hci_uart_set_flow_control()
      or directly. This leads to an execution at NULL and can be triggered by
      an unprivileged user. Fix this by adding a helper function and a check
      for the missing tty operations in the protocols code.
      
      This fixes CVE-2019-10207. The Fixes: lines list commits where calls to
      tiocm[gs]et() or hci_uart_set_flow_control() were added to the HCI UART
      protocols.
      
      Link: https://syzkaller.appspot.com/bug?id=1b42faa2848963564a5b1b7f8c837ea7b55ffa50
      Reported-by: syzbot+79337b501d6aa974d0f6@syzkaller.appspotmail.com
      Cc: stable@vger.kernel.org # v2.6.36+
      Fixes: b3190df6 ("Bluetooth: Support for Atheros AR300x serial chip")
      Fixes: 118612fb ("Bluetooth: hci_bcm: Add suspend/resume PM functions")
      Fixes: ff289559 ("Bluetooth: hci_intel: Add Intel baudrate configuration support")
      Fixes: 162f812f ("Bluetooth: hci_uart: Add Marvell support")
      Fixes: fa9ad876 ("Bluetooth: hci_qca: Add support for Qualcomm Bluetooth chip wcn3990")
      Signed-off-by: default avatarVladis Dronov <vdronov@redhat.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Reviewed-by: default avatarYu-Chen, Cho <acho@suse.com>
      Tested-by: default avatarYu-Chen, Cho <acho@suse.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      58a01b0b
    • Luke Nowakowski-Krijger's avatar
      media: radio-raremono: change devm_k*alloc to k*alloc · 4c0a7ec4
      Luke Nowakowski-Krijger authored
      commit c666355e upstream.
      
      Change devm_k*alloc to k*alloc to manually allocate memory
      
      The manual allocation and freeing of memory is necessary because when
      the USB radio is disconnected, the memory associated with devm_k*alloc
      is freed. Meaning if we still have unresolved references to the radio
      device, then we get use-after-free errors.
      
      This patch fixes this by manually allocating memory, and freeing it in
      the v4l2.release callback that gets called when the last radio device
      exits.
      
      Reported-and-tested-by: syzbot+a4387f5b6b799f6becbf@syzkaller.appspotmail.com
      Signed-off-by: default avatarLuke Nowakowski-Krijger <lnowakow@eng.ucsd.edu>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      [hverkuil-cisco@xs4all.nl: cleaned up two small checkpatch.pl warnings]
      [hverkuil-cisco@xs4all.nl: prefix subject with driver name]
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4c0a7ec4
    • Oliver Neukum's avatar
      media: cpia2_usb: first wake up, then free in disconnect · 0b8a71a8
      Oliver Neukum authored
      commit eff73de2 upstream.
      
      Kasan reported a use after free in cpia2_usb_disconnect()
      It first freed everything and then woke up those waiting.
      The reverse order is correct.
      
      Fixes: 6c493f8b ("[media] cpia2: major overhaul to get it in a working state again")
      Signed-off-by: default avatarOliver Neukum <oneukum@suse.com>
      Reported-by: syzbot+0c90fc937c84f97d0aa6@syzkaller.appspotmail.com
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0b8a71a8
    • Sean Young's avatar
      media: au0828: fix null dereference in error path · f7d3edb0
      Sean Young authored
      commit 6d0d1ff9 upstream.
      
      au0828_usb_disconnect() gets the au0828_dev struct via usb_get_intfdata,
      so it needs to set up for the error paths.
      
      Reported-by: syzbot+357d86bcb4cca1a2f572@syzkaller.appspotmail.com
      Signed-off-by: default avatarSean Young <sean@mess.org>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f7d3edb0
    • Phong Tran's avatar
      ISDN: hfcsusb: checking idx of ep configuration · af34434a
      Phong Tran authored
      commit f384e62a upstream.
      
      The syzbot test with random endpoint address which made the idx is
      overflow in the table of endpoint configuations.
      
      this adds the checking for fixing the error report from
      syzbot
      
      KASAN: stack-out-of-bounds Read in hfcsusb_probe [1]
      The patch tested by syzbot [2]
      
      Reported-by: syzbot+8750abbc3a46ef47d509@syzkaller.appspotmail.com
      
      [1]:
      https://syzkaller.appspot.com/bug?id=30a04378dac680c5d521304a00a86156bb913522
      [2]:
      https://groups.google.com/d/msg/syzkaller-bugs/_6HBdge8F3E/OJn7wVNpBAAJSigned-off-by: default avatarPhong Tran <tranmanphong@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      af34434a
    • Will Deacon's avatar
      arm64: compat: Provide definition for COMPAT_SIGMINSTKSZ · 8902d3a8
      Will Deacon authored
      commit 24951465 upstream.
      
      arch/arm/ defines a SIGMINSTKSZ of 2k, so we should use the same value
      for compat tasks.
      
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Dominik Brodowski <linux@dominikbrodowski.net>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Reviewed-by: default avatarDave Martin <Dave.Martin@arm.com>
      Reported-by: default avatarSteve McIntyre <steve.mcintyre@arm.com>
      Tested-by: default avatarSteve McIntyre <93sam@debian.org>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8902d3a8
    • Abhishek Sahu's avatar
      i2c: qup: fixed releasing dma without flush operation completion · 51e26d23
      Abhishek Sahu authored
      commit 7239872f upstream.
      
      The QUP BSLP BAM generates the following error sometimes if the
      current I2C DMA transfer fails and the flush operation has been
      scheduled
      
          “bam-dma-engine 7884000.dma: Cannot free busy channel”
      
      If any I2C error comes during BAM DMA transfer, then the QUP I2C
      interrupt will be generated and the flush operation will be
      carried out to make I2C consume all scheduled DMA transfer.
      Currently, the same completion structure is being used for BAM
      transfer which has already completed without reinit. It will make
      flush operation wait_for_completion_timeout completed immediately
      and will proceed for freeing the DMA resources where the
      descriptors are still in process.
      Signed-off-by: default avatarAbhishek Sahu <absahu@codeaurora.org>
      Acked-by: default avatarSricharan R <sricharan@codeaurora.org>
      Reviewed-by: default avatarAustin Christ <austinwc@codeaurora.org>
      Reviewed-by: default avatarAndy Gross <andy.gross@linaro.org>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      Signed-off-by: default avatarAmit Pundir <amit.pundir@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      51e26d23
    • allen yan's avatar
      arm64: dts: marvell: Fix A37xx UART0 register size · e522a090
      allen yan authored
      commit c737abc1 upstream.
      
      Armada-37xx UART0 registers are 0x200 bytes wide. Right next to them are
      the UART1 registers that should not be declared in this node.
      
      Update the example in DT bindings document accordingly.
      Signed-off-by: default avatarallen yan <yanwei@marvell.com>
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@free-electrons.com>
      Signed-off-by: default avatarGregory CLEMENT <gregory.clement@free-electrons.com>
      Signed-off-by: default avatarAmit Pundir <amit.pundir@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e522a090
    • Soheil Hassas Yeganeh's avatar
      tcp: reset sk_send_head in tcp_write_queue_purge · 70453339
      Soheil Hassas Yeganeh authored
      [ Upstream commit dbbf2d1e4077bab0c65ece2765d3fc69cf7d610f ]
      
      tcp_write_queue_purge clears all the SKBs in the write queue
      but does not reset the sk_send_head. As a result, we can have
      a NULL pointer dereference anywhere that we use tcp_send_head
      instead of the tcp_write_queue_tail.
      
      For example, after a27fd7a8 (tcp: purge write queue upon RST),
      we can purge the write queue on RST. Prior to
      75c119af (tcp: implement rb-tree based retransmit queue),
      tcp_push will only check tcp_send_head and then accesses
      tcp_write_queue_tail to send the actual SKB. As a result, it will
      dereference a NULL pointer.
      
      This has been reported twice for 4.14 where we don't have
      75c119af:
      
      By Timofey Titovets:
      
      [  422.081094] BUG: unable to handle kernel NULL pointer dereference
      at 0000000000000038
      [  422.081254] IP: tcp_push+0x42/0x110
      [  422.081314] PGD 0 P4D 0
      [  422.081364] Oops: 0002 [#1] SMP PTI
      
      By Yongjian Xu:
      
      BUG: unable to handle kernel NULL pointer dereference at 0000000000000038
      IP: tcp_push+0x48/0x120
      PGD 80000007ff77b067 P4D 80000007ff77b067 PUD 7fd989067 PMD 0
      Oops: 0002 [#18] SMP PTI
      Modules linked in: tcp_diag inet_diag tcp_bbr sch_fq iTCO_wdt
      iTCO_vendor_support pcspkr ixgbe mdio i2c_i801 lpc_ich joydev input_leds shpchp
      e1000e igb dca ptp pps_core hwmon mei_me mei ipmi_si ipmi_msghandler sg ses
      scsi_transport_sas enclosure ext4 jbd2 mbcache sd_mod ahci libahci megaraid_sas
      wmi ast ttm dm_mirror dm_region_hash dm_log dm_mod dax
      CPU: 6 PID: 14156 Comm: [ET_NET 6] Tainted: G D 4.14.26-1.el6.x86_64 #1
      Hardware name: LENOVO ThinkServer RD440 /ThinkServer RD440, BIOS A0TS80A
      09/22/2014
      task: ffff8807d78d8140 task.stack: ffffc9000e944000
      RIP: 0010:tcp_push+0x48/0x120
      RSP: 0018:ffffc9000e947a88 EFLAGS: 00010246
      RAX: 00000000000005b4 RBX: ffff880f7cce9c00 RCX: 0000000000000000
      RDX: 0000000000000000 RSI: 0000000000000040 RDI: ffff8807d00f5000
      RBP: ffffc9000e947aa8 R08: 0000000000001c84 R09: 0000000000000000
      R10: ffff8807d00f5158 R11: 0000000000000000 R12: ffff8807d00f5000
      R13: 0000000000000020 R14: 00000000000256d4 R15: 0000000000000000
      FS: 00007f5916de9700(0000) GS:ffff88107fd00000(0000) knlGS:0000000000000000
      CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000000000000038 CR3: 00000007f8226004 CR4: 00000000001606e0
      Call Trace:
      tcp_sendmsg_locked+0x33d/0xe50
      tcp_sendmsg+0x37/0x60
      inet_sendmsg+0x39/0xc0
      sock_sendmsg+0x49/0x60
      sock_write_iter+0xb6/0x100
      do_iter_readv_writev+0xec/0x130
      ? rw_verify_area+0x49/0xb0
      do_iter_write+0x97/0xd0
      vfs_writev+0x7e/0xe0
      ? __wake_up_common_lock+0x80/0xa0
      ? __fget_light+0x2c/0x70
      ? __do_page_fault+0x1e7/0x530
      do_writev+0x60/0xf0
      ? inet_shutdown+0xac/0x110
      SyS_writev+0x10/0x20
      do_syscall_64+0x6f/0x140
      ? prepare_exit_to_usermode+0x8b/0xa0
      entry_SYSCALL_64_after_hwframe+0x3d/0xa2
      RIP: 0033:0x3135ce0c57
      RSP: 002b:00007f5916de4b00 EFLAGS: 00000293 ORIG_RAX: 0000000000000014
      RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000003135ce0c57
      RDX: 0000000000000002 RSI: 00007f5916de4b90 RDI: 000000000000606f
      RBP: 0000000000000000 R08: 0000000000000000 R09: 00007f5916de8c38
      R10: 0000000000000000 R11: 0000000000000293 R12: 00000000000464cc
      R13: 00007f5916de8c30 R14: 00007f58d8bef080 R15: 0000000000000002
      Code: 48 8b 97 60 01 00 00 4c 8d 97 58 01 00 00 41 b9 00 00 00 00 41 89 f3 4c 39
      d2 49 0f 44 d1 41 81 e3 00 80 00 00 0f 85 b0 00 00 00 <80> 4a 38 08 44 8b 8f 74
      06 00 00 44 89 8f 7c 06 00 00 83 e6 01
      RIP: tcp_push+0x48/0x120 RSP: ffffc9000e947a88
      CR2: 0000000000000038
      ---[ end trace 8d545c2e93515549 ]---
      
      There is other scenario which found in stable 4.4:
      Allocated:
       [<ffffffff82f380a6>] __alloc_skb+0xe6/0x600 net/core/skbuff.c:218
       [<ffffffff832466c3>] alloc_skb_fclone include/linux/skbuff.h:856 [inline]
       [<ffffffff832466c3>] sk_stream_alloc_skb+0xa3/0x5d0 net/ipv4/tcp.c:833
       [<ffffffff83249164>] tcp_sendmsg+0xd34/0x2b00 net/ipv4/tcp.c:1178
       [<ffffffff83300ef3>] inet_sendmsg+0x203/0x4d0 net/ipv4/af_inet.c:755
      Freed:
       [<ffffffff82f372fd>] __kfree_skb+0x1d/0x20 net/core/skbuff.c:676
       [<ffffffff83288834>] sk_wmem_free_skb include/net/sock.h:1447 [inline]
       [<ffffffff83288834>] tcp_write_queue_purge include/net/tcp.h:1460 [inline]
       [<ffffffff83288834>] tcp_connect_init net/ipv4/tcp_output.c:3122 [inline]
       [<ffffffff83288834>] tcp_connect+0xb24/0x30c0 net/ipv4/tcp_output.c:3261
       [<ffffffff8329b991>] tcp_v4_connect+0xf31/0x1890 net/ipv4/tcp_ipv4.c:246
      
      BUG: KASAN: use-after-free in tcp_skb_pcount include/net/tcp.h:796 [inline]
      BUG: KASAN: use-after-free in tcp_init_tso_segs net/ipv4/tcp_output.c:1619 [inline]
      BUG: KASAN: use-after-free in tcp_write_xmit+0x3fc2/0x4cb0 net/ipv4/tcp_output.c:2056
       [<ffffffff81515cd5>] kasan_report.cold.7+0x175/0x2f7 mm/kasan/report.c:408
       [<ffffffff814f9784>] __asan_report_load2_noabort+0x14/0x20 mm/kasan/report.c:427
       [<ffffffff83286582>] tcp_skb_pcount include/net/tcp.h:796 [inline]
       [<ffffffff83286582>] tcp_init_tso_segs net/ipv4/tcp_output.c:1619 [inline]
       [<ffffffff83286582>] tcp_write_xmit+0x3fc2/0x4cb0 net/ipv4/tcp_output.c:2056
       [<ffffffff83287a40>] __tcp_push_pending_frames+0xa0/0x290 net/ipv4/tcp_output.c:2307
      
      stable 4.4 and stable 4.9 don't have the commit abb4a8b870b5 ("tcp: purge write queue upon RST")
      which is referred in dbbf2d1e4077,
      in tcp_connect_init, it calls tcp_write_queue_purge, and does not reset sk_send_head, then UAF.
      
      stable 4.14 have the commit abb4a8b870b5 ("tcp: purge write queue upon RST"),
      in tcp_reset, it calls tcp_write_queue_purge(sk), and does not reset sk_send_head, then UAF.
      
      So this patch can be used to fix stable 4.4 and 4.9.
      
      Fixes: a27fd7a8 (tcp: purge write queue upon RST)
      Reported-by: default avatarTimofey Titovets <nefelim4ag@gmail.com>
      Reported-by: default avatarYongjian Xu <yongjianchn@gmail.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarSoheil Hassas Yeganeh <soheil@google.com>
      Tested-by: default avatarYongjian Xu <yongjianchn@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarMao Wenan <maowenan@huawei.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      70453339
    • Xin Long's avatar
      ipv6: check sk sk_type and protocol early in ip_mroute_set/getsockopt · 1e531ad4
      Xin Long authored
      [ Upstream commit 99253eb7 ]
      
      Commit 5e1859fb ("ipv4: ipmr: various fixes and cleanups") fixed
      the issue for ipv4 ipmr:
      
        ip_mroute_setsockopt() & ip_mroute_getsockopt() should not
        access/set raw_sk(sk)->ipmr_table before making sure the socket
        is a raw socket, and protocol is IGMP
      
      The same fix should be done for ipv6 ipmr as well.
      
      This patch can fix the panic caused by overwriting the same offset
      as ipmr_table as in raw_sk(sk) when accessing other type's socket
      by ip_mroute_setsockopt().
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1e531ad4
    • Linus Torvalds's avatar
      access: avoid the RCU grace period for the temporary subjective credentials · 50810015
      Linus Torvalds authored
      commit d7852fbd upstream.
      
      It turns out that 'access()' (and 'faccessat()') can cause a lot of RCU
      work because it installs a temporary credential that gets allocated and
      freed for each system call.
      
      The allocation and freeing overhead is mostly benign, but because
      credentials can be accessed under the RCU read lock, the freeing
      involves a RCU grace period.
      
      Which is not a huge deal normally, but if you have a lot of access()
      calls, this causes a fair amount of seconday damage: instead of having a
      nice alloc/free patterns that hits in hot per-CPU slab caches, you have
      all those delayed free's, and on big machines with hundreds of cores,
      the RCU overhead can end up being enormous.
      
      But it turns out that all of this is entirely unnecessary.  Exactly
      because access() only installs the credential as the thread-local
      subjective credential, the temporary cred pointer doesn't actually need
      to be RCU free'd at all.  Once we're done using it, we can just free it
      synchronously and avoid all the RCU overhead.
      
      So add a 'non_rcu' flag to 'struct cred', which can be set by users that
      know they only use it in non-RCU context (there are other potential
      users for this).  We can make it a union with the rcu freeing list head
      that we need for the RCU case, so this doesn't need any extra storage.
      
      Note that this also makes 'get_current_cred()' clear the new non_rcu
      flag, in case we have filesystems that take a long-term reference to the
      cred and then expect the RCU delayed freeing afterwards.  It's not
      entirely clear that this is required, but it makes for clear semantics:
      the subjective cred remains non-RCU as long as you only access it
      synchronously using the thread-local accessors, but you _can_ use it as
      a generic cred if you want to.
      
      It is possible that we should just remove the whole RCU markings for
      ->cred entirely.  Only ->real_cred is really supposed to be accessed
      through RCU, and the long-term cred copies that nfs uses might want to
      explicitly re-enable RCU freeing if required, rather than have
      get_current_cred() do it implicitly.
      
      But this is a "minimal semantic changes" change for the immediate
      problem.
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarEric Dumazet <edumazet@google.com>
      Acked-by: default avatarPaul E. McKenney <paulmck@linux.ibm.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Jan Glauber <jglauber@marvell.com>
      Cc: Jiri Kosina <jikos@kernel.org>
      Cc: Jayachandran Chandrasekharan Nair <jnair@marvell.com>
      Cc: Greg KH <greg@kroah.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Miklos Szeredi <miklos@szeredi.hu>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      50810015
    • Michael Neuling's avatar
      powerpc/tm: Fix oops on sigreturn on systems without TM · 08ee34d8
      Michael Neuling authored
      commit f16d80b7 upstream.
      
      On systems like P9 powernv where we have no TM (or P8 booted with
      ppc_tm=off), userspace can construct a signal context which still has
      the MSR TS bits set. The kernel tries to restore this context which
      results in the following crash:
      
        Unexpected TM Bad Thing exception at c0000000000022fc (msr 0x8000000102a03031) tm_scratch=800000020280f033
        Oops: Unrecoverable exception, sig: 6 [#1]
        LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries
        Modules linked in:
        CPU: 0 PID: 1636 Comm: sigfuz Not tainted 5.2.0-11043-g0a8ad0ff #69
        NIP:  c0000000000022fc LR: 00007fffb2d67e48 CTR: 0000000000000000
        REGS: c00000003fffbd70 TRAP: 0700   Not tainted  (5.2.0-11045-g7142b497d8)
        MSR:  8000000102a03031 <SF,VEC,VSX,FP,ME,IR,DR,LE,TM[E]>  CR: 42004242  XER: 00000000
        CFAR: c0000000000022e0 IRQMASK: 0
        GPR00: 0000000000000072 00007fffb2b6e560 00007fffb2d87f00 0000000000000669
        GPR04: 00007fffb2b6e728 0000000000000000 0000000000000000 00007fffb2b6f2a8
        GPR08: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
        GPR12: 0000000000000000 00007fffb2b76900 0000000000000000 0000000000000000
        GPR16: 00007fffb2370000 00007fffb2d84390 00007fffea3a15ac 000001000a250420
        GPR20: 00007fffb2b6f260 0000000010001770 0000000000000000 0000000000000000
        GPR24: 00007fffb2d843a0 00007fffea3a14a0 0000000000010000 0000000000800000
        GPR28: 00007fffea3a14d8 00000000003d0f00 0000000000000000 00007fffb2b6e728
        NIP [c0000000000022fc] rfi_flush_fallback+0x7c/0x80
        LR [00007fffb2d67e48] 0x7fffb2d67e48
        Call Trace:
        Instruction dump:
        e96a0220 e96a02a8 e96a0330 e96a03b8 394a0400 4200ffdc 7d2903a6 e92d0c00
        e94d0c08 e96d0c10 e82d0c18 7db242a6 <4c000024> 7db243a6 7db142a6 f82d0c18
      
      The problem is the signal code assumes TM is enabled when
      CONFIG_PPC_TRANSACTIONAL_MEM is enabled. This may not be the case as
      with P9 powernv or if `ppc_tm=off` is used on P8.
      
      This means any local user can crash the system.
      
      Fix the problem by returning a bad stack frame to the user if they try
      to set the MSR TS bits with sigreturn() on systems where TM is not
      supported.
      
      Found with sigfuz kernel selftest on P9.
      
      This fixes CVE-2019-13648.
      
      Fixes: 2b0a576d ("powerpc: Add new transactional memory state to the signal context")
      Cc: stable@vger.kernel.org # v3.9
      Reported-by: default avatarPraveen Pandey <Praveen.Pandey@in.ibm.com>
      Signed-off-by: default avatarMichael Neuling <mikey@neuling.org>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20190719050502.405-1-mikey@neuling.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      08ee34d8
    • Hui Wang's avatar
      ALSA: hda - Add a conexant codec entry to let mute led work · 2f4b7fbb
      Hui Wang authored
      commit 3f880949 upstream.
      
      This conexant codec isn't in the supported codec list yet, the hda
      generic driver can drive this codec well, but on a Lenovo machine
      with mute/mic-mute leds, we need to apply CXT_FIXUP_THINKPAD_ACPI
      to make the leds work. After adding this codec to the list, the
      driver patch_conexant.c will apply THINKPAD_ACPI to this machine.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarHui Wang <hui.wang@canonical.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2f4b7fbb
    • Kai-Heng Feng's avatar
      ALSA: line6: Fix wrong altsetting for LINE6_PODHD500_1 · ec565611
      Kai-Heng Feng authored
      commit 70256b42 upstream.
      
      Commit 7b9584fa ("staging: line6: Move altsetting to properties")
      set a wrong altsetting for LINE6_PODHD500_1 during refactoring.
      
      Set the correct altsetting number to fix the issue.
      
      BugLink: https://bugs.launchpad.net/bugs/1790595
      Fixes: 7b9584fa ("staging: line6: Move altsetting to properties")
      Signed-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ec565611
    • Kefeng Wang's avatar
      hpet: Fix division by zero in hpet_time_div() · 0cbed4f1
      Kefeng Wang authored
      commit 0c7d37f4 upstream.
      
      The base value in do_div() called by hpet_time_div() is truncated from
      unsigned long to uint32_t, resulting in a divide-by-zero exception.
      
      UBSAN: Undefined behaviour in ../drivers/char/hpet.c:572:2
      division by zero
      CPU: 1 PID: 23682 Comm: syz-executor.3 Not tainted 4.4.184.x86_64+ #4
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
       0000000000000000 b573382df1853d00 ffff8800a3287b98 ffffffff81ad7561
       ffff8800a3287c00 ffffffff838b35b0 ffffffff838b3860 ffff8800a3287c20
       0000000000000000 ffff8800a3287bb0 ffffffff81b8f25e ffffffff838b35a0
      Call Trace:
       [<ffffffff81ad7561>] __dump_stack lib/dump_stack.c:15 [inline]
       [<ffffffff81ad7561>] dump_stack+0xc1/0x120 lib/dump_stack.c:51
       [<ffffffff81b8f25e>] ubsan_epilogue+0x12/0x8d lib/ubsan.c:166
       [<ffffffff81b900cb>] __ubsan_handle_divrem_overflow+0x282/0x2c8 lib/ubsan.c:262
       [<ffffffff823560dd>] hpet_time_div drivers/char/hpet.c:572 [inline]
       [<ffffffff823560dd>] hpet_ioctl_common drivers/char/hpet.c:663 [inline]
       [<ffffffff823560dd>] hpet_ioctl_common.cold+0xa8/0xad drivers/char/hpet.c:577
       [<ffffffff81e63d56>] hpet_ioctl+0xc6/0x180 drivers/char/hpet.c:676
       [<ffffffff81711590>] vfs_ioctl fs/ioctl.c:43 [inline]
       [<ffffffff81711590>] file_ioctl fs/ioctl.c:470 [inline]
       [<ffffffff81711590>] do_vfs_ioctl+0x6e0/0xf70 fs/ioctl.c:605
       [<ffffffff81711eb4>] SYSC_ioctl fs/ioctl.c:622 [inline]
       [<ffffffff81711eb4>] SyS_ioctl+0x94/0xc0 fs/ioctl.c:613
       [<ffffffff82846003>] tracesys_phase2+0x90/0x95
      
      The main C reproducer autogenerated by syzkaller,
      
        syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0);
        memcpy((void*)0x20000100, "/dev/hpet\000", 10);
        syscall(__NR_openat, 0xffffffffffffff9c, 0x20000100, 0, 0);
        syscall(__NR_ioctl, r[0], 0x40086806, 0x40000000000000);
      
      Fix it by using div64_ul().
      Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Signed-off-by: default avatarZhang HongJun <zhanghongjun2@huawei.com>
      Cc: stable <stable@vger.kernel.org>
      Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
      Link: https://lore.kernel.org/r/20190711132757.130092-1-wangkefeng.wang@huawei.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0cbed4f1
    • Zhenzhong Duan's avatar
      x86/speculation/mds: Apply more accurate check on hypervisor platform · 24db040f
      Zhenzhong Duan authored
      commit 517c3ba0 upstream.
      
      X86_HYPER_NATIVE isn't accurate for checking if running on native platform,
      e.g. CONFIG_HYPERVISOR_GUEST isn't set or "nopv" is enabled.
      
      Checking the CPU feature bit X86_FEATURE_HYPERVISOR to determine if it's
      running on native platform is more accurate.
      
      This still doesn't cover the platforms on which X86_FEATURE_HYPERVISOR is
      unsupported, e.g. VMware, but there is nothing which can be done about this
      scenario.
      
      Fixes: 8a4b06d3 ("x86/speculation/mds: Add sysfs reporting for MDS")
      Signed-off-by: default avatarZhenzhong Duan <zhenzhong.duan@oracle.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/1564022349-17338-1-git-send-email-zhenzhong.duan@oracle.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      24db040f
    • Hans de Goede's avatar
      x86/sysfb_efi: Add quirks for some devices with swapped width and height · f7e02b15
      Hans de Goede authored
      commit d02f1aa3 upstream.
      
      Some Lenovo 2-in-1s with a detachable keyboard have a portrait screen but
      advertise a landscape resolution and pitch, resulting in a messed up
      display if the kernel tries to show anything on the efifb (because of the
      wrong pitch).
      
      Fix this by adding a new DMI match table for devices which need to have
      their width and height swapped.
      
      At first it was tried to use the existing table for overriding some of the
      efifb parameters, but some of the affected devices have variants with
      different LCD resolutions which will not work with hardcoded override
      values.
      
      Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1730783Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/20190721152418.11644-1-hdegoede@redhat.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f7e02b15
    • Ryan Kennedy's avatar
      usb: pci-quirks: Correct AMD PLL quirk detection · 71960676
      Ryan Kennedy authored
      commit f3dccdaa upstream.
      
      The AMD PLL USB quirk is incorrectly enabled on newer Ryzen
      chipsets. The logic in usb_amd_find_chipset_info currently checks
      for unaffected chipsets rather than affected ones. This broke
      once a new chipset was added in e788787e. It makes more sense
      to reverse the logic so it won't need to be updated as new
      chipsets are added. Note that the core of the workaround in
      usb_amd_quirk_pll does correctly check the chipset.
      Signed-off-by: default avatarRyan Kennedy <ryan5544@gmail.com>
      Fixes: e788787e ("usb:xhci:Add quirk for Certain failing HP keyboard on reset after resume")
      Cc: stable <stable@vger.kernel.org>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Link: https://lore.kernel.org/r/20190704153529.9429-2-ryan5544@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      71960676
    • Phong Tran's avatar
      usb: wusbcore: fix unbalanced get/put cluster_id · 53955976
      Phong Tran authored
      commit f90bf1ec upstream.
      
      syzboot reported that
      https://syzkaller.appspot.com/bug?extid=fd2bd7df88c606eea4ef
      
      There is not consitency parameter in cluste_id_get/put calling.
      In case of getting the id with result is failure, the wusbhc->cluster_id
      will not be updated and this can not be used for wusb_cluster_id_put().
      
      Tested report
      https://groups.google.com/d/msg/syzkaller-bugs/0znZopp3-9k/oxOrhLkLEgAJ
      
      Reproduce and gdb got the details:
      
      139		addr = wusb_cluster_id_get();
      (gdb) n
      140		if (addr == 0)
      (gdb) print addr
      $1 = 254 '\376'
      (gdb) n
      142		result = __hwahc_set_cluster_id(hwahc, addr);
      (gdb) print result
      $2 = -71
      (gdb) break wusb_cluster_id_put
      Breakpoint 3 at 0xffffffff836e3f20: file drivers/usb/wusbcore/wusbhc.c, line 384.
      (gdb) s
      Thread 2 hit Breakpoint 3, wusb_cluster_id_put (id=0 '\000') at drivers/usb/wusbcore/wusbhc.c:384
      384		id = 0xff - id;
      (gdb) n
      385		BUG_ON(id >= CLUSTER_IDS);
      (gdb) print id
      $3 = 255 '\377'
      
      Reported-by: syzbot+fd2bd7df88c606eea4ef@syzkaller.appspotmail.com
      Signed-off-by: default avatarPhong Tran <tranmanphong@gmail.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20190724020601.15257-1-tranmanphong@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      53955976
    • Arnd Bergmann's avatar
      locking/lockdep: Hide unused 'class' variable · a0e02638
      Arnd Bergmann authored
      [ Upstream commit 68037aa7 ]
      
      The usage is now hidden in an #ifdef, so we need to move
      the variable itself in there as well to avoid this warning:
      
        kernel/locking/lockdep_proc.c:203:21: error: unused variable 'class' [-Werror,-Wunused-variable]
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Bart Van Assche <bvanassche@acm.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Qian Cai <cai@lca.pw>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Waiman Long <longman@redhat.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yuyang Du <duyuyang@gmail.com>
      Cc: frederic@kernel.org
      Fixes: 68d41d8c ("locking/lockdep: Fix lock used or unused stats error")
      Link: https://lkml.kernel.org/r/20190715092809.736834-1-arnd@arndb.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a0e02638
    • Yuyang Du's avatar
      locking/lockdep: Fix lock used or unused stats error · ccaa280d
      Yuyang Du authored
      [ Upstream commit 68d41d8c ]
      
      The stats variable nr_unused_locks is incremented every time a new lock
      class is register and decremented when the lock is first used in
      __lock_acquire(). And after all, it is shown and checked in lockdep_stats.
      
      However, under configurations that either CONFIG_TRACE_IRQFLAGS or
      CONFIG_PROVE_LOCKING is not defined:
      
      The commit:
      
        09180651 ("locking/lockdep: Consolidate lock usage bit initialization")
      
      missed marking the LOCK_USED flag at IRQ usage initialization because
      as mark_usage() is not called. And the commit:
      
        886532ae ("locking/lockdep: Move mark_lock() inside CONFIG_TRACE_IRQFLAGS && CONFIG_PROVE_LOCKING")
      
      further made mark_lock() not defined such that the LOCK_USED cannot be
      marked at all when the lock is first acquired.
      
      As a result, we fix this by not showing and checking the stats under such
      configurations for lockdep_stats.
      Reported-by: default avatarQian Cai <cai@lca.pw>
      Signed-off-by: default avatarYuyang Du <duyuyang@gmail.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: arnd@arndb.de
      Cc: frederic@kernel.org
      Link: https://lkml.kernel.org/r/20190709101522.9117-1-duyuyang@gmail.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ccaa280d
    • Jean-Philippe Brucker's avatar
      mm/mmu_notifier: use hlist_add_head_rcu() · 484354b2
      Jean-Philippe Brucker authored
      [ Upstream commit 543bdb2d ]
      
      Make mmu_notifier_register() safer by issuing a memory barrier before
      registering a new notifier.  This fixes a theoretical bug on weakly
      ordered CPUs.  For example, take this simplified use of notifiers by a
      driver:
      
      	my_struct->mn.ops = &my_ops; /* (1) */
      	mmu_notifier_register(&my_struct->mn, mm)
      		...
      		hlist_add_head(&mn->hlist, &mm->mmu_notifiers); /* (2) */
      		...
      
      Once mmu_notifier_register() releases the mm locks, another thread can
      invalidate a range:
      
      	mmu_notifier_invalidate_range()
      		...
      		hlist_for_each_entry_rcu(mn, &mm->mmu_notifiers, hlist) {
      			if (mn->ops->invalidate_range)
      
      The read side relies on the data dependency between mn and ops to ensure
      that the pointer is properly initialized.  But the write side doesn't have
      any dependency between (1) and (2), so they could be reordered and the
      readers could dereference an invalid mn->ops.  mmu_notifier_register()
      does take all the mm locks before adding to the hlist, but those have
      acquire semantics which isn't sufficient.
      
      By calling hlist_add_head_rcu() instead of hlist_add_head() we update the
      hlist using a store-release, ensuring that readers see prior
      initialization of my_struct.  This situation is better illustated by
      litmus test MP+onceassign+derefonce.
      
      Link: http://lkml.kernel.org/r/20190502133532.24981-1-jean-philippe.brucker@arm.com
      Fixes: cddb8a5c ("mmu-notifiers: core")
      Signed-off-by: default avatarJean-Philippe Brucker <jean-philippe.brucker@arm.com>
      Cc: Jérôme Glisse <jglisse@redhat.com>
      Cc: Michal Hocko <mhocko@suse.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      484354b2
    • Christoph Hellwig's avatar
      9p: pass the correct prototype to read_cache_page · 42297534
      Christoph Hellwig authored
      [ Upstream commit f053cbd4 ]
      
      Fix the callback 9p passes to read_cache_page to actually have the
      proper type expected.  Casting around function pointers can easily
      hide typing bugs, and defeats control flow protection.
      
      Link: http://lkml.kernel.org/r/20190520055731.24538-5-hch@lst.deSigned-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Sami Tolvanen <samitolvanen@google.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      42297534
    • Dmitry Vyukov's avatar
      mm/kmemleak.c: fix check for softirq context · 478cf2d4
      Dmitry Vyukov authored
      [ Upstream commit 6ef90569 ]
      
      in_softirq() is a wrong predicate to check if we are in a softirq
      context.  It also returns true if we have BH disabled, so objects are
      falsely stamped with "softirq" comm.  The correct predicate is
      in_serving_softirq().
      
      If user does cat from /sys/kernel/debug/kmemleak previously they would
      see this, which is clearly wrong, this is system call context (see the
      comm):
      
      unreferenced object 0xffff88805bd661c0 (size 64):
        comm "softirq", pid 0, jiffies 4294942959 (age 12.400s)
        hex dump (first 32 bytes):
          00 00 00 00 00 00 00 00 ff ff ff ff 00 00 00 00  ................
          00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00  ................
        backtrace:
          [<0000000007dcb30c>] kmemleak_alloc_recursive include/linux/kmemleak.h:55 [inline]
          [<0000000007dcb30c>] slab_post_alloc_hook mm/slab.h:439 [inline]
          [<0000000007dcb30c>] slab_alloc mm/slab.c:3326 [inline]
          [<0000000007dcb30c>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
          [<00000000969722b7>] kmalloc include/linux/slab.h:547 [inline]
          [<00000000969722b7>] kzalloc include/linux/slab.h:742 [inline]
          [<00000000969722b7>] ip_mc_add1_src net/ipv4/igmp.c:1961 [inline]
          [<00000000969722b7>] ip_mc_add_src+0x36b/0x400 net/ipv4/igmp.c:2085
          [<00000000a4134b5f>] ip_mc_msfilter+0x22d/0x310 net/ipv4/igmp.c:2475
          [<00000000d20248ad>] do_ip_setsockopt.isra.0+0x19fe/0x1c00 net/ipv4/ip_sockglue.c:957
          [<000000003d367be7>] ip_setsockopt+0x3b/0xb0 net/ipv4/ip_sockglue.c:1246
          [<000000003c7c76af>] udp_setsockopt+0x4e/0x90 net/ipv4/udp.c:2616
          [<000000000c1aeb23>] sock_common_setsockopt+0x3e/0x50 net/core/sock.c:3130
          [<000000000157b92b>] __sys_setsockopt+0x9e/0x120 net/socket.c:2078
          [<00000000a9f3d058>] __do_sys_setsockopt net/socket.c:2089 [inline]
          [<00000000a9f3d058>] __se_sys_setsockopt net/socket.c:2086 [inline]
          [<00000000a9f3d058>] __x64_sys_setsockopt+0x26/0x30 net/socket.c:2086
          [<000000001b8da885>] do_syscall_64+0x7c/0x1a0 arch/x86/entry/common.c:301
          [<00000000ba770c62>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      now they will see this:
      
      unreferenced object 0xffff88805413c800 (size 64):
        comm "syz-executor.4", pid 8960, jiffies 4294994003 (age 14.350s)
        hex dump (first 32 bytes):
          00 7a 8a 57 80 88 ff ff e0 00 00 01 00 00 00 00  .z.W............
          00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00  ................
        backtrace:
          [<00000000c5d3be64>] kmemleak_alloc_recursive include/linux/kmemleak.h:55 [inline]
          [<00000000c5d3be64>] slab_post_alloc_hook mm/slab.h:439 [inline]
          [<00000000c5d3be64>] slab_alloc mm/slab.c:3326 [inline]
          [<00000000c5d3be64>] kmem_cache_alloc_trace+0x13d/0x280 mm/slab.c:3553
          [<0000000023865be2>] kmalloc include/linux/slab.h:547 [inline]
          [<0000000023865be2>] kzalloc include/linux/slab.h:742 [inline]
          [<0000000023865be2>] ip_mc_add1_src net/ipv4/igmp.c:1961 [inline]
          [<0000000023865be2>] ip_mc_add_src+0x36b/0x400 net/ipv4/igmp.c:2085
          [<000000003029a9d4>] ip_mc_msfilter+0x22d/0x310 net/ipv4/igmp.c:2475
          [<00000000ccd0a87c>] do_ip_setsockopt.isra.0+0x19fe/0x1c00 net/ipv4/ip_sockglue.c:957
          [<00000000a85a3785>] ip_setsockopt+0x3b/0xb0 net/ipv4/ip_sockglue.c:1246
          [<00000000ec13c18d>] udp_setsockopt+0x4e/0x90 net/ipv4/udp.c:2616
          [<0000000052d748e3>] sock_common_setsockopt+0x3e/0x50 net/core/sock.c:3130
          [<00000000512f1014>] __sys_setsockopt+0x9e/0x120 net/socket.c:2078
          [<00000000181758bc>] __do_sys_setsockopt net/socket.c:2089 [inline]
          [<00000000181758bc>] __se_sys_setsockopt net/socket.c:2086 [inline]
          [<00000000181758bc>] __x64_sys_setsockopt+0x26/0x30 net/socket.c:2086
          [<00000000d4b73623>] do_syscall_64+0x7c/0x1a0 arch/x86/entry/common.c:301
          [<00000000c1098bec>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Link: http://lkml.kernel.org/r/20190517171507.96046-1-dvyukov@gmail.comSigned-off-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      478cf2d4
    • Sam Ravnborg's avatar
      sh: prevent warnings when using iounmap · 8b593377
      Sam Ravnborg authored
      [ Upstream commit 733f0025 ]
      
      When building drm/exynos for sh, as part of an allmodconfig build, the
      following warning triggered:
      
        exynos7_drm_decon.c: In function `decon_remove':
        exynos7_drm_decon.c:769:24: warning: unused variable `ctx'
          struct decon_context *ctx = dev_get_drvdata(&pdev->dev);
      
      The ctx variable is only used as argument to iounmap().
      
      In sh - allmodconfig CONFIG_MMU is not defined
      so it ended up in:
      
      \#define __iounmap(addr)	do { } while (0)
      \#define iounmap		__iounmap
      
      Fix the warning by introducing a static inline function for iounmap.
      
      This is similar to several other architectures.
      
      Link: http://lkml.kernel.org/r/20190622114208.24427-1-sam@ravnborg.orgSigned-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Inki Dae <inki.dae@samsung.com>
      Cc: Krzysztof Kozlowski <krzk@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8b593377
    • Oliver O'Halloran's avatar
      powerpc/eeh: Handle hugepages in ioremap space · bce3e3e8
      Oliver O'Halloran authored
      [ Upstream commit 33439620 ]
      
      In commit 4a7b06c157a2 ("powerpc/eeh: Handle hugepages in ioremap
      space") support for using hugepages in the vmalloc and ioremap areas was
      enabled for radix. Unfortunately this broke EEH MMIO error checking.
      
      Detection works by inserting a hook which checks the results of the
      ioreadXX() set of functions.  When a read returns a 0xFFs response we
      need to check for an error which we do by mapping the (virtual) MMIO
      address back to a physical address, then mapping physical address to a
      PCI device via an interval tree.
      
      When translating virt -> phys we currently assume the ioremap space is
      only populated by PAGE_SIZE mappings. If a hugepage mapping is found we
      emit a WARN_ON(), but otherwise handles the check as though a normal
      page was found. In pathalogical cases such as copying a buffer
      containing a lot of 0xFFs from BAR memory this can result in the system
      not booting because it's too busy printing WARN_ON()s.
      
      There's no real reason to assume huge pages can't be present and we're
      prefectly capable of handling them, so do that.
      
      Fixes: 4a7b06c157a2 ("powerpc/eeh: Handle hugepages in ioremap space")
      Reported-by: default avatarSachin Sant <sachinp@linux.vnet.ibm.com>
      Signed-off-by: default avatarOliver O'Halloran <oohall@gmail.com>
      Tested-by: default avatarSachin Sant <sachinp@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20190710150517.27114-1-oohall@gmail.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      bce3e3e8
    • morten petersen's avatar
      mailbox: handle failed named mailbox channel request · 450233af
      morten petersen authored
      [ Upstream commit 25777e57 ]
      
      Previously, if mbox_request_channel_byname was used with a name
      which did not exist in the "mbox-names" property of a mailbox
      client, the mailbox corresponding to the last entry in the
      "mbox-names" list would be incorrectly selected.
      With this patch, -EINVAL is returned if the named mailbox is
      not found.
      Signed-off-by: default avatarMorten Borup Petersen <morten_bp@live.dk>
      Signed-off-by: default avatarJassi Brar <jaswinder.singh@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      450233af
    • Ocean Chen's avatar
      f2fs: avoid out-of-range memory access · dd1fc2ce
      Ocean Chen authored
      [ Upstream commit 56f3ce67 ]
      
      blkoff_off might over 512 due to fs corrupt or security
      vulnerability. That should be checked before being using.
      
      Use ENTRIES_IN_SUM to protect invalid value in cur_data_blkoff.
      Signed-off-by: default avatarOcean Chen <oceanchen@google.com>
      Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      dd1fc2ce
    • Masahiro Yamada's avatar
      powerpc/boot: add {get, put}_unaligned_be32 to xz_config.h · 34dd8fb9
      Masahiro Yamada authored
      [ Upstream commit 9e005b76 ]
      
      The next commit will make the way of passing CONFIG options more robust.
      Unfortunately, it would uncover another hidden issue; without this
      commit, skiroot_defconfig would be broken like this:
      
      |   WRAP    arch/powerpc/boot/zImage.pseries
      | arch/powerpc/boot/wrapper.a(decompress.o): In function `bcj_powerpc.isra.10':
      | decompress.c:(.text+0x720): undefined reference to `get_unaligned_be32'
      | decompress.c:(.text+0x7a8): undefined reference to `put_unaligned_be32'
      | make[1]: *** [arch/powerpc/boot/Makefile;383: arch/powerpc/boot/zImage.pseries] Error 1
      | make: *** [arch/powerpc/Makefile;295: zImage] Error 2
      
      skiroot_defconfig is the only defconfig that enables CONFIG_KERNEL_XZ
      for ppc, which has never been correctly built before.
      
      I figured out the root cause in lib/decompress_unxz.c:
      
      | #ifdef CONFIG_PPC
      | #      define XZ_DEC_POWERPC
      | #endif
      
      CONFIG_PPC is undefined here in the ppc bootwrapper because autoconf.h
      is not included except by arch/powerpc/boot/serial.c
      
      XZ_DEC_POWERPC is not defined, therefore, bcj_powerpc() is not compiled
      for the bootwrapper.
      
      With the next commit passing CONFIG_PPC correctly, we would realize that
      {get,put}_unaligned_be32 was missing.
      
      Unlike the other decompressors, the ppc bootwrapper duplicates all the
      necessary helpers in arch/powerpc/boot/.
      
      The other architectures define __KERNEL__ and pull in helpers for
      building the decompressors.
      
      If ppc bootwrapper had defined __KERNEL__, lib/xz/xz_private.h would
      have included <asm/unaligned.h>:
      
      | #ifdef __KERNEL__
      | #       include <linux/xz.h>
      | #       include <linux/kernel.h>
      | #       include <asm/unaligned.h>
      
      However, doing so would cause tons of definition conflicts since the
      bootwrapper has duplicated everything.
      
      I just added copies of {get,put}_unaligned_be32, following the
      bootwrapper coding convention.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20190705100144.28785-1-yamada.masahiro@socionext.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      34dd8fb9
    • Konstantin Taranov's avatar
      RDMA/rxe: Fill in wc byte_len with IB_WC_RECV_RDMA_WITH_IMM · 8baa8d68
      Konstantin Taranov authored
      [ Upstream commit bdce1290 ]
      
      Calculate the correct byte_len on the receiving side when a work
      completion is generated with IB_WC_RECV_RDMA_WITH_IMM opcode.
      
      According to the IBA byte_len must indicate the number of written bytes,
      whereas it was always equal to zero for the IB_WC_RECV_RDMA_WITH_IMM
      opcode, even though data was transferred.
      
      Fixes: 8700e3e7 ("Soft RoCE driver")
      Signed-off-by: default avatarKonstantin Taranov <konstantin.taranov@inf.ethz.ch>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8baa8d68