Skip to content
  1. Mar 20, 2020
    • Eric Dumazet's avatar
      gre: fix uninit-value in __iptunnel_pull_header · 31b4b975
      Eric Dumazet authored
      [ Upstream commit 17c25caf ]
      
      syzbot found an interesting case of the kernel reading
      an uninit-value [1]
      
      Problem is in the handling of ETH_P_WCCP in gre_parse_header()
      
      We look at the byte following GRE options to eventually decide
      if the options are four bytes longer.
      
      Use skb_header_pointer() to not pull bytes if we found
      that no more bytes were needed.
      
      All callers of gre_parse_header() are properly using pskb_may_pull()
      anyway before proceeding to next header.
      
      [1]
      BUG: KMSAN: uninit-value in pskb_may_pull include/linux/skbuff.h:2303 [inline]
      BUG: KMSAN: uninit-value in __iptunnel_pull_header+0x30c/0xbd0 net/ipv4/ip_tunnel_core.c:94
      CPU: 1 PID: 11784 Comm: syz-executor940 Not tainted 5.6.0-rc2-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       __dump_stack lib/dump_stack.c:77 [inline]
       dump_stack+0x1c9/0x220 lib/dump_stack.c:118
       kmsan_report+0xf7/0x1e0 mm/kmsan/kmsan_report.c:118
       __msan_warning+0x58/0xa0 mm/kmsan/kmsan_instr.c:215
       pskb_may_pull include/linux/skbuff.h:2303 [inline]
       __iptunnel_pull_header+0x30c/0xbd0 net/ipv4/ip_tunnel_core.c:94
       iptunnel_pull_header include/net/ip_tunnels.h:411 [inline]
       gre_rcv+0x15e/0x19c0 net/ipv6/ip6_gre.c:606
       ip6_protocol_deliver_rcu+0x181b/0x22c0 net/ipv6/ip6_input.c:432
       ip6_input_finish net/ipv6/ip6_input.c:473 [inline]
       NF_HOOK include/linux/netfilter.h:307 [inline]
       ip6_input net/ipv6/ip6_input.c:482 [inline]
       ip6_mc_input+0xdf2/0x1460 net/ipv6/ip6_input.c:576
       dst_input include/net/dst.h:442 [inline]
       ip6_rcv_finish net/ipv6/ip6_input.c:76 [inline]
       NF_HOOK include/linux/netfilter.h:307 [inline]
       ipv6_rcv+0x683/0x710 net/ipv6/ip6_input.c:306
       __netif_receive_skb_one_core net/core/dev.c:5198 [inline]
       __netif_receive_skb net/core/dev.c:5312 [inline]
       netif_receive_skb_internal net/core/dev.c:5402 [inline]
       netif_receive_skb+0x66b/0xf20 net/core/dev.c:5461
       tun_rx_batched include/linux/skbuff.h:4321 [inline]
       tun_get_user+0x6aef/0x6f60 drivers/net/tun.c:1997
       tun_chr_write_iter+0x1f2/0x360 drivers/net/tun.c:2026
       call_write_iter include/linux/fs.h:1901 [inline]
       new_sync_write fs/read_write.c:483 [inline]
       __vfs_write+0xa5a/0xca0 fs/read_write.c:496
       vfs_write+0x44a/0x8f0 fs/read_write.c:558
       ksys_write+0x267/0x450 fs/read_write.c:611
       __do_sys_write fs/read_write.c:623 [inline]
       __se_sys_write fs/read_write.c:620 [inline]
       __ia32_sys_write+0xdb/0x120 fs/read_write.c:620
       do_syscall_32_irqs_on arch/x86/entry/common.c:339 [inline]
       do_fast_syscall_32+0x3c7/0x6e0 arch/x86/entry/common.c:410
       entry_SYSENTER_compat+0x68/0x77 arch/x86/entry/entry_64_compat.S:139
      RIP: 0023:0xf7f62d99
      Code: 90 e8 0b 00 00 00 f3 90 0f ae e8 eb f9 8d 74 26 00 89 3c 24 c3 90 90 90 90 90 90 90 90 90 90 90 90 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 eb 0d 90 90 90 90 90 90 90 90 90 90 90 90
      RSP: 002b:00000000fffedb2c EFLAGS: 00000217 ORIG_RAX: 0000000000000004
      RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000020002580
      RDX: 0000000000000fca RSI: 0000000000000036 RDI: 0000000000000004
      RBP: 0000000000008914 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
      R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
      
      Uninit was created at:
       kmsan_save_stack_with_flags mm/kmsan/kmsan.c:144 [inline]
       kmsan_internal_poison_shadow+0x66/0xd0 mm/kmsan/kmsan.c:127
       kmsan_slab_alloc+0x8a/0xe0 mm/kmsan/kmsan_hooks.c:82
       slab_alloc_node mm/slub.c:2793 [inline]
       __kmalloc_node_track_caller+0xb40/0x1200 mm/slub.c:4401
       __kmalloc_reserve net/core/skbuff.c:142 [inline]
       __alloc_skb+0x2fd/0xac0 net/core/skbuff.c:210
       alloc_skb include/linux/skbuff.h:1051 [inline]
       alloc_skb_with_frags+0x18c/0xa70 net/core/skbuff.c:5766
       sock_alloc_send_pskb+0xada/0xc60 net/core/sock.c:2242
       tun_alloc_skb drivers/net/tun.c:1529 [inline]
       tun_get_user+0x10ae/0x6f60 drivers/net/tun.c:1843
       tun_chr_write_iter+0x1f2/0x360 drivers/net/tun.c:2026
       call_write_iter include/linux/fs.h:1901 [inline]
       new_sync_write fs/read_write.c:483 [inline]
       __vfs_write+0xa5a/0xca0 fs/read_write.c:496
       vfs_write+0x44a/0x8f0 fs/read_write.c:558
       ksys_write+0x267/0x450 fs/read_write.c:611
       __do_sys_write fs/read_write.c:623 [inline]
       __se_sys_write fs/read_write.c:620 [inline]
       __ia32_sys_write+0xdb/0x120 fs/read_write.c:620
       do_syscall_32_irqs_on arch/x86/entry/common.c:339 [inline]
       do_fast_syscall_32+0x3c7/0x6e0 arch/x86/entry/common.c:410
       entry_SYSENTER_compat+0x68/0x77 arch/x86/entry/entry_64_compat.S:139
      
      Fixes: 95f5c64c ("gre: Move utility functions to common headers")
      Fixes: c5441932
      
       ("GRE: Refactor GRE tunneling code.")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      31b4b975
    • Dmitry Yakunin's avatar
      cgroup, netclassid: periodically release file_lock on classid updating · 81ab17d7
      Dmitry Yakunin authored
      [ Upstream commit 018d26fc
      
       ]
      
      In our production environment we have faced with problem that updating
      classid in cgroup with heavy tasks cause long freeze of the file tables
      in this tasks. By heavy tasks we understand tasks with many threads and
      opened sockets (e.g. balancers). This freeze leads to an increase number
      of client timeouts.
      
      This patch implements following logic to fix this issue:
      аfter iterating 1000 file descriptors file table lock will be released
      thus providing a time gap for socket creation/deletion.
      
      Now update is non atomic and socket may be skipped using calls:
      
      dup2(oldfd, newfd);
      close(oldfd);
      
      But this case is not typical. Moreover before this patch skip is possible
      too by hiding socket fd in unix socket buffer.
      
      New sockets will be allocated with updated classid because cgroup state
      is updated before start of the file descriptors iteration.
      
      So in common cases this patch has no side effects.
      
      Signed-off-by: default avatarDmitry Yakunin <zeil@yandex-team.ru>
      Reviewed-by: default avatarKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      81ab17d7
    • Florian Fainelli's avatar
      net: phy: Avoid multiple suspends · 139fe350
      Florian Fainelli authored
      commit 503ba7c6 upstream.
      
      It is currently possible for a PHY device to be suspended as part of a
      network device driver's suspend call while it is still being attached to
      that net_device, either via phy_suspend() or implicitly via phy_stop().
      
      Later on, when the MDIO bus controller get suspended, we would attempt
      to suspend again the PHY because it is still attached to a network
      device.
      
      This is both a waste of time and creates an opportunity for improper
      clock/power management bugs to creep in.
      
      Fixes: 803dd9c7
      
       ("net: phy: avoid suspending twice a PHY")
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      139fe350
    • David S. Miller's avatar
      phy: Revert toggling reset changes. · ffee24cf
      David S. Miller authored
      commit 7b566f70 upstream.
      
      This reverts:
      
      ef1b5bf5 ("net: phy: Fix not to call phy_resume() if PHY is not attached")
      8c85f4b8
      
       ("net: phy: micrel: add toggling phy reset if PHY is not  attached")
      
      Andrew Lunn informs me that there are alternative efforts
      underway to fix this more properly.
      
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      [just take the ef1b5bf5
      
       revert - gregkh]
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ffee24cf
  2. Mar 12, 2020
    • Greg Kroah-Hartman's avatar
      Linux 4.14.173 · 12cd844a
      Greg Kroah-Hartman authored
      v4.14.173
      12cd844a
    • Dragos Tarcatu's avatar
      ASoC: topology: Fix memleak in soc_tplg_manifest_load() · 30238068
      Dragos Tarcatu authored
      commit 242c46c0 upstream.
      
      In case of ABI version mismatch, _manifest needs to be freed as
      it is just a copy of the original topology manifest. However, if
      a driver manifest handler is defined, that would get executed and
      the cleanup is never reached. Fix that by getting the return status
      of manifest() instead of returning directly.
      
      Fixes: 583958fa
      
       ("ASoC: topology: Make manifest backward compatible from ABI v4")
      Signed-off-by: default avatarDragos Tarcatu <dragos_tarcatu@mentor.com>
      Link: https://lore.kernel.org/r/20200207185325.22320-3-dragos_tarcatu@mentor.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      
      30238068
    • Mathias Nyman's avatar
      xhci: handle port status events for removed USB3 hcd · df4bf4dc
      Mathias Nyman authored
      commit 1245374e
      
       upstream.
      
      At xhci removal the USB3 hcd (shared_hcd) is removed before the primary
      USB2 hcd. Interrupts for port status changes may still occur for USB3
      ports after the shared_hcd is freed, causing  NULL pointer dereference.
      
      Check if xhci->shared_hcd is still valid before handing USB3 port events
      
      Cc: <stable@vger.kernel.org>
      Reported-by: default avatarPeter Chen <peter.chen@nxp.com>
      Tested-by: default avatarJack Pham <jackp@codeaurora.org>
      Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Cc: Macpaul Lin <macpaul.lin@mediatek.com>
      [redone for 4.14.y based on Mathias's comments]
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      df4bf4dc
    • Mikulas Patocka's avatar
      dm integrity: fix a deadlock due to offloading to an incorrect workqueue · ec6ddb1a
      Mikulas Patocka authored
      commit 53770f0e upstream.
      
      If we need to perform synchronous I/O in dm_integrity_map_continue(),
      we must make sure that we are not in the map function - in order to
      avoid the deadlock due to bio queuing in generic_make_request. To
      avoid the deadlock, we offload the request to metadata_wq.
      
      However, metadata_wq also processes metadata updates for write requests.
      If there are too many requests that get offloaded to metadata_wq at the
      beginning of dm_integrity_map_continue, the workqueue metadata_wq
      becomes clogged and the system is incapable of processing any metadata
      updates.
      
      This causes a deadlock because all the requests that need to do metadata
      updates wait for metadata_wq to proceed and metadata_wq waits inside
      wait_and_add_new_range until some existing request releases its range
      lock (which doesn't happen because the range lock is released after
      metadata update).
      
      In order to fix the deadlock, we create a new workqueue offload_wq and
      offload requests to it - so that processing of offload_wq is independent
      from processing of metadata_wq.
      
      Fixes: 7eada909
      
       ("dm: add integrity target")
      Cc: stable@vger.kernel.org # v4.12+
      Reported-by: default avatarHeinz Mauelshagen <heinzm@redhat.com>
      Tested-by: default avatarHeinz Mauelshagen <heinzm@redhat.com>
      Signed-off-by: default avatarHeinz Mauelshagen <heinzm@redhat.com>
      Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ec6ddb1a
    • Desnes A. Nunes do Rosario's avatar
      powerpc: fix hardware PMU exception bug on PowerVM compatibility mode systems · d7893444
      Desnes A. Nunes do Rosario authored
      commit fc37a163 upstream.
      
      PowerVM systems running compatibility mode on a few Power8 revisions are
      still vulnerable to the hardware defect that loses PMU exceptions arriving
      prior to a context switch.
      
      The software fix for this issue is enabled through the CPU_FTR_PMAO_BUG
      cpu_feature bit, nevertheless this bit also needs to be set for PowerVM
      compatibility mode systems.
      
      Fixes: 68f2f0d4
      
       ("powerpc: Add a cpu feature CPU_FTR_PMAO_BUG")
      Signed-off-by: default avatarDesnes A. Nunes do Rosario <desnesn@linux.ibm.com>
      Reviewed-by: default avatarLeonardo Bras <leonardo@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20200227134715.9715-1-desnesn@linux.ibm.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d7893444
    • Dan Carpenter's avatar
      dmaengine: coh901318: Fix a double lock bug in dma_tc_handle() · 956b5b1c
      Dan Carpenter authored
      commit 36d5d220 upstream.
      
      The caller is already holding the lock so this will deadlock.
      
      Fixes: 0b58828c
      
       ("DMAENGINE: COH 901 318 remove irq counting")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Link: https://lore.kernel.org/r/20200217144050.3i4ymbytogod4ijn@kili.mountain
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      956b5b1c
    • Dan Carpenter's avatar
      hwmon: (adt7462) Fix an error return in ADT7462_REG_VOLT() · 5c5cdae8
      Dan Carpenter authored
      commit 44f2f882 upstream.
      
      This is only called from adt7462_update_device().  The caller expects it
      to return zero on error.  I fixed a similar issue earlier in commit
      a4bf06d5 ("hwmon: (adt7462) ADT7462_REG_VOLT_MAX() should return 0")
      but I missed this one.
      
      Fixes: c0b4e3ab
      
       ("adt7462: new hwmon driver")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
      Link: https://lore.kernel.org/r/20200303101608.kqjwfcazu2ylhi2a@kili.mountain
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5c5cdae8
    • Ahmad Fatoum's avatar
      ARM: imx: build v7_cpu_resume() unconditionally · 09192ee9
      Ahmad Fatoum authored
      commit 512a928a upstream.
      
      This function is not only needed by the platform suspend code, but is also
      reused as the CPU resume function when the ARM cores can be powered down
      completely in deep idle, which is the case on i.MX6SX and i.MX6UL(L).
      
      Providing the static inline stub whenever CONFIG_SUSPEND is disabled means
      that those platforms will hang on resume from cpuidle if suspend is disabled.
      
      So there are two problems:
      
        - The static inline stub masks the linker error
        - The function is not available where needed
      
      Fix both by just building the function unconditionally, when
      CONFIG_SOC_IMX6 is enabled. The actual code is three instructions long,
      so it's arguably ok to just leave it in for all i.MX6 kernel configurations.
      
      Fixes: 05136f08
      
       ("ARM: imx: support arm power off in cpuidle for i.mx6sx")
      Signed-off-by: default avatarLucas Stach <l.stach@pengutronix.de>
      Signed-off-by: default avatarAhmad Fatoum <a.fatoum@pengutronix.de>
      Signed-off-by: default avatarRouven Czerwinski <r.czerwinski@pengutronix.de>
      Signed-off-by: default avatarShawn Guo <shawnguo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      09192ee9
    • Dennis Dalessandro's avatar
      IB/hfi1, qib: Ensure RCU is locked when accessing list · de374e15
      Dennis Dalessandro authored
      commit 817a68a6 upstream.
      
      The packet handling function, specifically the iteration of the qp list
      for mad packet processing misses locking RCU before running through the
      list. Not only is this incorrect, but the list_for_each_entry_rcu() call
      can not be called with a conditional check for lock dependency. Remedy
      this by invoking the rcu lock and unlock around the critical section.
      
      This brings MAD packet processing in line with what is done for non-MAD
      packets.
      
      Fixes: 77241056
      
       ("IB/hfi1: add driver files")
      Link: https://lore.kernel.org/r/20200225195445.140896.41873.stgit@awfm-01.aw.intel.com
      Reviewed-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
      Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      de374e15
    • Jason Gunthorpe's avatar
      RMDA/cm: Fix missing ib_cm_destroy_id() in ib_cm_insert_listen() · 3c1099c8
      Jason Gunthorpe authored
      commit c14dfddb upstream.
      
      The algorithm pre-allocates a cm_id since allocation cannot be done while
      holding the cm.lock spinlock, however it doesn't free it on one error
      path, leading to a memory leak.
      
      Fixes: 067b171b
      
       ("IB/cm: Share listening CM IDs")
      Link: https://lore.kernel.org/r/20200221152023.GA8680@ziepe.ca
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3c1099c8
    • Bernard Metzler's avatar
      RDMA/iwcm: Fix iwcm work deallocation · 8457a776
      Bernard Metzler authored
      commit 810dbc69 upstream.
      
      The dealloc_work_entries() function must update the work_free_list pointer
      while freeing its entries, since potentially called again on same list. A
      second iteration of the work list caused system crash. This happens, if
      work allocation fails during cma_iw_listen() and free_cm_id() tries to
      free the list again during cleanup.
      
      Fixes: 922a8e9f
      
       ("RDMA: iWARP Connection Manager.")
      Link: https://lore.kernel.org/r/20200302181614.17042-1-bmt@zurich.ibm.com
      Reported-by: default avatar <syzbot+cb0c054eabfba4342146@syzkaller.appspotmail.com>
      Signed-off-by: default avatarBernard Metzler <bmt@zurich.ibm.com>
      Reviewed-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8457a776
    • Charles Keepax's avatar
      ASoC: dapm: Correct DAPM handling of active widgets during shutdown · 9b2c4c1b
      Charles Keepax authored
      commit 9b319308 upstream.
      
      commit c2caa4da ("ASoC: Fix widget powerdown on shutdown") added a
      set of the power state during snd_soc_dapm_shutdown to ensure the
      widgets powered off. However, when commit 39eb5fd1
      ("ASoC: dapm: Delay w->power update until the changes are written")
      added the new_power member of the widget structure, to differentiate
      between the current power state and the target power state, it did not
      update the shutdown to use the new_power member.
      
      As new_power has not updated it will be left in the state set by the
      last DAPM sequence, ie. 1 for active widgets. So as the DAPM sequence
      for the shutdown proceeds it will turn the widgets on (despite them
      already being on) rather than turning them off.
      
      Fixes: 39eb5fd1
      
       ("ASoC: dapm: Delay w->power update until the changes are written")
      Signed-off-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
      Link: https://lore.kernel.org/r/20200228153145.21013-1-ckeepax@opensource.cirrus.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9b2c4c1b
    • Matthias Reichl's avatar
      ASoC: pcm512x: Fix unbalanced regulator enable call in probe error path · 5c17ed40
      Matthias Reichl authored
      commit ac0a6899 upstream.
      
      When we get a clock error during probe we have to call
      regulator_bulk_disable before bailing out, otherwise we trigger
      a warning in regulator_put.
      
      Fix this by using "goto err" like in the error cases above.
      
      Fixes: 5a3af129
      
       ("ASoC: pcm512x: Add PCM512x driver")
      Signed-off-by: default avatarMatthias Reichl <hias@horus.com>
      Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      Link: https://lore.kernel.org/r/20200220202956.29233-1-hias@horus.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5c17ed40
    • Takashi Iwai's avatar
      ASoC: pcm: Fix possible buffer overflow in dpcm state sysfs output · 6dfcfe0c
      Takashi Iwai authored
      commit 6c89ffea upstream.
      
      dpcm_show_state() invokes multiple snprintf() calls to concatenate
      formatted strings on the fixed size buffer.  The usage of snprintf()
      is supposed for avoiding the buffer overflow, but it doesn't work as
      expected because snprintf() doesn't return the actual output size but
      the size to be written.
      
      Fix this bug by replacing all snprintf() calls with scnprintf()
      calls.
      
      Fixes: f86dcef8
      
       ("ASoC: dpcm: Add debugFS support for DPCM")
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Acked-by: default avatarCezary Rojewski <cezary.rojewski@intel.com>
      Link: https://lore.kernel.org/r/20200218111737.14193-4-tiwai@suse.de
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6dfcfe0c
    • Takashi Iwai's avatar
      ASoC: intel: skl: Fix possible buffer overflow in debug outputs · 7c4e0801
      Takashi Iwai authored
      commit 549cd0ba upstream.
      
      The debugfs output of intel skl driver writes strings with multiple
      snprintf() calls with the fixed size.  This was supposed to avoid the
      buffer overflow but actually it still would, because snprintf()
      returns the expected size to be output, not the actual output size.
      
      Fix it by replacing snprintf() calls with scnprintf().
      
      Fixes: d14700a0
      
       ("ASoC: Intel: Skylake: Debugfs facility to dump module config")
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Acked-by: default avatarCezary Rojewski <cezary.rojewski@intel.com>
      Link: https://lore.kernel.org/r/20200218111737.14193-3-tiwai@suse.de
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7c4e0801
    • Takashi Iwai's avatar
      ASoC: intel: skl: Fix pin debug prints · 543eafed
      Takashi Iwai authored
      commit 64bbacc5 upstream.
      
      skl_print_pins() loops over all given pins but it overwrites the text
      at the very same position while increasing the returned length.
      Fix this to show the all pin contents properly.
      
      Fixes: d14700a0
      
       ("ASoC: Intel: Skylake: Debugfs facility to dump module config")
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Acked-by: default avatarCezary Rojewski <cezary.rojewski@intel.com>
      Link: https://lore.kernel.org/r/20200218111737.14193-2-tiwai@suse.de
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      543eafed
    • Dragos Tarcatu's avatar
      ASoC: topology: Fix memleak in soc_tplg_link_elems_load() · c40c33a8
      Dragos Tarcatu authored
      commit 2b2d5c4d upstream.
      
      If soc_tplg_link_config() fails, _link needs to be freed in case of
      topology ABI version mismatch. However the current code is returning
      directly and ends up leaking memory in this case.
      This patch fixes that.
      
      Fixes: 593d9e52
      
       ("ASoC: topology: Add support to configure existing physical DAI links")
      Signed-off-by: default avatarDragos Tarcatu <dragos_tarcatu@mentor.com>
      Link: https://lore.kernel.org/r/20200207185325.22320-2-dragos_tarcatu@mentor.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c40c33a8
    • Vladimir Oltean's avatar
      ARM: dts: ls1021a: Restore MDIO compatible to gianfar · 77ed33b9
      Vladimir Oltean authored
      commit 7155c446 upstream.
      
      The difference between "fsl,etsec2-mdio" and "gianfar" has to do with
      the .get_tbipa function, which calculates the address of the TBIPA
      register automatically, if not explicitly specified. [ see
      drivers/net/ethernet/freescale/fsl_pq_mdio.c ]. On LS1021A, the TBIPA
      register is at offset 0x30 within the port register block, which is what
      the "gianfar" method of calculating addresses actually does.
      
      Luckily, the bad "compatible" is inconsequential for ls1021a.dtsi,
      because the TBIPA register is explicitly specified via the second "reg"
      (<0x0 0x2d10030 0x0 0x4>), so the "get_tbipa" function is dead code.
      Nonetheless it's good to restore it to its correct value.
      
      Background discussion:
      https://www.spinics.net/lists/stable/msg361156.html
      
      Fixes: c7861adb
      
       ("ARM: dts: ls1021: Fix SGMII PCS link remaining down after PHY disconnect")
      Reported-by: default avatarPavel Machek <pavel@denx.de>
      Signed-off-by: default avatarVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: default avatarShawn Guo <shawnguo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      77ed33b9
    • Mikulas Patocka's avatar
      dm cache: fix a crash due to incorrect work item cancelling · 165dc070
      Mikulas Patocka authored
      commit 7cdf6a0a upstream.
      
      The crash can be reproduced by running the lvm2 testsuite test
      lvconvert-thin-external-cache.sh for several minutes, e.g.:
        while :; do make check T=shell/lvconvert-thin-external-cache.sh; done
      
      The crash happens in this call chain:
      do_waker -> policy_tick -> smq_tick -> end_hotspot_period -> clear_bitset
      -> memset -> __memset -- which accesses an invalid pointer in the vmalloc
      area.
      
      The work entry on the workqueue is executed even after the bitmap was
      freed. The problem is that cancel_delayed_work doesn't wait for the
      running work item to finish, so the work item can continue running and
      re-submitting itself even after cache_postsuspend. In order to make sure
      that the work item won't be running, we must use cancel_delayed_work_sync.
      
      Also, change flush_workqueue to drain_workqueue, so that if some work item
      submits itself or another work item, we are properly waiting for both of
      them.
      
      Fixes: c6b4fcba
      
       ("dm: add cache target")
      Cc: stable@vger.kernel.org # v3.9
      Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      165dc070
    • Dmitry Osipenko's avatar
      dmaengine: tegra-apb: Prevent race conditions of tasklet vs free list · 3e4c735e
      Dmitry Osipenko authored
      commit c33ee130
      
       upstream.
      
      The interrupt handler puts a half-completed DMA descriptor on a free list
      and then schedules tasklet to process bottom half of the descriptor that
      executes client's callback, this creates possibility to pick up the busy
      descriptor from the free list. Thus, let's disallow descriptor's re-use
      until it is fully processed.
      
      Signed-off-by: default avatarDmitry Osipenko <digetx@gmail.com>
      Acked-by: default avatarJon Hunter <jonathanh@nvidia.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200209163356.6439-3-digetx@gmail.com
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3e4c735e
    • Dmitry Osipenko's avatar
      dmaengine: tegra-apb: Fix use-after-free · 04b31630
      Dmitry Osipenko authored
      commit 94788af4
      
       upstream.
      
      I was doing some experiments with I2C and noticed that Tegra APB DMA
      driver crashes sometime after I2C DMA transfer termination. The crash
      happens because tegra_dma_terminate_all() bails out immediately if pending
      list is empty, and thus, it doesn't release the half-completed descriptors
      which are getting re-used before ISR tasklet kicks-in.
      
       tegra-i2c 7000c400.i2c: DMA transfer timeout
       elants_i2c 0-0010: elants_i2c_irq: failed to read data: -110
       ------------[ cut here ]------------
       WARNING: CPU: 0 PID: 142 at lib/list_debug.c:45 __list_del_entry_valid+0x45/0xac
       list_del corruption, ddbaac44->next is LIST_POISON1 (00000100)
       Modules linked in:
       CPU: 0 PID: 142 Comm: kworker/0:2 Not tainted 5.5.0-rc2-next-20191220-00175-gc3605715758d-dirty #538
       Hardware name: NVIDIA Tegra SoC (Flattened Device Tree)
       Workqueue: events_freezable_power_ thermal_zone_device_check
       [<c010e5c5>] (unwind_backtrace) from [<c010a1c5>] (show_stack+0x11/0x14)
       [<c010a1c5>] (show_stack) from [<c0973925>] (dump_stack+0x85/0x94)
       [<c0973925>] (dump_stack) from [<c011f529>] (__warn+0xc1/0xc4)
       [<c011f529>] (__warn) from [<c011f7e9>] (warn_slowpath_fmt+0x61/0x78)
       [<c011f7e9>] (warn_slowpath_fmt) from [<c042497d>] (__list_del_entry_valid+0x45/0xac)
       [<c042497d>] (__list_del_entry_valid) from [<c047a87f>] (tegra_dma_tasklet+0x5b/0x154)
       [<c047a87f>] (tegra_dma_tasklet) from [<c0124799>] (tasklet_action_common.constprop.0+0x41/0x7c)
       [<c0124799>] (tasklet_action_common.constprop.0) from [<c01022ab>] (__do_softirq+0xd3/0x2a8)
       [<c01022ab>] (__do_softirq) from [<c0124683>] (irq_exit+0x7b/0x98)
       [<c0124683>] (irq_exit) from [<c0168c19>] (__handle_domain_irq+0x45/0x80)
       [<c0168c19>] (__handle_domain_irq) from [<c043e429>] (gic_handle_irq+0x45/0x7c)
       [<c043e429>] (gic_handle_irq) from [<c0101aa5>] (__irq_svc+0x65/0x94)
       Exception stack(0xde2ebb90 to 0xde2ebbd8)
      
      Signed-off-by: default avatarDmitry Osipenko <digetx@gmail.com>
      Acked-by: default avatarJon Hunter <jonathanh@nvidia.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200209163356.6439-2-digetx@gmail.com
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      04b31630
    • Sean Christopherson's avatar
      x86/pkeys: Manually set X86_FEATURE_OSPKE to preserve existing changes · a350eee1
      Sean Christopherson authored
      commit 735a6dd0 upstream.
      
      Explicitly set X86_FEATURE_OSPKE via set_cpu_cap() instead of calling
      get_cpu_cap() to pull the feature bit from CPUID after enabling CR4.PKE.
      Invoking get_cpu_cap() effectively wipes out any {set,clear}_cpu_cap()
      changes that were made between this_cpu->c_init() and setup_pku(), as
      all non-synthetic feature words are reinitialized from the CPU's CPUID
      values.
      
      Blasting away capability updates manifests most visibility when running
      on a VMX capable CPU, but with VMX disabled by BIOS.  To indicate that
      VMX is disabled, init_ia32_feat_ctl() clears X86_FEATURE_VMX, using
      clear_cpu_cap() instead of setup_clear_cpu_cap() so that KVM can report
      which CPU is misconfigured (KVM needs to probe every CPU anyways).
      Restoring X86_FEATURE_VMX from CPUID causes KVM to think VMX is enabled,
      ultimately leading to an unexpected #GP when KVM attempts to do VMXON.
      
      Arguably, init_ia32_feat_ctl() should use setup_clear_cpu_cap() and let
      KVM figure out a different way to report the misconfigured CPU, but VMX
      is not the only feature bit that is affected, i.e. there is precedent
      that tweaking feature bits via {set,clear}_cpu_cap() after ->c_init()
      is expected to work.  Most notably, x86_init_rdrand()'s clearing of
      X86_FEATURE_RDRAND when RDRAND malfunctions is also overwritten.
      
      Fixes: 06976945
      
       ("x86/mm/pkeys: Actually enable Memory Protection Keys in the CPU")
      Reported-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Signed-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Acked-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
      Tested-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/20200226231615.13664-1-sean.j.christopherson@intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a350eee1
    • Jiri Slaby's avatar
      vt: selection, push sel_lock up · a4719f6d
      Jiri Slaby authored
      commit e8c75a30
      
       upstream.
      
      sel_lock cannot nest in the console lock. Thanks to syzkaller, the
      kernel states firmly:
      
      > WARNING: possible circular locking dependency detected
      > 5.6.0-rc3-syzkaller #0 Not tainted
      > ------------------------------------------------------
      > syz-executor.4/20336 is trying to acquire lock:
      > ffff8880a2e952a0 (&tty->termios_rwsem){++++}, at: tty_unthrottle+0x22/0x100 drivers/tty/tty_ioctl.c:136
      >
      > but task is already holding lock:
      > ffffffff89462e70 (sel_lock){+.+.}, at: paste_selection+0x118/0x470 drivers/tty/vt/selection.c:374
      >
      > which lock already depends on the new lock.
      >
      > the existing dependency chain (in reverse order) is:
      >
      > -> #2 (sel_lock){+.+.}:
      >        mutex_lock_nested+0x1b/0x30 kernel/locking/mutex.c:1118
      >        set_selection_kernel+0x3b8/0x18a0 drivers/tty/vt/selection.c:217
      >        set_selection_user+0x63/0x80 drivers/tty/vt/selection.c:181
      >        tioclinux+0x103/0x530 drivers/tty/vt/vt.c:3050
      >        vt_ioctl+0x3f1/0x3a30 drivers/tty/vt/vt_ioctl.c:364
      
      This is ioctl(TIOCL_SETSEL).
      Locks held on the path: console_lock -> sel_lock
      
      > -> #1 (console_lock){+.+.}:
      >        console_lock+0x46/0x70 kernel/printk/printk.c:2289
      >        con_flush_chars+0x50/0x650 drivers/tty/vt/vt.c:3223
      >        n_tty_write+0xeae/0x1200 drivers/tty/n_tty.c:2350
      >        do_tty_write drivers/tty/tty_io.c:962 [inline]
      >        tty_write+0x5a1/0x950 drivers/tty/tty_io.c:1046
      
      This is write().
      Locks held on the path: termios_rwsem -> console_lock
      
      > -> #0 (&tty->termios_rwsem){++++}:
      >        down_write+0x57/0x140 kernel/locking/rwsem.c:1534
      >        tty_unthrottle+0x22/0x100 drivers/tty/tty_ioctl.c:136
      >        mkiss_receive_buf+0x12aa/0x1340 drivers/net/hamradio/mkiss.c:902
      >        tty_ldisc_receive_buf+0x12f/0x170 drivers/tty/tty_buffer.c:465
      >        paste_selection+0x346/0x470 drivers/tty/vt/selection.c:389
      >        tioclinux+0x121/0x530 drivers/tty/vt/vt.c:3055
      >        vt_ioctl+0x3f1/0x3a30 drivers/tty/vt/vt_ioctl.c:364
      
      This is ioctl(TIOCL_PASTESEL).
      Locks held on the path: sel_lock -> termios_rwsem
      
      > other info that might help us debug this:
      >
      > Chain exists of:
      >   &tty->termios_rwsem --> console_lock --> sel_lock
      
      Clearly. From the above, we have:
       console_lock -> sel_lock
       sel_lock -> termios_rwsem
       termios_rwsem -> console_lock
      
      Fix this by reversing the console_lock -> sel_lock dependency in
      ioctl(TIOCL_SETSEL). First, lock sel_lock, then console_lock.
      
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      Reported-by: default avatar <syzbot+26183d9746e62da329b8@syzkaller.appspotmail.com>
      Fixes: 07e6124a
      
       ("vt: selection, close sel_buffer race")
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200228115406.5735-2-jslaby@suse.cz
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a4719f6d
    • Jiri Slaby's avatar
      vt: selection, push console lock down · 64489a22
      Jiri Slaby authored
      commit 4b70dd57
      
       upstream.
      
      We need to nest the console lock in sel_lock, so we have to push it down
      a bit. Fortunately, the callers of set_selection_* just lock the console
      lock around the function call. So moving it down is easy.
      
      In the next patch, we switch the order.
      
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      Fixes: 07e6124a
      
       ("vt: selection, close sel_buffer race")
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200228115406.5735-1-jslaby@suse.cz
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      64489a22
    • Jiri Slaby's avatar
      vt: selection, close sel_buffer race · 432ef54c
      Jiri Slaby authored
      commit 07e6124a
      
       upstream.
      
      syzkaller reported this UAF:
      BUG: KASAN: use-after-free in n_tty_receive_buf_common+0x2481/0x2940 drivers/tty/n_tty.c:1741
      Read of size 1 at addr ffff8880089e40e9 by task syz-executor.1/13184
      
      CPU: 0 PID: 13184 Comm: syz-executor.1 Not tainted 5.4.7 #1
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014
      Call Trace:
      ...
       kasan_report+0xe/0x20 mm/kasan/common.c:634
       n_tty_receive_buf_common+0x2481/0x2940 drivers/tty/n_tty.c:1741
       tty_ldisc_receive_buf+0xac/0x190 drivers/tty/tty_buffer.c:461
       paste_selection+0x297/0x400 drivers/tty/vt/selection.c:372
       tioclinux+0x20d/0x4e0 drivers/tty/vt/vt.c:3044
       vt_ioctl+0x1bcf/0x28d0 drivers/tty/vt/vt_ioctl.c:364
       tty_ioctl+0x525/0x15a0 drivers/tty/tty_io.c:2657
       vfs_ioctl fs/ioctl.c:47 [inline]
      
      It is due to a race between parallel paste_selection (TIOCL_PASTESEL)
      and set_selection_user (TIOCL_SETSEL) invocations. One uses sel_buffer,
      while the other frees it and reallocates a new one for another
      selection. Add a mutex to close this race.
      
      The mutex takes care properly of sel_buffer and sel_buffer_lth only. The
      other selection global variables (like sel_start, sel_end, and sel_cons)
      are protected only in set_selection_user. The other functions need quite
      some more work to close the races of the variables there. This is going
      to happen later.
      
      This likely fixes (I am unsure as there is no reproducer provided) bug
      206361 too. It was marked as CVE-2020-8648.
      
      Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
      Reported-by: default avatar <syzbot+59997e8d5cbdc486e6f6@syzkaller.appspotmail.com>
      References: https://bugzilla.kernel.org/show_bug.cgi?id=206361
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200210081131.23572-2-jslaby@suse.cz
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      432ef54c
    • Jay Dolan's avatar
      serial: 8250_exar: add support for ACCES cards · 7336a80a
      Jay Dolan authored
      commit 10c5ccc3
      
       upstream.
      
      Add ACCES VIDs and PIDs that use the Exar chips
      
      Signed-off-by: default avatarJay Dolan <jay.dolan@accesio.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200305140504.22237-1-jay.dolan@accesio.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7336a80a
    • tangbin's avatar
      tty:serial:mvebu-uart:fix a wrong return · b0960a0e
      tangbin authored
      commit 4a3e2084
      
       upstream.
      
      in this place, the function should return a
      negative value and the PTR_ERR already returns
      a negative,so return -PTR_ERR() is wrong.
      
      Signed-off-by: default avatartangbin <tangbin@cmss.chinamobile.com>
      Cc: stable <stable@vger.kernel.org>
      Acked-by: default avatarJiri Slaby <jslaby@suse.cz>
      Link: https://lore.kernel.org/r/20200305013823.20976-1-tangbin@cmss.chinamobile.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b0960a0e
    • Faiz Abbas's avatar
      arm: dts: dra76x: Fix mmc3 max-frequency · 414de95c
      Faiz Abbas authored
      commit fa63c003 upstream.
      
      dra76x is not affected by i887 which requires mmc3 node to be limited to
      a max frequency of 64 MHz. Fix this by overwriting the correct value in
      the the dra76 specific dtsi.
      
      Fixes: 895bd4b3
      
       ("ARM: dts: Add support for dra76-evm")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarFaiz Abbas <faiz_abbas@ti.com>
      Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      414de95c
    • OGAWA Hirofumi's avatar
      fat: fix uninit-memory access for partial initialized inode · 265b81a5
      OGAWA Hirofumi authored
      commit bc87302a
      
       upstream.
      
      When get an error in the middle of reading an inode, some fields in the
      inode might be still not initialized.  And then the evict_inode path may
      access those fields via iput().
      
      To fix, this makes sure that inode fields are initialized.
      
      Reported-by: default avatar <syzbot+9d82b8de2992579da5d0@syzkaller.appspotmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
      Cc: <stable@vger.kernel.org>
      Link: http://lkml.kernel.org/r/871rqnreqx.fsf@mail.parknet.co.jp
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      265b81a5
    • Mel Gorman's avatar
      mm, numa: fix bad pmd by atomically check for pmd_trans_huge when marking page tables prot_numa · ebf46a94
      Mel Gorman authored
      commit 8b272b3c
      
       upstream.
      
      : A user reported a bug against a distribution kernel while running a
      : proprietary workload described as "memory intensive that is not swapping"
      : that is expected to apply to mainline kernels.  The workload is
      : read/write/modifying ranges of memory and checking the contents.  They
      : reported that within a few hours that a bad PMD would be reported followed
      : by a memory corruption where expected data was all zeros.  A partial
      : report of the bad PMD looked like
      :
      :   [ 5195.338482] ../mm/pgtable-generic.c:33: bad pmd ffff8888157ba008(000002e0396009e2)
      :   [ 5195.341184] ------------[ cut here ]------------
      :   [ 5195.356880] kernel BUG at ../mm/pgtable-generic.c:35!
      :   ....
      :   [ 5195.410033] Call Trace:
      :   [ 5195.410471]  [<ffffffff811bc75d>] change_protection_range+0x7dd/0x930
      :   [ 5195.410716]  [<ffffffff811d4be8>] change_prot_numa+0x18/0x30
      :   [ 5195.410918]  [<ffffffff810adefe>] task_numa_work+0x1fe/0x310
      :   [ 5195.411200]  [<ffffffff81098322>] task_work_run+0x72/0x90
      :   [ 5195.411246]  [<ffffffff81077139>] exit_to_usermode_loop+0x91/0xc2
      :   [ 5195.411494]  [<ffffffff81003a51>] prepare_exit_to_usermode+0x31/0x40
      :   [ 5195.411739]  [<ffffffff815e56af>] retint_user+0x8/0x10
      :
      : Decoding revealed that the PMD was a valid prot_numa PMD and the bad PMD
      : was a false detection.  The bug does not trigger if automatic NUMA
      : balancing or transparent huge pages is disabled.
      :
      : The bug is due a race in change_pmd_range between a pmd_trans_huge and
      : pmd_nond_or_clear_bad check without any locks held.  During the
      : pmd_trans_huge check, a parallel protection update under lock can have
      : cleared the PMD and filled it with a prot_numa entry between the transhuge
      : check and the pmd_none_or_clear_bad check.
      :
      : While this could be fixed with heavy locking, it's only necessary to make
      : a copy of the PMD on the stack during change_pmd_range and avoid races.  A
      : new helper is created for this as the check if quite subtle and the
      : existing similar helpful is not suitable.  This passed 154 hours of
      : testing (usually triggers between 20 minutes and 24 hours) without
      : detecting bad PMDs or corruption.  A basic test of an autonuma-intensive
      : workload showed no significant change in behaviour.
      
      Although Mel withdrew the patch on the face of LKML comment
      https://lkml.org/lkml/2017/4/10/922 the race window aforementioned is
      still open, and we have reports of Linpack test reporting bad residuals
      after the bad PMD warning is observed.  In addition to that, bad
      rss-counter and non-zero pgtables assertions are triggered on mm teardown
      for the task hitting the bad PMD.
      
       host kernel: mm/pgtable-generic.c:40: bad pmd 00000000b3152f68(8000000d2d2008e7)
       ....
       host kernel: BUG: Bad rss-counter state mm:00000000b583043d idx:1 val:512
       host kernel: BUG: non-zero pgtables_bytes on freeing mm: 4096
      
      The issue is observed on a v4.18-based distribution kernel, but the race
      window is expected to be applicable to mainline kernels, as well.
      
      [akpm@linux-foundation.org: fix comment typo, per Rafael]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarRafael Aquini <aquini@redhat.com>
      Signed-off-by: default avatarMel Gorman <mgorman@techsingularity.net>
      Cc: <stable@vger.kernel.org>
      Cc: Zi Yan <zi.yan@cs.rutgers.edu>
      Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: Michal Hocko <mhocko@suse.com>
      Link: http://lkml.kernel.org/r/20200216191800.22423-1-aquini@redhat.com
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ebf46a94
    • Zhang Xiaoxu's avatar
      vgacon: Fix a UAF in vgacon_invert_region · 1855aacc
      Zhang Xiaoxu authored
      commit 513dc792 upstream.
      
      When syzkaller tests, there is a UAF:
        BUG: KASan: use after free in vgacon_invert_region+0x9d/0x110 at addr
          ffff880000100000
        Read of size 2 by task syz-executor.1/16489
        page:ffffea0000004000 count:0 mapcount:-127 mapping:          (null)
        index:0x0
        page flags: 0xfffff00000000()
        page dumped because: kasan: bad access detected
        CPU: 1 PID: 16489 Comm: syz-executor.1 Not tainted
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
        rel-1.9.3-0-ge2fc41e-prebuilt.qemu-project.org 04/01/2014
        Call Trace:
          [<ffffffffb119f309>] dump_stack+0x1e/0x20
          [<ffffffffb04af957>] kasan_report+0x577/0x950
          [<ffffffffb04ae652>] __asan_load2+0x62/0x80
          [<ffffffffb090f26d>] vgacon_invert_region+0x9d/0x110
          [<ffffffffb0a39d95>] invert_screen+0xe5/0x470
          [<ffffffffb0a21dcb>] set_selection+0x44b/0x12f0
          [<ffffffffb0a3bfae>] tioclinux+0xee/0x490
          [<ffffffffb0a1d114>] vt_ioctl+0xff4/0x2670
          [<ffffffffb0a0089a>] tty_ioctl+0x46a/0x1a10
          [<ffffffffb052db3d>] do_vfs_ioctl+0x5bd/0xc40
          [<ffffffffb052e2f2>] SyS_ioctl+0x132/0x170
          [<ffffffffb11c9b1b>] system_call_fastpath+0x22/0x27
          Memory state around the buggy address:
           ffff8800000fff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00
           00 00
           ffff8800000fff80: 00 00 00 00 00 00 00 00 00 00 00 00 00
           00 00 00
          >ffff880000100000: ff ff ff ff ff ff ff ff ff ff ff ff ff
           ff ff ff
      
      It can be reproduce in the linux mainline by the program:
        #include <stdio.h>
        #include <stdlib.h>
        #include <unistd.h>
        #include <fcntl.h>
        #include <sys/types.h>
        #include <sys/stat.h>
        #include <sys/ioctl.h>
        #include <linux/vt.h>
      
        struct tiocl_selection {
          unsigned short xs;      /* X start */
          unsigned short ys;      /* Y start */
          unsigned short xe;      /* X end */
          unsigned short ye;      /* Y end */
          unsigned short sel_mode; /* selection mode */
        };
      
        #define TIOCL_SETSEL    2
        struct tiocl {
          unsigned char type;
          unsigned char pad;
          struct tiocl_selection sel;
        };
      
        int main()
        {
          int fd = 0;
          const char *dev = "/dev/char/4:1";
      
          struct vt_consize v = {0};
          struct tiocl tioc = {0};
      
          fd = open(dev, O_RDWR, 0);
      
          v.v_rows = 3346;
          ioctl(fd, VT_RESIZEX, &v);
      
          tioc.type = TIOCL_SETSEL;
          ioctl(fd, TIOCLINUX, &tioc);
      
          return 0;
        }
      
      When resize the screen, update the 'vc->vc_size_row' to the new_row_size,
      but when 'set_origin' in 'vgacon_set_origin', vgacon use 'vga_vram_base'
      for 'vc_origin' and 'vc_visible_origin', not 'vc_screenbuf'. It maybe
      smaller than 'vc_screenbuf'. When TIOCLINUX, use the new_row_size to calc
      the offset, it maybe larger than the vga_vram_size in vgacon driver, then
      bad access.
      Also, if set an larger screenbuf firstly, then set an more larger
      screenbuf, when copy old_origin to new_origin, a bad access may happen.
      
      So, If the screen size larger than vga_vram, resize screen should be
      failed. This alse fix CVE-2020-8649 and CVE-2020-8647.
      
      Linus pointed out that overflow checking seems absent. We're saved by
      the existing bounds checks in vc_do_resize() with rather strict
      limits:
      
      	if (cols > VC_RESIZE_MAXCOL || lines > VC_RESIZE_MAXROW)
      		return -EINVAL;
      
      Fixes: 0aec4867
      
       ("[PATCH] SVGATextMode fix")
      Reference: CVE-2020-8647 and CVE-2020-8649
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarZhang Xiaoxu <zhangxiaoxu5@huawei.com>
      [danvet: augment commit message to point out overflow safety]
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/20200304022429.37738-1-zhangxiaoxu5@huawei.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1855aacc
    • Eugeniu Rosca's avatar
      usb: core: port: do error out if usb_autopm_get_interface() fails · 8389c9d7
      Eugeniu Rosca authored
      commit 1f8b39bc upstream.
      
      Reviewing a fresh portion of coverity defects in USB core
      (specifically CID 1458999), Alan Stern noted below in [1]:
      
      On Tue, Feb 25, 2020 at 02:39:23PM -0500, Alan Stern wrote:
       > A revised search finds line 997 in drivers/usb/core/hub.c and lines
       > 216, 269 in drivers/usb/core/port.c.  (I didn't try looking in any
       > other directories.)  AFAICT all three of these should check the
       > return value, although a error message in the kernel log probably
       > isn't needed.
      
      Factor out the usb_port_runtime_{resume,suspend}() changes into a
      standalone patch to allow conflict-free porting on top of stable v3.9+.
      
      [1] https://lore.kernel.org/lkml/Pine.LNX.4.44L0.2002251419120.1485-100000@iolanthe.rowland.org
      
      Fixes: 971fcd49
      
       ("usb: add runtime pm support for usb port device")
      Cc: stable@vger.kernel.org # v3.9+
      Suggested-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Link: https://lore.kernel.org/r/20200226175036.14946-3-erosca@de.adit-jv.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8389c9d7
    • Eugeniu Rosca's avatar
      usb: core: hub: do error out if usb_autopm_get_interface() fails · af20d8c0
      Eugeniu Rosca authored
      commit 60e3f6e4 upstream.
      
      Reviewing a fresh portion of coverity defects in USB core
      (specifically CID 1458999), Alan Stern noted below in [1]:
      
      On Tue, Feb 25, 2020 at 02:39:23PM -0500, Alan Stern wrote:
       > A revised search finds line 997 in drivers/usb/core/hub.c and lines
       > 216, 269 in drivers/usb/core/port.c.  (I didn't try looking in any
       > other directories.)  AFAICT all three of these should check the
       > return value, although a error message in the kernel log probably
       > isn't needed.
      
      Factor out the usb_remove_device() change into a standalone patch to
      allow conflict-free integration on top of the earliest stable branches.
      
      [1] https://lore.kernel.org/lkml/Pine.LNX.4.44L0.2002251419120.1485-100000@iolanthe.rowland.org
      
      Fixes: 253e0572
      
       ("USB: add a "remove hardware" sysfs attribute")
      Cc: stable@vger.kernel.org # v2.6.33+
      Suggested-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Link: https://lore.kernel.org/r/20200226175036.14946-2-erosca@de.adit-jv.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      af20d8c0
    • Eugeniu Rosca's avatar
      usb: core: hub: fix unhandled return by employing a void function · bc6da5b1
      Eugeniu Rosca authored
      commit 63d6d7ed upstream.
      
      Address below Coverity complaint (Feb 25, 2020, 8:06 AM CET):
      bc6da5b1
    • Dan Lazewatsky's avatar
      usb: quirks: add NO_LPM quirk for Logitech Screen Share · 504a02d4
      Dan Lazewatsky authored
      commit b96ed52d
      
       upstream.
      
      LPM on the device appears to cause xHCI host controllers to claim
      that there isn't enough bandwidth to support additional devices.
      
      Signed-off-by: default avatarDan Lazewatsky <dlaz@chromium.org>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.com>
      Link: https://lore.kernel.org/r/20200226143438.1445-1-gustavo.padovan@collabora.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      504a02d4
    • Jim Lin's avatar
      usb: storage: Add quirk for Samsung Fit flash · 5c4d9b1e
      Jim Lin authored
      commit 86d92f54
      
       upstream.
      
      Current driver has 240 (USB2.0) and 2048 (USB3.0) as max_sectors,
      e.g., /sys/bus/scsi/devices/0:0:0:0/max_sectors
      
      If data access times out, driver error handling will issue a port
      reset.
      Sometimes Samsung Fit (090C:1000) flash disk will not respond to
      later Set Address or Get Descriptor command.
      
      Adding this quirk to limit max_sectors to 64 sectors to avoid issue
      occurring.
      
      Signed-off-by: default avatarJim Lin <jilin@nvidia.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/1583158895-31342-1-git-send-email-jilin@nvidia.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5c4d9b1e