1. 16 Aug, 2019 40 commits
    • Tai Man's avatar
      drm/amd/display: Increase size of audios array · 8d641499
      Tai Man authored
      [ Upstream commit 7352193a ]
      
      [Why]
      The audios array defined in "struct resource_pool" is only 6 (MAX_PIPES)
      but the max number of audio devices (num_audio) is 7. In some projects,
      it will run out of audios array.
      
      [How]
      Incraese the audios array size to 7.
      Signed-off-by: default avatarTai Man <taiman.wong@amd.com>
      Reviewed-by: default avatarJoshua Aberback <Joshua.Aberback@amd.com>
      Acked-by: default avatarLeo Li <sunpeng.li@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8d641499
    • Alvin Lee's avatar
      drm/amd/display: Only enable audio if speaker allocation exists · f9420bfa
      Alvin Lee authored
      [ Upstream commit 6ac25e6d ]
      
      [Why]
      
      In dm_helpers_parse_edid_caps, there is a corner case where no speakers
      can be allocated even though the audio mode count is greater than 0.
      Enabling audio when no speaker allocations exists can cause issues in
      the video stream.
      
      [How]
      
      Add a check to not enable audio unless one or more speaker allocations
      exist (since doing this can cause issues in the video stream).
      Signed-off-by: default avatarAlvin Lee <alvin.lee2@amd.com>
      Reviewed-by: default avatarJun Lei <Jun.Lei@amd.com>
      Acked-by: default avatarLeo Li <sunpeng.li@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f9420bfa
    • Julian Parkin's avatar
      drm/amd/display: Fix dc_create failure handling and 666 color depths · 3998e684
      Julian Parkin authored
      [ Upstream commit 0905f329 ]
      
      [Why]
      It is possible (but very unlikely) that constructing dc fails
      before current_state is created.
      
      We support 666 color depth in some scenarios, but this
      isn't handled in get_norm_pix_clk. It uses exactly the
      same pixel clock as the 888 case.
      
      [How]
      Check for non null current_state before destructing.
      
      Add case for 666 color depth to get_norm_pix_clk to
      avoid assertion.
      Signed-off-by: default avatarJulian Parkin <julian.parkin@amd.com>
      Reviewed-by: default avatarCharlene Liu <Charlene.Liu@amd.com>
      Acked-by: default avatarLeo Li <sunpeng.li@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3998e684
    • Tai Man's avatar
      drm/amd/display: use encoder's engine id to find matched free audio device · e7a8a794
      Tai Man authored
      [ Upstream commit 74eda776 ]
      
      [Why]
      On some platforms, the encoder id 3 is not populated. So the encoders
      are not stored in right order as index (id: 0, 1, 2, 4, 5) at pool. This
      would cause encoders id 4 & id 5 to fail when finding corresponding
      audio device, defaulting to the first available audio device. As result,
      we cannot stream audio into two DP ports with encoders id 4 & id 5.
      
      [How]
      It need to create enough audio device objects (0 - 5) to perform matching.
      Then use encoder engine id to find matched audio device.
      Signed-off-by: default avatarTai Man <taiman.wong@amd.com>
      Reviewed-by: default avatarCharlene Liu <Charlene.Liu@amd.com>
      Acked-by: default avatarLeo Li <sunpeng.li@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e7a8a794
    • SivapiriyanKumarasamy's avatar
      drm/amd/display: Wait for backlight programming completion in set backlight level · 2a5e21ad
      SivapiriyanKumarasamy authored
      [ Upstream commit c7990dae ]
      
      [WHY]
      Currently we don't wait for blacklight programming completion in DMCU
      when setting backlight level. Some sequences such as PSR static screen
      event trigger reprogramming requires it to be complete.
      
      [How]
      Add generic wait for dmcu command completion in set backlight level.
      Signed-off-by: default avatarSivapiriyanKumarasamy <sivapiriyan.kumarasamy@amd.com>
      Reviewed-by: default avatarAnthony Koo <Anthony.Koo@amd.com>
      Acked-by: default avatarLeo Li <sunpeng.li@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2a5e21ad
    • Mauro Carvalho Chehab's avatar
      scripts/sphinx-pre-install: fix script for RHEL/CentOS · 056af94d
      Mauro Carvalho Chehab authored
      [ Upstream commit b308467c ]
      
      There's a missing parenthesis at the script, with causes it to
      fail to detect non-Fedora releases (e. g. RHEL/CentOS).
      
      Tested with Centos 7.6.1810.
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      056af94d
    • Laura Garcia Liebana's avatar
      netfilter: nft_hash: fix symhash with modulus one · 36b6458d
      Laura Garcia Liebana authored
      [ Upstream commit 28b1d6ef ]
      
      The rule below doesn't work as the kernel raises -ERANGE.
      
      nft add rule netdev nftlb lb01 ip daddr set \
      	symhash mod 1 map { 0 : 192.168.0.10 } fwd to "eth0"
      
      This patch allows to use the symhash modulus with one
      element, in the same way that the other types of hashes and
      algorithms that uses the modulus parameter.
      Signed-off-by: default avatarLaura Garcia Liebana <nevola@gmail.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      36b6458d
    • Florian Westphal's avatar
      netfilter: conntrack: always store window size un-scaled · 6f1d7f0d
      Florian Westphal authored
      [ Upstream commit 959b69ef ]
      
      Jakub Jankowski reported following oddity:
      
      After 3 way handshake completes, timeout of new connection is set to
      max_retrans (300s) instead of established (5 days).
      
      shortened excerpt from pcap provided:
      25.070622 IP (flags [DF], proto TCP (6), length 52)
      10.8.5.4.1025 > 10.8.1.2.80: Flags [S], seq 11, win 64240, [wscale 8]
      26.070462 IP (flags [DF], proto TCP (6), length 48)
      10.8.1.2.80 > 10.8.5.4.1025: Flags [S.], seq 82, ack 12, win 65535, [wscale 3]
      27.070449 IP (flags [DF], proto TCP (6), length 40)
      10.8.5.4.1025 > 10.8.1.2.80: Flags [.], ack 83, win 512, length 0
      
      Turns out the last_win is of u16 type, but we store the scaled value:
      512 << 8 (== 0x20000) becomes 0 window.
      
      The Fixes tag is not correct, as the bug has existed forever, but
      without that change all that this causes might cause is to mistake a
      window update (to-nonzero-from-zero) for a retransmit.
      
      Fixes: fbcd253d ("netfilter: conntrack: lower timeout to RETRANS seconds if window is 0")
      Reported-by: default avatarJakub Jankowski <shasta@toxcorp.com>
      Tested-by: default avatarJakub Jankowski <shasta@toxcorp.com>
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Acked-by: default avatarJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6f1d7f0d
    • Miaohe Lin's avatar
      netfilter: Fix rpfilter dropping vrf packets by mistake · 307b6e5d
      Miaohe Lin authored
      [ Upstream commit b575b24b ]
      
      When firewalld is enabled with ipv4/ipv6 rpfilter, vrf
      ipv4/ipv6 packets will be dropped. Vrf device will pass
      through netfilter hook twice. One with enslaved device
      and another one with l3 master device. So in device may
      dismatch witch out device because out device is always
      enslaved device.So failed with the check of the rpfilter
      and drop the packets by mistake.
      Signed-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      307b6e5d
    • Farhan Ali's avatar
      vfio-ccw: Set pa_nr to 0 if memory allocation fails for pa_iova_pfn · 6f9dff8d
      Farhan Ali authored
      [ Upstream commit c1ab6926 ]
      
      So we don't call try to call vfio_unpin_pages() incorrectly.
      
      Fixes: 0a19e61e ("vfio: ccw: introduce channel program interfaces")
      Signed-off-by: default avatarFarhan Ali <alifm@linux.ibm.com>
      Reviewed-by: default avatarEric Farman <farman@linux.ibm.com>
      Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
      Message-Id: <33a89467ad6369196ae6edf820cbcb1e2d8d050c.1562854091.git.alifm@linux.ibm.com>
      Signed-off-by: default avatarCornelia Huck <cohuck@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6f9dff8d
    • Florian Westphal's avatar
      netfilter: nfnetlink: avoid deadlock due to synchronous request_module · bb312b4a
      Florian Westphal authored
      [ Upstream commit 1b0890cd ]
      
      Thomas and Juliana report a deadlock when running:
      
      (rmmod nf_conntrack_netlink/xfrm_user)
      
        conntrack -e NEW -E &
        modprobe -v xfrm_user
      
      They provided following analysis:
      
      conntrack -e NEW -E
          netlink_bind()
              netlink_lock_table() -> increases "nl_table_users"
                  nfnetlink_bind()
                  # does not unlock the table as it's locked by netlink_bind()
                      __request_module()
                          call_usermodehelper_exec()
      
      This triggers "modprobe nf_conntrack_netlink" from kernel, netlink_bind()
      won't return until modprobe process is done.
      
      "modprobe xfrm_user":
          xfrm_user_init()
              register_pernet_subsys()
                  -> grab pernet_ops_rwsem
                      ..
                      netlink_table_grab()
                          calls schedule() as "nl_table_users" is non-zero
      
      so modprobe is blocked because netlink_bind() increased
      nl_table_users while also holding pernet_ops_rwsem.
      
      "modprobe nf_conntrack_netlink" runs and inits nf_conntrack_netlink:
          ctnetlink_init()
              register_pernet_subsys()
                  -> blocks on "pernet_ops_rwsem" thanks to xfrm_user module
      
      both modprobe processes wait on one another -- neither can make
      progress.
      
      Switch netlink_bind() to "nowait" modprobe -- this releases the netlink
      table lock, which then allows both modprobe instances to complete.
      Reported-by: default avatarThomas Jarosch <thomas.jarosch@intra2net.com>
      Reported-by: default avatarJuliana Rodrigueiro <juliana.rodrigueiro@intra2net.com>
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bb312b4a
    • Stephane Grosjean's avatar
      can: peak_usb: fix potential double kfree_skb() · f61c4d3a
      Stephane Grosjean authored
      commit fee6a892 upstream.
      
      When closing the CAN device while tx skbs are inflight, echo skb could
      be released twice. By calling close_candev() before unlinking all
      pending tx urbs, then the internal echo_skb[] array is fully and
      correctly cleared before the USB write callback and, therefore,
      can_get_echo_skb() are called, for each aborted URB.
      
      Fixes: bb478555 ("can: usb: PEAK-System Technik USB adapters driver core")
      Signed-off-by: default avatarStephane Grosjean <s.grosjean@peak-system.com>
      Cc: linux-stable <stable@vger.kernel.org>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f61c4d3a
    • Nikita Yushchenko's avatar
      can: rcar_canfd: fix possible IRQ storm on high load · 0e9038a2
      Nikita Yushchenko authored
      commit d4b890ae upstream.
      
      We have observed rcar_canfd driver entering IRQ storm under high load,
      with following scenario:
      - rcar_canfd_global_interrupt() in entered due to Rx available,
      - napi_schedule_prep() is called, and sets NAPIF_STATE_SCHED in state
      - Rx fifo interrupts are masked,
      - rcar_canfd_global_interrupt() is entered again, this time due to
        error interrupt (e.g. due to overflow),
      - since scheduled napi poller has not yet executed, condition for calling
        napi_schedule_prep() from rcar_canfd_global_interrupt() remains true,
        thus napi_schedule_prep() gets called and sets NAPIF_STATE_MISSED flag
        in state,
      - later, napi poller function rcar_canfd_rx_poll() gets executed, and
        calls napi_complete_done(),
      - due to NAPIF_STATE_MISSED flag in state, this call does not clear
        NAPIF_STATE_SCHED flag from state,
      - on return from napi_complete_done(), rcar_canfd_rx_poll() unmasks Rx
        interrutps,
      - Rx interrupt happens, rcar_canfd_global_interrupt() gets called
        and calls napi_schedule_prep(),
      - since NAPIF_STATE_SCHED is set in state at this time, this call
        returns false,
      - due to that false return, rcar_canfd_global_interrupt() returns
        without masking Rx interrupt
      - and this results into IRQ storm: unmasked Rx interrupt happens again
        and again is misprocessed in the same way.
      
      This patch fixes that scenario by unmasking Rx interrupts only when
      napi_complete_done() returns true, which means it has cleared
      NAPIF_STATE_SCHED in state.
      
      Fixes: dd3bd23e ("can: rcar_canfd: Add Renesas R-Car CAN FD driver")
      Signed-off-by: default avatarNikita Yushchenko <nikita.yoush@cogentembedded.com>
      Cc: linux-stable <stable@vger.kernel.org>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0e9038a2
    • Guenter Roeck's avatar
      usb: typec: tcpm: Ignore unsupported/unknown alternate mode requests · 9479a058
      Guenter Roeck authored
      commit 88d02c9b upstream.
      
      TCPM may receive PD messages associated with unknown or unsupported
      alternate modes. If that happens, calls to typec_match_altmode()
      will return NULL. The tcpm code does not currently take this into
      account. This results in crashes.
      
      Unable to handle kernel NULL pointer dereference at virtual address 000001f0
      pgd = 41dad9a1
      [000001f0] *pgd=00000000
      Internal error: Oops: 5 [#1] THUMB2
      Modules linked in: tcpci tcpm
      CPU: 0 PID: 2338 Comm: kworker/u2:0 Not tainted 5.1.18-sama5-armv7-r2 #6
      Hardware name: Atmel SAMA5
      Workqueue: 2-0050 tcpm_pd_rx_handler [tcpm]
      PC is at typec_altmode_attention+0x0/0x14
      LR is at tcpm_pd_rx_handler+0xa3b/0xda0 [tcpm]
      ...
      [<c03fbee8>] (typec_altmode_attention) from [<bf8030fb>]
      				(tcpm_pd_rx_handler+0xa3b/0xda0 [tcpm])
      [<bf8030fb>] (tcpm_pd_rx_handler [tcpm]) from [<c012082b>]
      				(process_one_work+0x123/0x2a8)
      [<c012082b>] (process_one_work) from [<c0120a6d>]
      				(worker_thread+0xbd/0x3b0)
      [<c0120a6d>] (worker_thread) from [<c012431f>] (kthread+0xcf/0xf4)
      [<c012431f>] (kthread) from [<c01010f9>] (ret_from_fork+0x11/0x38)
      
      Ignore PD messages if the associated alternate mode is not supported.
      
      Fixes: e9576fe8 ("usb: typec: tcpm: Support for Alternate Modes")
      Cc: stable <stable@vger.kernel.org>
      Reported-by: default avatarDouglas Gilbert <dgilbert@interlog.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Acked-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Tested-by: default avatarDouglas Gilbert <dgilbert@interlog.com>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Link: https://lore.kernel.org/r/1564761822-13984-1-git-send-email-linux@roeck-us.netSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9479a058
    • Guenter Roeck's avatar
      usb: typec: tcpm: Add NULL check before dereferencing config · 3f524b63
      Guenter Roeck authored
      commit 1957de95 upstream.
      
      When instantiating tcpm on an NXP OM 13588 board with NXP PTN5110,
      the following crash is seen when writing into the 'preferred_role'
      sysfs attribute.
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000028
      pgd = f69149ad
      [00000028] *pgd=00000000
      Internal error: Oops: 5 [#1] THUMB2
      Modules linked in: tcpci tcpm
      CPU: 0 PID: 1882 Comm: bash Not tainted 5.1.18-sama5-armv7-r2 #4
      Hardware name: Atmel SAMA5
      PC is at tcpm_try_role+0x3a/0x4c [tcpm]
      LR is at tcpm_try_role+0x15/0x4c [tcpm]
      pc : [<bf8000e2>]    lr : [<bf8000bd>]    psr: 60030033
      sp : dc1a1e88  ip : c03fb47d  fp : 00000000
      r10: dc216190  r9 : dc1a1f78  r8 : 00000001
      r7 : df4ae044  r6 : dd032e90  r5 : dd1ce340  r4 : df4ae054
      r3 : 00000000  r2 : 00000000  r1 : 00000000  r0 : df4ae044
      Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA Thumb  Segment none
      Control: 50c53c7d  Table: 3efec059  DAC: 00000051
      Process bash (pid: 1882, stack limit = 0x6a6d4aa5)
      Stack: (0xdc1a1e88 to 0xdc1a2000)
      1e80:                   dd05d808 dd1ce340 00000001 00000007 dd1ce340 c03fb4a7
      1ea0: 00000007 00000007 dc216180 00000000 00000000 c01e1e03 00000000 00000000
      1ec0: c0907008 dee98b40 c01e1d5d c06106c4 00000000 00000000 00000007 c0194e8b
      1ee0: 0000000a 00000400 00000000 c01a97db dc22bf00 ffffe000 df4b6a00 df745900
      1f00: 00000001 00000001 000000dd c01a9c2f 7aeab3be c0907008 00000000 dc22bf00
      1f20: c0907008 00000000 00000000 00000000 00000000 7aeab3be 00000007 dee98b40
      1f40: 005dc318 dc1a1f78 00000000 00000000 00000007 c01969f7 0000000a c01a20cb
      1f60: dee98b40 c0907008 dee98b40 005dc318 00000000 c0196b9b 00000000 00000000
      1f80: dee98b40 7aeab3be 00000074 005dc318 b6f3bdb0 00000004 c0101224 dc1a0000
      1fa0: 00000004 c0101001 00000074 005dc318 00000001 005dc318 00000007 00000000
      1fc0: 00000074 005dc318 b6f3bdb0 00000004 00000007 00000007 00000000 00000000
      1fe0: 00000004 be800880 b6ed35b3 b6e5c746 60030030 00000001 00000000 00000000
      [<bf8000e2>] (tcpm_try_role [tcpm]) from [<c03fb4a7>] (preferred_role_store+0x2b/0x5c)
      [<c03fb4a7>] (preferred_role_store) from [<c01e1e03>] (kernfs_fop_write+0xa7/0x150)
      [<c01e1e03>] (kernfs_fop_write) from [<c0194e8b>] (__vfs_write+0x1f/0x104)
      [<c0194e8b>] (__vfs_write) from [<c01969f7>] (vfs_write+0x6b/0x104)
      [<c01969f7>] (vfs_write) from [<c0196b9b>] (ksys_write+0x43/0x94)
      [<c0196b9b>] (ksys_write) from [<c0101001>] (ret_fast_syscall+0x1/0x62)
      
      Since commit 96232cbc ("usb: typec: tcpm: support get typec and pd
      config from device properties"), the 'config' pointer in struct tcpc_dev
      is optional when registering a Type-C port. Since it is optional, we have
      to check if it is NULL before dereferencing it.
      Reported-by: default avatarDouglas Gilbert <dgilbert@interlog.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Fixes: 96232cbc ("usb: typec: tcpm: support get typec and pd config from device properties")
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Cc: stable <stable@vger.kernel.org>
      Reviewed-by: default avatarJun Li <jun.li@nxp.com>
      Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Link: https://lore.kernel.org/r/1563979112-22483-1-git-send-email-linux@roeck-us.netSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3f524b63
    • Li Jun's avatar
      usb: typec: tcpm: remove tcpm dir if no children · bbc2e820
      Li Jun authored
      commit 12ca7297 upstream.
      
      If config tcpm as module, module unload will not remove tcpm dir,
      then the next module load will have problem: the rootdir is NULL
      but tcpm dir is still there, so tcpm_debugfs_init() will create
      tcpm dir again with failure, fix it by remove the tcpm dir if no
      children.
      
      Cc: stable@vger.kernel.org # v4.15+
      Fixes: 4b4e02c8 ("typec: tcpm: Move out of staging")
      Signed-off-by: default avatarLi Jun <jun.li@nxp.com>
      Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Link: https://lore.kernel.org/r/20190717080646.30421-2-jun.li@nxp.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bbc2e820
    • Li Jun's avatar
      usb: typec: tcpm: free log buf memory when remove debug file · 2ec5c9b7
      Li Jun authored
      commit fd5da3e2 upstream.
      
      The logbuffer memory should be freed when remove debug file.
      
      Cc: stable@vger.kernel.org # v4.15+
      Fixes: 4b4e02c8 ("typec: tcpm: Move out of staging")
      Signed-off-by: default avatarLi Jun <jun.li@nxp.com>
      Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Link: https://lore.kernel.org/r/20190717080646.30421-1-jun.li@nxp.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2ec5c9b7
    • Suzuki K Poulose's avatar
      usb: yurex: Fix use-after-free in yurex_delete · 33f2240a
      Suzuki K Poulose authored
      commit fc05481b upstream.
      
      syzbot reported the following crash [0]:
      
      BUG: KASAN: use-after-free in usb_free_coherent+0x79/0x80
      drivers/usb/core/usb.c:928
      Read of size 8 at addr ffff8881b18599c8 by task syz-executor.4/16007
      
      CPU: 0 PID: 16007 Comm: syz-executor.4 Not tainted 5.3.0-rc2+ #23
      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+0xca/0x13e lib/dump_stack.c:113
        print_address_description+0x6a/0x32c mm/kasan/report.c:351
        __kasan_report.cold+0x1a/0x33 mm/kasan/report.c:482
        kasan_report+0xe/0x12 mm/kasan/common.c:612
        usb_free_coherent+0x79/0x80 drivers/usb/core/usb.c:928
        yurex_delete+0x138/0x330 drivers/usb/misc/yurex.c:100
        kref_put include/linux/kref.h:65 [inline]
        yurex_release+0x66/0x90 drivers/usb/misc/yurex.c:392
        __fput+0x2d7/0x840 fs/file_table.c:280
        task_work_run+0x13f/0x1c0 kernel/task_work.c:113
        tracehook_notify_resume include/linux/tracehook.h:188 [inline]
        exit_to_usermode_loop+0x1d2/0x200 arch/x86/entry/common.c:163
        prepare_exit_to_usermode arch/x86/entry/common.c:194 [inline]
        syscall_return_slowpath arch/x86/entry/common.c:274 [inline]
        do_syscall_64+0x45f/0x580 arch/x86/entry/common.c:299
        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      RIP: 0033:0x413511
      Code: 75 14 b8 03 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 04 1b 00 00 c3 48
      83 ec 08 e8 0a fc ff ff 48 89 04 24 b8 03 00 00 00 0f 05 <48> 8b 3c 24 48
      89 c2 e8 53 fc ff ff 48 89 d0 48 83 c4 08 48 3d 01
      RSP: 002b:00007ffc424ea2e0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
      RAX: 0000000000000000 RBX: 0000000000000007 RCX: 0000000000413511
      RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000006
      RBP: 0000000000000001 R08: 0000000029a2fc22 R09: 0000000029a2fc26
      R10: 00007ffc424ea3c0 R11: 0000000000000293 R12: 000000000075c9a0
      R13: 000000000075c9a0 R14: 0000000000761938 R15: ffffffffffffffff
      
      Allocated by task 2776:
        save_stack+0x1b/0x80 mm/kasan/common.c:69
        set_track mm/kasan/common.c:77 [inline]
        __kasan_kmalloc mm/kasan/common.c:487 [inline]
        __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:460
        kmalloc include/linux/slab.h:552 [inline]
        kzalloc include/linux/slab.h:748 [inline]
        usb_alloc_dev+0x51/0xf95 drivers/usb/core/usb.c:583
        hub_port_connect drivers/usb/core/hub.c:5004 [inline]
        hub_port_connect_change drivers/usb/core/hub.c:5213 [inline]
        port_event drivers/usb/core/hub.c:5359 [inline]
        hub_event+0x15c0/0x3640 drivers/usb/core/hub.c:5441
        process_one_work+0x92b/0x1530 kernel/workqueue.c:2269
        worker_thread+0x96/0xe20 kernel/workqueue.c:2415
        kthread+0x318/0x420 kernel/kthread.c:255
        ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352
      
      Freed by task 16007:
        save_stack+0x1b/0x80 mm/kasan/common.c:69
        set_track mm/kasan/common.c:77 [inline]
        __kasan_slab_free+0x130/0x180 mm/kasan/common.c:449
        slab_free_hook mm/slub.c:1423 [inline]
        slab_free_freelist_hook mm/slub.c:1470 [inline]
        slab_free mm/slub.c:3012 [inline]
        kfree+0xe4/0x2f0 mm/slub.c:3953
        device_release+0x71/0x200 drivers/base/core.c:1064
        kobject_cleanup lib/kobject.c:693 [inline]
        kobject_release lib/kobject.c:722 [inline]
        kref_put include/linux/kref.h:65 [inline]
        kobject_put+0x171/0x280 lib/kobject.c:739
        put_device+0x1b/0x30 drivers/base/core.c:2213
        usb_put_dev+0x1f/0x30 drivers/usb/core/usb.c:725
        yurex_delete+0x40/0x330 drivers/usb/misc/yurex.c:95
        kref_put include/linux/kref.h:65 [inline]
        yurex_release+0x66/0x90 drivers/usb/misc/yurex.c:392
        __fput+0x2d7/0x840 fs/file_table.c:280
        task_work_run+0x13f/0x1c0 kernel/task_work.c:113
        tracehook_notify_resume include/linux/tracehook.h:188 [inline]
        exit_to_usermode_loop+0x1d2/0x200 arch/x86/entry/common.c:163
        prepare_exit_to_usermode arch/x86/entry/common.c:194 [inline]
        syscall_return_slowpath arch/x86/entry/common.c:274 [inline]
        do_syscall_64+0x45f/0x580 arch/x86/entry/common.c:299
        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
      The buggy address belongs to the object at ffff8881b1859980
        which belongs to the cache kmalloc-2k of size 2048
      The buggy address is located 72 bytes inside of
        2048-byte region [ffff8881b1859980, ffff8881b185a180)
      The buggy address belongs to the page:
      page:ffffea0006c61600 refcount:1 mapcount:0 mapping:ffff8881da00c000
      index:0x0 compound_mapcount: 0
      flags: 0x200000000010200(slab|head)
      raw: 0200000000010200 0000000000000000 0000000100000001 ffff8881da00c000
      raw: 0000000000000000 00000000000f000f 00000001ffffffff 0000000000000000
      page dumped because: kasan: bad access detected
      
      Memory state around the buggy address:
        ffff8881b1859880: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
        ffff8881b1859900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      > ffff8881b1859980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                     ^
        ffff8881b1859a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
        ffff8881b1859a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      ==================================================================
      
      A quick look at the yurex_delete() shows that we drop the reference
      to the usb_device before releasing any buffers associated with the
      device. Delay the reference drop until we have finished the cleanup.
      
      [0] https://lore.kernel.org/lkml/0000000000003f86d8058f0bd671@google.com/
      
      Fixes: 6bc235a2 ("USB: add driver for Meywa-Denki & Kayac YUREX")
      Cc: Jiri Kosina <jkosina@suse.cz>
      Cc: Tomoki Sekiyama <tomoki.sekiyama@gmail.com>
      Cc: Oliver Neukum <oneukum@suse.com>
      Cc: andreyknvl@google.com
      Cc: gregkh@linuxfoundation.org
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: syzkaller-bugs@googlegroups.com
      Cc: dtor@chromium.org
      Reported-by: syzbot+d1fedb1c1fdb07fca507@syzkaller.appspotmail.com
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20190805111528.6758-1-suzuki.poulose@arm.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      33f2240a
    • Yoshihiro Shimoda's avatar
      usb: host: xhci-rcar: Fix timeout in xhci_suspend() · 49888a4f
      Yoshihiro Shimoda authored
      commit 783bda5e upstream.
      
      When a USB device is connected to the host controller and
      the system enters suspend, the following error happens
      in xhci_suspend():
      
      	xhci-hcd ee000000.usb: WARN: xHC CMD_RUN timeout
      
      Since the firmware/internal CPU control the USBSTS.STS_HALT
      and the process speed is down when the roothub port enters U3,
      long delay for the handshake of STS_HALT is neeed in xhci_suspend().
      So, this patch adds to set the XHCI_SLOW_SUSPEND.
      
      Fixes: 435cc113 ("usb: host: xhci-plat: set resume_quirk() for R-Car controllers")
      Cc: <stable@vger.kernel.org> # v4.12+
      Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Link: https://lore.kernel.org/r/1564734815-17964-1-git-send-email-yoshihiro.shimoda.uh@renesas.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      49888a4f
    • Andreas Gruenbacher's avatar
      gfs2: gfs2_walk_metadata fix · 21344f05
      Andreas Gruenbacher authored
      commit a27a0c9b upstream.
      
      It turns out that the current version of gfs2_metadata_walker suffers
      from multiple problems that can cause gfs2_hole_size to report an
      incorrect size.  This will confuse fiemap as well as lseek with the
      SEEK_DATA flag.
      
      Fix that by changing gfs2_hole_walker to compute the metapath to the
      first data block after the hole (if any), and compute the hole size
      based on that.
      
      Fixes xfstest generic/490.
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      Reviewed-by: default avatarBob Peterson <rpeterso@redhat.com>
      Cc: stable@vger.kernel.org # v4.18+
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      21344f05
    • Nick Desaulniers's avatar
      x86/purgatory: Use CFLAGS_REMOVE rather than reset KBUILD_CFLAGS · b674f791
      Nick Desaulniers authored
      commit b059f801 upstream.
      
      KBUILD_CFLAGS is very carefully built up in the top level Makefile,
      particularly when cross compiling or using different build tools.
      Resetting KBUILD_CFLAGS via := assignment is an antipattern.
      
      The comment above the reset mentions that -pg is problematic.  Other
      Makefiles use `CFLAGS_REMOVE_file.o = $(CC_FLAGS_FTRACE)` when
      CONFIG_FUNCTION_TRACER is set. Prefer that pattern to wiping out all of
      the important KBUILD_CFLAGS then manually having to re-add them. Seems
      also that __stack_chk_fail references are generated when using
      CONFIG_STACKPROTECTOR or CONFIG_STACKPROTECTOR_STRONG.
      
      Fixes: 8fc5b4d4 ("purgatory: core purgatory functionality")
      Reported-by: default avatarVaibhav Rustagi <vaibhavrustagi@google.com>
      Suggested-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Suggested-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Tested-by: default avatarVaibhav Rustagi <vaibhavrustagi@google.com>
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/20190807221539.94583-2-ndesaulniers@google.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b674f791
    • Thomas Richter's avatar
      perf record: Fix module size on s390 · 0a9e41e2
      Thomas Richter authored
      commit 12a6d294 upstream.
      
      On s390 the modules loaded in memory have the text segment located after
      the GOT and Relocation table. This can be seen with this output:
      
        [root@m35lp76 perf]# fgrep qeth /proc/modules
        qeth 151552 1 qeth_l2, Live 0x000003ff800b2000
        ...
        [root@m35lp76 perf]# cat /sys/module/qeth/sections/.text
        0x000003ff800b3990
        [root@m35lp76 perf]#
      
      There is an offset of 0x1990 bytes. The size of the qeth module is
      151552 bytes (0x25000 in hex).
      
      The location of the GOT/relocation table at the beginning of a module is
      unique to s390.
      
      commit 203d8a4a ("perf s390: Fix 'start' address of module's map")
      adjusts the start address of a module in the map structures, but does
      not adjust the size of the modules. This leads to overlapping of module
      maps as this example shows:
      
      [root@m35lp76 perf] # ./perf report -D
           0 0 0xfb0 [0xa0]: PERF_RECORD_MMAP -1/0: [0x3ff800b3990(0x25000)
                @ 0]:  x /lib/modules/.../qeth.ko.xz
           0 0 0x1050 [0xb0]: PERF_RECORD_MMAP -1/0: [0x3ff800d85a0(0x8000)
                @ 0]:  x /lib/modules/.../ip6_tables.ko.xz
      
      The module qeth.ko has an adjusted start address modified to b3990, but
      its size is unchanged and the module ends at 0x3ff800d8990.  This end
      address overlaps with the next modules start address of 0x3ff800d85a0.
      
      When the size of the leading GOT/Relocation table stored in the
      beginning of the text segment (0x1990 bytes) is subtracted from module
      qeth end address, there are no overlaps anymore:
      
         0x3ff800d8990 - 0x1990 = 0x0x3ff800d7000
      
      which is the same as
      
         0x3ff800b2000 + 0x25000 = 0x0x3ff800d7000.
      
      To fix this issue, also adjust the modules size in function
      arch__fix_module_text_start(). Add another function parameter named size
      and reduce the size of the module when the text segment start address is
      changed.
      
      Output after:
           0 0 0xfb0 [0xa0]: PERF_RECORD_MMAP -1/0: [0x3ff800b3990(0x23670)
                @ 0]:  x /lib/modules/.../qeth.ko.xz
           0 0 0x1050 [0xb0]: PERF_RECORD_MMAP -1/0: [0x3ff800d85a0(0x7a60)
                @ 0]:  x /lib/modules/.../ip6_tables.ko.xz
      Reported-by: default avatarStefan Liebler <stli@linux.ibm.com>
      Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Acked-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Hendrik Brueckner <brueckner@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: stable@vger.kernel.org
      Fixes: 203d8a4a ("perf s390: Fix 'start' address of module's map")
      Link: http://lkml.kernel.org/r/20190724122703.3996-1-tmricht@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0a9e41e2
    • Adrian Hunter's avatar
      perf db-export: Fix thread__exec_comm() · f1f66289
      Adrian Hunter authored
      commit 3de7ae0b upstream.
      
      Threads synthesized from /proc have comms with a start time of zero, and
      not marked as "exec". Currently, there can be 2 such comms. The first is
      created by processing a synthesized fork event and is set to the
      parent's comm string, and the second by processing a synthesized comm
      event set to the thread's current comm string.
      
      In the absence of an "exec" comm, thread__exec_comm() picks the last
      (oldest) comm, which, in the case above, is the parent's comm string.
      For a main thread, that is very probably wrong. Use the second-to-last
      in that case.
      
      This affects only db-export because it is the only user of
      thread__exec_comm().
      
      Example:
      
        $ sudo perf record -a -o pt-a-sleep-1 -e intel_pt//u -- sleep 1
        $ sudo chown ahunter pt-a-sleep-1
      
      Before:
      
        $ perf script -i pt-a-sleep-1 --itrace=bep -s tools/perf/scripts/python/export-to-sqlite.py pt-a-sleep-1.db branches calls
        $ sqlite3 -header -column pt-a-sleep-1.db 'select * from comm_threads_view'
        comm_id     command     thread_id   pid         tid
        ----------  ----------  ----------  ----------  ----------
        1           swapper     1           0           0
        2           rcu_sched   2           10          10
        3           kthreadd    3           78          78
        5           sudo        4           15180       15180
        5           sudo        5           15180       15182
        7           kworker/4:  6           10335       10335
        8           kthreadd    7           55          55
        10          systemd     8           865         865
        10          systemd     9           865         875
        13          perf        10          15181       15181
        15          sleep       10          15181       15181
        16          kworker/3:  11          14179       14179
        17          kthreadd    12          29376       29376
        19          systemd     13          746         746
        21          systemd     14          401         401
        23          systemd     15          879         879
        23          systemd     16          879         945
        25          kthreadd    17          556         556
        27          kworker/u1  18          14136       14136
        28          kworker/u1  19          15021       15021
        29          kthreadd    20          509         509
        31          systemd     21          836         836
        31          systemd     22          836         967
        33          systemd     23          1148        1148
        33          systemd     24          1148        1163
        35          kworker/2:  25          17988       17988
        36          kworker/0:  26          13478       13478
      
      After:
      
        $ perf script -i pt-a-sleep-1 --itrace=bep -s tools/perf/scripts/python/export-to-sqlite.py pt-a-sleep-1b.db branches calls
        $ sqlite3 -header -column pt-a-sleep-1b.db 'select * from comm_threads_view'
        comm_id     command     thread_id   pid         tid
        ----------  ----------  ----------  ----------  ----------
        1           swapper     1           0           0
        2           rcu_sched   2           10          10
        3           kswapd0     3           78          78
        4           perf        4           15180       15180
        4           perf        5           15180       15182
        6           kworker/4:  6           10335       10335
        7           kcompactd0  7           55          55
        8           accounts-d  8           865         865
        8           accounts-d  9           865         875
        10          perf        10          15181       15181
        12          sleep       10          15181       15181
        13          kworker/3:  11          14179       14179
        14          kworker/1:  12          29376       29376
        15          haveged     13          746         746
        16          systemd-jo  14          401         401
        17          NetworkMan  15          879         879
        17          NetworkMan  16          879         945
        19          irq/131-iw  17          556         556
        20          kworker/u1  18          14136       14136
        21          kworker/u1  19          15021       15021
        22          kworker/u1  20          509         509
        23          thermald    21          836         836
        23          thermald    22          836         967
        25          unity-sett  23          1148        1148
        25          unity-sett  24          1148        1163
        27          kworker/2:  25          17988       17988
        28          kworker/0:  26          13478       13478
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: stable@vger.kernel.org
      Fixes: 65de51f9 ("perf tools: Identify which comms are from exec")
      Link: http://lkml.kernel.org/r/20190808064823.14846-1-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f1f66289
    • Thomas Richter's avatar
      perf annotate: Fix s390 gap between kernel end and module start · 532db2b9
      Thomas Richter authored
      commit b9c0a649 upstream.
      
      During execution of command 'perf top' the error message:
      
         Not enough memory for annotating '__irf_end' symbol!)
      
      is emitted from this call sequence:
        __cmd_top
          perf_top__mmap_read
            perf_top__mmap_read_idx
              perf_event__process_sample
                hist_entry_iter__add
                  hist_iter__top_callback
                    perf_top__record_precise_ip
                      hist_entry__inc_addr_samples
                        symbol__inc_addr_samples
                          symbol__get_annotation
                            symbol__alloc_hist
      
      In this function the size of symbol __irf_end is calculated. The size of
      a symbol is the difference between its start and end address.
      
      When the symbol was read the first time, its start and end was set to:
      
         symbol__new: __irf_end 0xe954d0-0xe954d0
      
      which is correct and maps with /proc/kallsyms:
      
         root@s8360046:~/linux-4.15.0/tools/perf# fgrep _irf_end /proc/kallsyms
         0000000000e954d0 t __irf_end
         root@s8360046:~/linux-4.15.0/tools/perf#
      
      In function symbol__alloc_hist() the end of symbol __irf_end is
      
        symbol__alloc_hist sym:__irf_end start:0xe954d0 end:0x3ff80045a8
      
      which is identical with the first module entry in /proc/kallsyms
      
      This results in a symbol size of __irf_req for histogram analyses of
      70334140059072 bytes and a malloc() for this requested size fails.
      
      The root cause of this is function
        __dso__load_kallsyms()
        +-> symbols__fixup_end()
      
      Function symbols__fixup_end() enlarges the last symbol in the kallsyms
      map:
      
         # fgrep __irf_end /proc/kallsyms
         0000000000e954d0 t __irf_end
         #
      
      to the start address of the first module:
         # cat /proc/kallsyms | sort  | egrep ' [tT] '
         ....
         0000000000e952d0 T __security_initcall_end
         0000000000e954d0 T __initramfs_size
         0000000000e954d0 t __irf_end
         000003ff800045a8 T fc_get_event_number       [scsi_transport_fc]
         000003ff800045d0 t store_fc_vport_disable    [scsi_transport_fc]
         000003ff800046a8 T scsi_is_fc_rport  [scsi_transport_fc]
         000003ff800046d0 t fc_target_setup   [scsi_transport_fc]
      
      On s390 the kernel is located around memory address 0x200, 0x10000 or
      0x100000, depending on linux version. Modules however start some- where
      around 0x3ff xxxx xxxx.
      
      This is different than x86 and produces a large gap for which histogram
      allocation fails.
      
      Fix this by detecting the kernel's last symbol and do no adjustment for
      it. Introduce a weak function and handle s390 specifics.
      Reported-by: default avatarKlaus Theurich <klaus.theurich@de.ibm.com>
      Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Acked-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Hendrik Brueckner <brueckner@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: stable@vger.kernel.org
      Link: http://lkml.kernel.org/r/20190724122703.3996-2-tmricht@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      532db2b9
    • Joerg Roedel's avatar
      mm/vmalloc: Sync unmappings in __purge_vmap_area_lazy() · 46b306f3
      Joerg Roedel authored
      commit 3f8fd02b upstream.
      
      On x86-32 with PTI enabled, parts of the kernel page-tables are not shared
      between processes. This can cause mappings in the vmalloc/ioremap area to
      persist in some page-tables after the region is unmapped and released.
      
      When the region is re-used the processes with the old mappings do not fault
      in the new mappings but still access the old ones.
      
      This causes undefined behavior, in reality often data corruption, kernel
      oopses and panics and even spontaneous reboots.
      
      Fix this problem by activly syncing unmaps in the vmalloc/ioremap area to
      all page-tables in the system before the regions can be re-used.
      
      References: https://bugzilla.suse.com/show_bug.cgi?id=1118689
      Fixes: 5d72b4fb ('x86, mm: support huge I/O mapping capability I/F')
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
      Link: https://lkml.kernel.org/r/20190719184652.11391-4-joro@8bytes.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      46b306f3
    • Joerg Roedel's avatar
      x86/mm: Sync also unmappings in vmalloc_sync_all() · 9935d7ed
      Joerg Roedel authored
      commit 8e998fc2 upstream.
      
      With huge-page ioremap areas the unmappings also need to be synced between
      all page-tables. Otherwise it can cause data corruption when a region is
      unmapped and later re-used.
      
      Make the vmalloc_sync_one() function ready to sync unmappings and make sure
      vmalloc_sync_all() iterates over all page-tables even when an unmapped PMD
      is found.
      
      Fixes: 5d72b4fb ('x86, mm: support huge I/O mapping capability I/F')
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
      Link: https://lkml.kernel.org/r/20190719184652.11391-3-joro@8bytes.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9935d7ed
    • Joerg Roedel's avatar
      x86/mm: Check for pfn instead of page in vmalloc_sync_one() · dd524d48
      Joerg Roedel authored
      commit 51b75b5b upstream.
      
      Do not require a struct page for the mapped memory location because it
      might not exist. This can happen when an ioremapped region is mapped with
      2MB pages.
      
      Fixes: 5d72b4fb ('x86, mm: support huge I/O mapping capability I/F')
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
      Link: https://lkml.kernel.org/r/20190719184652.11391-2-joro@8bytes.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dd524d48
    • Dmitry Torokhov's avatar
      Input: synaptics - enable RMI mode for HP Spectre X360 · b8a2169b
      Dmitry Torokhov authored
      commit 25f8c834 upstream.
      
      The 2016 kabylake HP Spectre X360 (model number 13-w013dx) works much better
      with psmouse.synaptics_intertouch=1 kernel parameter, so let's enable RMI4
      mode automatically.
      
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204115Reported-by: default avatarNate Graham <pointedstick@zoho.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b8a2169b
    • Kai-Heng Feng's avatar
      Input: elantech - enable SMBus on new (2018+) systems · 3d180fe5
      Kai-Heng Feng authored
      commit 883a2a80 upstream.
      
      There are some new HP laptops with Elantech touchpad that don't support
      multitouch.
      
      Currently we use ETP_NEW_IC_SMBUS_HOST_NOTIFY() to check if SMBus is supported,
      but in addition to firmware version, the bus type also informs us whether the IC
      can support SMBus. To avoid breaking old ICs, we will only enable SMbus support
      based the bus type on systems manufactured after 2018.
      
      Lastly, let's consolidate all checks into elantech_use_host_notify() and use it
      to determine whether to use PS/2 or SMBus.
      Signed-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Acked-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3d180fe5
    • Oliver Neukum's avatar
      Input: usbtouchscreen - initialize PM mutex before using it · ce7d4fe4
      Oliver Neukum authored
      commit b55d996f upstream.
      
      Mutexes shall be initialized before they are used.
      
      Fixes: 12e510db ("Input: usbtouchscreen - fix deadlock in autosuspend")
      Reported-by: syzbot+199ea16c7f26418b4365@syzkaller.appspotmail.com
      Signed-off-by: default avatarOliver Neukum <oneukum@suse.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ce7d4fe4
    • Mikulas Patocka's avatar
      loop: set PF_MEMALLOC_NOIO for the worker thread · c9a1c104
      Mikulas Patocka authored
      commit d0a255e7 upstream.
      
      A deadlock with this stacktrace was observed.
      
      The loop thread does a GFP_KERNEL allocation, it calls into dm-bufio
      shrinker and the shrinker depends on I/O completion in the dm-bufio
      subsystem.
      
      In order to fix the deadlock (and other similar ones), we set the flag
      PF_MEMALLOC_NOIO at loop thread entry.
      
      PID: 474    TASK: ffff8813e11f4600  CPU: 10  COMMAND: "kswapd0"
         #0 [ffff8813dedfb938] __schedule at ffffffff8173f405
         #1 [ffff8813dedfb990] schedule at ffffffff8173fa27
         #2 [ffff8813dedfb9b0] schedule_timeout at ffffffff81742fec
         #3 [ffff8813dedfba60] io_schedule_timeout at ffffffff8173f186
         #4 [ffff8813dedfbaa0] bit_wait_io at ffffffff8174034f
         #5 [ffff8813dedfbac0] __wait_on_bit at ffffffff8173fec8
         #6 [ffff8813dedfbb10] out_of_line_wait_on_bit at ffffffff8173ff81
         #7 [ffff8813dedfbb90] __make_buffer_clean at ffffffffa038736f [dm_bufio]
         #8 [ffff8813dedfbbb0] __try_evict_buffer at ffffffffa0387bb8 [dm_bufio]
         #9 [ffff8813dedfbbd0] dm_bufio_shrink_scan at ffffffffa0387cc3 [dm_bufio]
        #10 [ffff8813dedfbc40] shrink_slab at ffffffff811a87ce
        #11 [ffff8813dedfbd30] shrink_zone at ffffffff811ad778
        #12 [ffff8813dedfbdc0] kswapd at ffffffff811ae92f
        #13 [ffff8813dedfbec0] kthread at ffffffff810a8428
        #14 [ffff8813dedfbf50] ret_from_fork at ffffffff81745242
      
        PID: 14127  TASK: ffff881455749c00  CPU: 11  COMMAND: "loop1"
         #0 [ffff88272f5af228] __schedule at ffffffff8173f405
         #1 [ffff88272f5af280] schedule at ffffffff8173fa27
         #2 [ffff88272f5af2a0] schedule_preempt_disabled at ffffffff8173fd5e
         #3 [ffff88272f5af2b0] __mutex_lock_slowpath at ffffffff81741fb5
         #4 [ffff88272f5af330] mutex_lock at ffffffff81742133
         #5 [ffff88272f5af350] dm_bufio_shrink_count at ffffffffa03865f9 [dm_bufio]
         #6 [ffff88272f5af380] shrink_slab at ffffffff811a86bd
         #7 [ffff88272f5af470] shrink_zone at ffffffff811ad778
         #8 [ffff88272f5af500] do_try_to_free_pages at ffffffff811adb34
         #9 [ffff88272f5af590] try_to_free_pages at ffffffff811adef8
        #10 [ffff88272f5af610] __alloc_pages_nodemask at ffffffff811a09c3
        #11 [ffff88272f5af710] alloc_pages_current at ffffffff811e8b71
        #12 [ffff88272f5af760] new_slab at ffffffff811f4523
        #13 [ffff88272f5af7b0] __slab_alloc at ffffffff8173a1b5
        #14 [ffff88272f5af880] kmem_cache_alloc at ffffffff811f484b
        #15 [ffff88272f5af8d0] do_blockdev_direct_IO at ffffffff812535b3
        #16 [ffff88272f5afb00] __blockdev_direct_IO at ffffffff81255dc3
        #17 [ffff88272f5afb30] xfs_vm_direct_IO at ffffffffa01fe3fc [xfs]
        #18 [ffff88272f5afb90] generic_file_read_iter at ffffffff81198994
        #19 [ffff88272f5afc50] __dta_xfs_file_read_iter_2398 at ffffffffa020c970 [xfs]
        #20 [ffff88272f5afcc0] lo_rw_aio at ffffffffa0377042 [loop]
        #21 [ffff88272f5afd70] loop_queue_work at ffffffffa0377c3b [loop]
        #22 [ffff88272f5afe60] kthread_worker_fn at ffffffff810a8a0c
        #23 [ffff88272f5afec0] kthread at ffffffff810a8428
        #24 [ffff88272f5aff50] ret_from_fork at ffffffff81745242
      Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c9a1c104
    • Kevin Hao's avatar
      mmc: cavium: Add the missing dma unmap when the dma has finished. · d79d76f2
      Kevin Hao authored
      commit b803974a upstream.
      
      This fixes the below calltrace when the CONFIG_DMA_API_DEBUG is enabled.
        DMA-API: thunderx_mmc 0000:01:01.4: cpu touching an active dma mapped cacheline [cln=0x000000002fdf9800]
        WARNING: CPU: 21 PID: 1 at kernel/dma/debug.c:596 debug_dma_assert_idle+0x1f8/0x270
        Modules linked in:
        CPU: 21 PID: 1 Comm: init Not tainted 5.3.0-rc1-next-20190725-yocto-standard+ #64
        Hardware name: Marvell OcteonTX CN96XX board (DT)
        pstate: 80400009 (Nzcv daif +PAN -UAO)
        pc : debug_dma_assert_idle+0x1f8/0x270
        lr : debug_dma_assert_idle+0x1f8/0x270
        sp : ffff0000113cfc10
        x29: ffff0000113cfc10 x28: 0000ffff8c880000
        x27: ffff800bc72a0000 x26: ffff000010ff8000
        x25: ffff000010ff8940 x24: ffff000010ff8968
        x23: 0000000000000000 x22: ffff000010e83700
        x21: ffff000010ea2000 x20: ffff000010e835c8
        x19: ffff800bc2c73300 x18: ffffffffffffffff
        x17: 0000000000000000 x16: 0000000000000000
        x15: ffff000010e835c8 x14: 6d20616d64206576
        x13: 69746361206e6120 x12: 676e696863756f74
        x11: 20757063203a342e x10: 31303a31303a3030
        x9 : 303020636d6d5f78 x8 : 3230303030303030
        x7 : 00000000000002fd x6 : ffff000010fd57d0
        x5 : 0000000000000000 x4 : ffff0000106c5210
        x3 : 00000000ffffffff x2 : 0000800bee9c0000
        x1 : 57d5843f4aa62800 x0 : 0000000000000000
        Call trace:
         debug_dma_assert_idle+0x1f8/0x270
         wp_page_copy+0xb0/0x688
         do_wp_page+0xa8/0x5b8
         __handle_mm_fault+0x600/0xd00
         handle_mm_fault+0x118/0x1e8
         do_page_fault+0x200/0x500
         do_mem_abort+0x50/0xb0
         el0_da+0x20/0x24
        ---[ end trace a005534bd23e109f ]---
        DMA-API: Mapped at:
         debug_dma_map_sg+0x94/0x350
         cvm_mmc_request+0x3c4/0x988
         __mmc_start_request+0x9c/0x1f8
         mmc_start_request+0x7c/0xb0
         mmc_blk_mq_issue_rq+0x5c4/0x7b8
      Signed-off-by: default avatarKevin Hao <haokexin@gmail.com>
      Fixes: ba3869ff ("mmc: cavium: Add core MMC driver for Cavium SOCs")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d79d76f2
    • Kevin Hao's avatar
      mmc: cavium: Set the correct dma max segment size for mmc_host · fd3f902d
      Kevin Hao authored
      commit fa25eba6 upstream.
      
      We have set the mmc_host.max_seg_size to 8M, but the dma max segment
      size of PCI device is set to 64K by default in function pci_device_add().
      The mmc_host.max_seg_size is used to set the max segment size of
      the blk queue. Then this mismatch will trigger a calltrace like below
      when a bigger than 64K segment request arrives at mmc dev. So we should
      consider the limitation of the cvm_mmc_host when setting the
      mmc_host.max_seg_size.
        DMA-API: thunderx_mmc 0000:01:01.4: mapping sg segment longer than device claims to support [len=131072] [max=65536]
        WARNING: CPU: 6 PID: 238 at kernel/dma/debug.c:1221 debug_dma_map_sg+0x2b8/0x350
        Modules linked in:
        CPU: 6 PID: 238 Comm: kworker/6:1H Not tainted 5.3.0-rc1-next-20190724-yocto-standard+ #62
        Hardware name: Marvell OcteonTX CN96XX board (DT)
        Workqueue: kblockd blk_mq_run_work_fn
        pstate: 80c00009 (Nzcv daif +PAN +UAO)
        pc : debug_dma_map_sg+0x2b8/0x350
        lr : debug_dma_map_sg+0x2b8/0x350
        sp : ffff00001770f9e0
        x29: ffff00001770f9e0 x28: ffffffff00000000
        x27: 00000000ffffffff x26: ffff800bc2c73180
        x25: ffff000010e83700 x24: 0000000000000002
        x23: 0000000000000001 x22: 0000000000000001
        x21: 0000000000000000 x20: ffff800bc48ba0b0
        x19: ffff800bc97e8c00 x18: ffffffffffffffff
        x17: 0000000000000000 x16: 0000000000000000
        x15: ffff000010e835c8 x14: 6874207265676e6f
        x13: 6c20746e656d6765 x12: 7320677320676e69
        x11: 7070616d203a342e x10: 31303a31303a3030
        x9 : 303020636d6d5f78 x8 : 35363d78616d5b20
        x7 : 00000000000002fd x6 : ffff000010fd57dc
        x5 : 0000000000000000 x4 : ffff0000106c61f0
        x3 : 00000000ffffffff x2 : 0000800bee060000
        x1 : 7010678df3041a00 x0 : 0000000000000000
        Call trace:
         debug_dma_map_sg+0x2b8/0x350
         cvm_mmc_request+0x3c4/0x988
         __mmc_start_request+0x9c/0x1f8
         mmc_start_request+0x7c/0xb0
         mmc_blk_mq_issue_rq+0x5c4/0x7b8
         mmc_mq_queue_rq+0x11c/0x278
         blk_mq_dispatch_rq_list+0xb0/0x568
         blk_mq_do_dispatch_sched+0x6c/0x108
         blk_mq_sched_dispatch_requests+0x110/0x1b8
         __blk_mq_run_hw_queue+0xb0/0x118
         blk_mq_run_work_fn+0x28/0x38
         process_one_work+0x210/0x490
         worker_thread+0x48/0x458
         kthread+0x130/0x138
         ret_from_fork+0x10/0x1c
      Signed-off-by: default avatarKevin Hao <haokexin@gmail.com>
      Fixes: ba3869ff ("mmc: cavium: Add core MMC driver for Cavium SOCs")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fd3f902d
    • Wenwen Wang's avatar
      sound: fix a memory leak bug · 9575ba61
      Wenwen Wang authored
      commit c7cd7c74 upstream.
      
      In sound_insert_unit(), the controlling structure 's' is allocated through
      kmalloc(). Then it is added to the sound driver list by invoking
      __sound_insert_unit(). Later on, if __register_chrdev() fails, 's' is
      removed from the list through __sound_remove_unit(). If 'index' is not less
      than 0, -EBUSY is returned to indicate the error. However, 's' is not
      deallocated on this execution path, leading to a memory leak bug.
      
      To fix the above issue, free 's' before -EBUSY is returned.
      Signed-off-by: default avatarWenwen Wang <wenwen@cs.uga.edu>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9575ba61
    • Oliver Neukum's avatar
      usb: iowarrior: fix deadlock on disconnect · d397091d
      Oliver Neukum authored
      commit c468a8aa upstream.
      
      We have to drop the mutex before we close() upon disconnect()
      as close() needs the lock. This is safe to do by dropping the
      mutex as intfdata is already set to NULL, so open() will fail.
      
      Fixes: 03f36e88 ("USB: open disconnect race in iowarrior")
      Reported-by: syzbot+a64a382964bf6c71a9c0@syzkaller.appspotmail.com
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarOliver Neukum <oneukum@suse.com>
      Link: https://lore.kernel.org/r/20190808092728.23417-1-oneukum@suse.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d397091d
    • Gavin Li's avatar
      usb: usbfs: fix double-free of usb memory upon submiturb error · b43611cd
      Gavin Li authored
      commit c43f28df upstream.
      
      Upon an error within proc_do_submiturb(), dec_usb_memory_use_count()
      gets called once by the error handling tail and again by free_async().
      Remove the first call.
      Signed-off-by: default avatarGavin Li <git@thegavinli.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20190804235044.22327-1-gavinli@thegavinli.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b43611cd
    • Gary R Hook's avatar
      crypto: ccp - Ignore tag length when decrypting GCM ciphertext · 6dbc3b74
      Gary R Hook authored
      commit e2664ecb upstream.
      
      AES GCM input buffers for decryption contain AAD+CTEXT+TAG. Only
      decrypt the ciphertext, and use the tag for comparison.
      
      Fixes: 36cf515b ("crypto: ccp - Enable support for AES GCM on v5 CCPs")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarGary R Hook <gary.hook@amd.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6dbc3b74
    • Gary R Hook's avatar
      crypto: ccp - Add support for valid authsize values less than 16 · 30692ede
      Gary R Hook authored
      commit 9f00baf7 upstream.
      
      AES GCM encryption allows for authsize values of 4, 8, and 12-16 bytes.
      Validate the requested authsize, and retain it to save in the request
      context.
      
      Fixes: 36cf515b ("crypto: ccp - Enable support for AES GCM on v5 CCPs")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarGary R Hook <gary.hook@amd.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      30692ede
    • Gary R Hook's avatar
      crypto: ccp - Fix oops by properly managing allocated structures · 1c4393df
      Gary R Hook authored
      commit 25e44338 upstream.
      
      A plaintext or ciphertext length of 0 is allowed in AES, in which case
      no encryption occurs. Ensure that we don't clean up data structures
      that were never allocated.
      
      Fixes: 36cf515b ("crypto: ccp - Enable support for AES GCM on v5 CCPs")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarGary R Hook <gary.hook@amd.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1c4393df
    • Tetsuo Handa's avatar
      staging: android: ion: Bail out upon SIGKILL when allocating memory. · b9de2157
      Tetsuo Handa authored
      commit 8f9e86ee upstream.
      
      syzbot found that a thread can stall for minutes inside
      ion_system_heap_allocate() after that thread was killed by SIGKILL [1].
      Let's check for SIGKILL before doing memory allocation.
      
      [1] https://syzkaller.appspot.com/bug?id=a0e3436829698d5824231251fad9d8e998f94f5eSigned-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: stable <stable@vger.kernel.org>
      Reported-by: default avatarsyzbot <syzbot+8ab2d0f39fb79fe6ca40@syzkaller.appspotmail.com>
      Acked-by: default avatarLaura Abbott <labbott@redhat.com>
      Acked-by: default avatarSumit Semwal <sumit.semwal@linaro.org>
      Link: https://lore.kernel.org/r/d088f188-5f32-d8fc-b9a0-0b404f7501cc@I-love.SAKURA.ne.jpSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b9de2157