1. 16 8月, 2019 40 次提交
    • M
      nvme: fix multipath crash when ANA is deactivated · bdce5621
      Marta Rybczynska 提交于
      [ Upstream commit 66b20ac0a1a10769d059d6903202f53494e3d902 ]
      
      Fix a crash with multipath activated. It happends when ANA log
      page is larger than MDTS and because of that ANA is disabled.
      The driver then tries to access unallocated buffer when connecting
      to a nvme target. The signature is as follows:
      
      [  300.433586] nvme nvme0: ANA log page size (8208) larger than MDTS (8192).
      [  300.435387] nvme nvme0: disabling ANA support.
      [  300.437835] nvme nvme0: creating 4 I/O queues.
      [  300.459132] nvme nvme0: new ctrl: NQN "nqn.0.0.0", addr 10.91.0.1:8009
      [  300.464609] BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
      [  300.466342] #PF error: [normal kernel read fault]
      [  300.467385] PGD 0 P4D 0
      [  300.467987] Oops: 0000 [#1] SMP PTI
      [  300.468787] CPU: 3 PID: 50 Comm: kworker/u8:1 Not tainted 5.0.20kalray+ #4
      [  300.470264] Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
      [  300.471532] Workqueue: nvme-wq nvme_scan_work [nvme_core]
      [  300.472724] RIP: 0010:nvme_parse_ana_log+0x21/0x140 [nvme_core]
      [  300.474038] Code: 45 01 d2 d8 48 98 c3 66 90 0f 1f 44 00 00 41 57 41 56 41 55 41 54 55 53 48 89 fb 48 83 ec 08 48 8b af 20 0a 00 00 48 89 34 24 <66> 83 7d 08 00 0f 84 c6 00 00 00 44 8b 7d 14 49 89 d5 8b 55 10 48
      [  300.477374] RSP: 0018:ffffa50e80fd7cb8 EFLAGS: 00010296
      [  300.478334] RAX: 0000000000000001 RBX: ffff9130f1872258 RCX: 0000000000000000
      [  300.479784] RDX: ffffffffc06c4c30 RSI: ffff9130edad4280 RDI: ffff9130f1872258
      [  300.481488] RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000044
      [  300.483203] R10: 0000000000000220 R11: 0000000000000040 R12: ffff9130f18722c0
      [  300.484928] R13: ffff9130f18722d0 R14: ffff9130edad4280 R15: ffff9130f18722c0
      [  300.486626] FS:  0000000000000000(0000) GS:ffff9130f7b80000(0000) knlGS:0000000000000000
      [  300.488538] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  300.489907] CR2: 0000000000000008 CR3: 00000002365e6000 CR4: 00000000000006e0
      [  300.491612] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [  300.493303] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [  300.494991] Call Trace:
      [  300.495645]  nvme_mpath_add_disk+0x5c/0xb0 [nvme_core]
      [  300.496880]  nvme_validate_ns+0x2ef/0x550 [nvme_core]
      [  300.498105]  ? nvme_identify_ctrl.isra.45+0x6a/0xb0 [nvme_core]
      [  300.499539]  nvme_scan_work+0x2b4/0x370 [nvme_core]
      [  300.500717]  ? __switch_to_asm+0x35/0x70
      [  300.501663]  process_one_work+0x171/0x380
      [  300.502340]  worker_thread+0x49/0x3f0
      [  300.503079]  kthread+0xf8/0x130
      [  300.503795]  ? max_active_store+0x80/0x80
      [  300.504690]  ? kthread_bind+0x10/0x10
      [  300.505502]  ret_from_fork+0x35/0x40
      [  300.506280] Modules linked in: nvme_tcp nvme_rdma rdma_cm iw_cm ib_cm ib_core nvme_fabrics nvme_core xt_physdev ip6table_raw ip6table_mangle ip6table_filter ip6_tables xt_comment iptable_nat nf_nat_ipv4 nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 xt_CHECKSUM iptable_mangle iptable_filter veth ebtable_filter ebtable_nat ebtables iptable_raw vxlan ip6_udp_tunnel udp_tunnel sunrpc joydev pcspkr virtio_balloon br_netfilter bridge stp llc ip_tables xfs libcrc32c ata_generic pata_acpi virtio_net virtio_console net_failover virtio_blk failover ata_piix serio_raw libata virtio_pci virtio_ring virtio
      [  300.514984] CR2: 0000000000000008
      [  300.515569] ---[ end trace faa2eefad7e7f218 ]---
      [  300.516354] RIP: 0010:nvme_parse_ana_log+0x21/0x140 [nvme_core]
      [  300.517330] Code: 45 01 d2 d8 48 98 c3 66 90 0f 1f 44 00 00 41 57 41 56 41 55 41 54 55 53 48 89 fb 48 83 ec 08 48 8b af 20 0a 00 00 48 89 34 24 <66> 83 7d 08 00 0f 84 c6 00 00 00 44 8b 7d 14 49 89 d5 8b 55 10 48
      [  300.520353] RSP: 0018:ffffa50e80fd7cb8 EFLAGS: 00010296
      [  300.521229] RAX: 0000000000000001 RBX: ffff9130f1872258 RCX: 0000000000000000
      [  300.522399] RDX: ffffffffc06c4c30 RSI: ffff9130edad4280 RDI: ffff9130f1872258
      [  300.523560] RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000044
      [  300.524734] R10: 0000000000000220 R11: 0000000000000040 R12: ffff9130f18722c0
      [  300.525915] R13: ffff9130f18722d0 R14: ffff9130edad4280 R15: ffff9130f18722c0
      [  300.527084] FS:  0000000000000000(0000) GS:ffff9130f7b80000(0000) knlGS:0000000000000000
      [  300.528396] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  300.529440] CR2: 0000000000000008 CR3: 00000002365e6000 CR4: 00000000000006e0
      [  300.530739] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [  300.531989] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [  300.533264] Kernel panic - not syncing: Fatal exception
      [  300.534338] Kernel Offset: 0x17c00000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)
      [  300.536227] ---[ end Kernel panic - not syncing: Fatal exception ]---
      
      Condition check refactoring from Christoph Hellwig.
      Signed-off-by: NMarta Rybczynska <marta.rybczynska@kalray.eu>
      Tested-by: NJean-Baptiste Riaux <jbriaux@kalray.eu>
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      bdce5621
    • L
      ACPI/IORT: Fix off-by-one check in iort_dev_find_its_id() · b1689742
      Lorenzo Pieralisi 提交于
      [ Upstream commit 5a46d3f71d5e5a9f82eabc682f996f1281705ac7 ]
      
      Static analysis identified that index comparison against ITS entries in
      iort_dev_find_its_id() is off by one.
      
      Update the comparison condition and clarify the resulting error
      message.
      
      Fixes: 4bf2efd2 ("ACPI: Add new IORT functions to support MSI domain handling")
      Link: https://lore.kernel.org/linux-arm-kernel/20190613065410.GB16334@mwanda/Reviewed-by: NHanjun Guo <guohanjun@huawei.com>
      Reported-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Hanjun Guo <guohanjun@huawei.com>
      Cc: Sudeep Holla <sudeep.holla@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Signed-off-by: NWill Deacon <will@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      b1689742
    • A
      drbd: dynamically allocate shash descriptor · 38c919ec
      Arnd Bergmann 提交于
      [ Upstream commit 77ce56e2bfaa64127ae5e23ef136c0168b818777 ]
      
      Building with clang and KASAN, we get a warning about an overly large
      stack frame on 32-bit architectures:
      
      drivers/block/drbd/drbd_receiver.c:921:31: error: stack frame size of 1280 bytes in function 'conn_connect'
            [-Werror,-Wframe-larger-than=]
      
      We already allocate other data dynamically in this function, so
      just do the same for the shash descriptor, which makes up most of
      this memory.
      
      Link: https://lore.kernel.org/lkml/20190617132440.2721536-1-arnd@arndb.de/Reviewed-by: NKees Cook <keescook@chromium.org>
      Reviewed-by: NRoland Kammerer <roland.kammerer@linbit.com>
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      38c919ec
    • A
      perf probe: Avoid calling freeing routine multiple times for same pointer · f4e2d182
      Arnaldo Carvalho de Melo 提交于
      [ Upstream commit d95daf5accf4a72005daa13fbb1d1bd8709f2861 ]
      
      When perf_add_probe_events() we call cleanup_perf_probe_events() for the
      pev pointer it receives, then, as part of handling this failure the main
      'perf probe' goes on and calls cleanup_params() and that will again call
      cleanup_perf_probe_events()for the same pointer, so just set nevents to
      zero when handling the failure of perf_add_probe_events() to avoid the
      double free.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-x8qgma4g813z96dvtw9w219q@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      f4e2d182
    • J
      perf tools: Fix proper buffer size for feature processing · 101a1554
      Jiri Olsa 提交于
      [ Upstream commit 79b2fe5e756163897175a8f57d66b26cd9befd59 ]
      
      After Song Liu's segfault fix for pipe mode, Arnaldo reported following
      error:
      
        # perf record -o - | perf script
        0x514 [0x1ac]: failed to process type: 80
      
      It's caused by wrong buffer size setup in feature processing, which
      makes cpu topology feature fail, because it's using buffer size to
      recognize its header version.
      Reported-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Carrillo-Cisneros <davidcc@google.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Fixes: e9def1b2 ("perf tools: Add feature header record to pipe-mode")
      Link: http://lkml.kernel.org/r/20190715140426.32509-1-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      101a1554
    • C
      ALSA: compress: Be more restrictive about when a drain is allowed · b065f404
      Charles Keepax 提交于
      [ Upstream commit 3b8179944cb0dd53e5223996966746cdc8a60657 ]
      
      Draining makes little sense in the situation of hardware overrun, as the
      hardware will have consumed all its available samples. Additionally,
      draining whilst the stream is paused would presumably get stuck as no
      data is being consumed on the DSP side.
      Signed-off-by: NCharles Keepax <ckeepax@opensource.cirrus.com>
      Acked-by: NVinod Koul <vkoul@kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      b065f404
    • C
      ALSA: compress: Don't allow paritial drain operations on capture streams · 30dd700d
      Charles Keepax 提交于
      [ Upstream commit a70ab8a8645083f3700814e757f2940a88b7ef88 ]
      
      Partial drain and next track are intended for gapless playback and
      don't really have an obvious interpretation for a capture stream, so
      makes sense to not allow those operations on capture streams.
      Signed-off-by: NCharles Keepax <ckeepax@opensource.cirrus.com>
      Acked-by: NVinod Koul <vkoul@kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      30dd700d
    • C
      ALSA: compress: Prevent bypasses of set_params · f1ea9a63
      Charles Keepax 提交于
      [ Upstream commit 26c3f1542f5064310ad26794c09321780d00c57d ]
      
      Currently, whilst in SNDRV_PCM_STATE_OPEN it is possible to call
      snd_compr_stop, snd_compr_drain and snd_compr_partial_drain, which
      allow a transition to SNDRV_PCM_STATE_SETUP. The stream should
      only be able to move to the setup state once it has received a
      SNDRV_COMPRESS_SET_PARAMS ioctl. Fix this issue by not allowing
      those ioctls whilst in the open state.
      Signed-off-by: NCharles Keepax <ckeepax@opensource.cirrus.com>
      Acked-by: NVinod Koul <vkoul@kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      f1ea9a63
    • C
      ALSA: compress: Fix regression on compressed capture streams · b9e2fa1e
      Charles Keepax 提交于
      [ Upstream commit 4475f8c4ab7b248991a60d9c02808dbb813d6be8 ]
      
      A previous fix to the stop handling on compressed capture streams causes
      some knock on issues. The previous fix updated snd_compr_drain_notify to
      set the state back to PREPARED for capture streams. This causes some
      issues however as the handling for snd_compr_poll differs between the
      two states and some user-space applications were relying on the poll
      failing after the stream had been stopped.
      
      To correct this regression whilst still fixing the original problem the
      patch was addressing, update the capture handling to skip the PREPARED
      state rather than skipping the SETUP state as it has done until now.
      
      Fixes: 4f2ab5e1d13d ("ALSA: compress: Fix stop handling on compressed capture streams")
      Signed-off-by: NCharles Keepax <ckeepax@opensource.cirrus.com>
      Acked-by: NVinod Koul <vkoul@kernel.org>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      b9e2fa1e
    • J
      s390/qdio: add sanity checks to the fast-requeue path · 77868c00
      Julian Wiedmann 提交于
      [ Upstream commit a6ec414a4dd529eeac5c3ea51c661daba3397108 ]
      
      If the device driver were to send out a full queue's worth of SBALs,
      current code would end up discovering the last of those SBALs as PRIMED
      and erroneously skip the SIGA-w. This immediately stalls the queue.
      
      Add a check to not attempt fast-requeue in this case. While at it also
      make sure that the state of the previous SBAL was successfully extracted
      before inspecting it.
      Signed-off-by: NJulian Wiedmann <jwi@linux.ibm.com>
      Reviewed-by: NJens Remus <jremus@linux.ibm.com>
      Signed-off-by: NHeiko Carstens <heiko.carstens@de.ibm.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      77868c00
    • W
      cpufreq/pasemi: fix use-after-free in pas_cpufreq_cpu_init() · 8729fe83
      Wen Yang 提交于
      [ Upstream commit e0a12445d1cb186d875410d093a00d215bec6a89 ]
      
      The cpu variable is still being used in the of_get_property() call
      after the of_node_put() call, which may result in use-after-free.
      
      Fixes: a9acc26b75f6 ("cpufreq/pasemi: fix possible object reference leak")
      Signed-off-by: NWen Yang <wen.yang99@zte.com.cn>
      Acked-by: NViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      8729fe83
    • Q
      drm: silence variable 'conn' set but not used · 991c4756
      Qian Cai 提交于
      [ Upstream commit bbb6fc43f131f77fcb7ae8081f6d7c51396a2120 ]
      
      The "struct drm_connector" iteration cursor from
      "for_each_new_connector_in_state" is never used in atomic_remove_fb()
      which generates a compilation warning,
      
      drivers/gpu/drm/drm_framebuffer.c: In function 'atomic_remove_fb':
      drivers/gpu/drm/drm_framebuffer.c:838:24: warning: variable 'conn' set
      but not used [-Wunused-but-set-variable]
      
      Silence it by marking "conn" __maybe_unused.
      Signed-off-by: NQian Cai <cai@lca.pw>
      Signed-off-by: NSean Paul <seanpaul@chromium.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/1563822886-13570-1-git-send-email-cai@lca.pwSigned-off-by: NSasha Levin <sashal@kernel.org>
      991c4756
    • B
      hwmon: (nct6775) Fix register address and added missed tolerance for nct6106 · ca1b1940
      Björn Gerhart 提交于
      [ Upstream commit f3d43e2e45fd9d44ba52d20debd12cd4ee9c89bf ]
      
      Fixed address of third NCT6106_REG_WEIGHT_DUTY_STEP, and
      added missed NCT6106_REG_TOLERANCE_H.
      
      Fixes: 6c009501 ("hwmon: (nct6775) Add support for NCT6102D/6106D")
      Signed-off-by: NBjoern Gerhart <gerhart@posteo.de>
      Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      ca1b1940
    • N
      allocate_flower_entry: should check for null deref · 56dc57c7
      Navid Emamdoost 提交于
      [ Upstream commit bb1320834b8a80c6ac2697ab418d066981ea08ba ]
      
      allocate_flower_entry does not check for allocation success, but tries
      to deref the result. I only moved the spin_lock under null check, because
       the caller is checking allocation's status at line 652.
      Signed-off-by: NNavid Emamdoost <navid.emamdoost@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      56dc57c7
    • B
      mac80211: don't warn about CW params when not using them · f4cfdd46
      Brian Norris 提交于
      [ Upstream commit d2b3fe42bc629c2d4002f652b3abdfb2e72991c7 ]
      
      ieee80211_set_wmm_default() normally sets up the initial CW min/max for
      each queue, except that it skips doing this if the driver doesn't
      support ->conf_tx. We still end up calling drv_conf_tx() in some cases
      (e.g., ieee80211_reconfig()), which also still won't do anything
      useful...except it complains here about the invalid CW parameters.
      
      Let's just skip the WARN if we weren't going to do anything useful with
      the parameters.
      Signed-off-by: NBrian Norris <briannorris@chromium.org>
      Link: https://lore.kernel.org/r/20190718015712.197499-1-briannorris@chromium.orgSigned-off-by: NJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      f4cfdd46
    • J
      nl80211: fix NL80211_HE_MAX_CAPABILITY_LEN · f2fd8981
      John Crispin 提交于
      [ Upstream commit 5edaac063bbf1267260ad2a5b9bb803399343e58 ]
      
      NL80211_HE_MAX_CAPABILITY_LEN has changed between D2.0 and D4.0. It is now
      MAC (6) + PHY (11) + MCS (12) + PPE (25) = 54.
      Signed-off-by: NJohn Crispin <john@phrozen.org>
      Link: https://lore.kernel.org/r/20190627095832.19445-1-john@phrozen.orgSigned-off-by: NJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      f2fd8981
    • T
      iscsi_ibft: make ISCSI_IBFT dependson ACPI instead of ISCSI_IBFT_FIND · 492c158a
      Thomas Tai 提交于
      [ Upstream commit 94bccc34071094c165c79b515d21b63c78f7e968 ]
      
      iscsi_ibft can use ACPI to find the iBFT entry during bootup,
      currently, ISCSI_IBFT depends on ISCSI_IBFT_FIND which is
      a X86 legacy way to find the iBFT by searching through the
      low memory. This patch changes the dependency so that other
      arch like ARM64 can use ISCSI_IBFT as long as the arch supports
      ACPI.
      
      ibft_init() needs to use the global variable ibft_addr declared
      in iscsi_ibft_find.c. A #ifndef CONFIG_ISCSI_IBFT_FIND is needed
      to declare the variable if CONFIG_ISCSI_IBFT_FIND is not selected.
      Moving ibft_addr into the iscsi_ibft.c does not work because if
      ISCSI_IBFT is selected as a module, the arch/x86/kernel/setup.c won't
      be able to find the variable at compile time.
      Signed-off-by: NThomas Tai <thomas.tai@oracle.com>
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      492c158a
    • T
      drm/amd/display: Increase size of audios array · 8d641499
      Tai Man 提交于
      [ Upstream commit 7352193a33dfc9b69ba3bf6a8caea925b96243b1 ]
      
      [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: NTai Man <taiman.wong@amd.com>
      Reviewed-by: NJoshua Aberback <Joshua.Aberback@amd.com>
      Acked-by: NLeo Li <sunpeng.li@amd.com>
      Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      8d641499
    • A
      drm/amd/display: Only enable audio if speaker allocation exists · f9420bfa
      Alvin Lee 提交于
      [ Upstream commit 6ac25e6d5b2fbf251e9fa2f4131d42c815b43867 ]
      
      [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: NAlvin Lee <alvin.lee2@amd.com>
      Reviewed-by: NJun Lei <Jun.Lei@amd.com>
      Acked-by: NLeo Li <sunpeng.li@amd.com>
      Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      f9420bfa
    • J
      drm/amd/display: Fix dc_create failure handling and 666 color depths · 3998e684
      Julian Parkin 提交于
      [ Upstream commit 0905f32977268149f06e3ce6ea4bd6d374dd891f ]
      
      [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: NJulian Parkin <julian.parkin@amd.com>
      Reviewed-by: NCharlene Liu <Charlene.Liu@amd.com>
      Acked-by: NLeo Li <sunpeng.li@amd.com>
      Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      3998e684
    • T
      drm/amd/display: use encoder's engine id to find matched free audio device · e7a8a794
      Tai Man 提交于
      [ Upstream commit 74eda776d7a4e69ec7aa1ce30a87636f14220fbb ]
      
      [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: NTai Man <taiman.wong@amd.com>
      Reviewed-by: NCharlene Liu <Charlene.Liu@amd.com>
      Acked-by: NLeo Li <sunpeng.li@amd.com>
      Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      e7a8a794
    • S
      drm/amd/display: Wait for backlight programming completion in set backlight level · 2a5e21ad
      SivapiriyanKumarasamy 提交于
      [ Upstream commit c7990daebe71d11a9e360b5c3b0ecd1846a3a4bb ]
      
      [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: NSivapiriyanKumarasamy <sivapiriyan.kumarasamy@amd.com>
      Reviewed-by: NAnthony Koo <Anthony.Koo@amd.com>
      Acked-by: NLeo Li <sunpeng.li@amd.com>
      Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      2a5e21ad
    • M
      scripts/sphinx-pre-install: fix script for RHEL/CentOS · 056af94d
      Mauro Carvalho Chehab 提交于
      [ Upstream commit b308467c916aa7acc5069802ab76a9f657434701 ]
      
      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: NMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      056af94d
    • L
      netfilter: nft_hash: fix symhash with modulus one · 36b6458d
      Laura Garcia Liebana 提交于
      [ Upstream commit 28b1d6ef53e3303b90ca8924bb78f31fa527cafb ]
      
      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: NLaura Garcia Liebana <nevola@gmail.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      36b6458d
    • F
      netfilter: conntrack: always store window size un-scaled · 6f1d7f0d
      Florian Westphal 提交于
      [ Upstream commit 959b69ef57db00cb33e9c4777400ae7183ebddd3 ]
      
      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: NJakub Jankowski <shasta@toxcorp.com>
      Tested-by: NJakub Jankowski <shasta@toxcorp.com>
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Acked-by: NJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      6f1d7f0d
    • M
      netfilter: Fix rpfilter dropping vrf packets by mistake · 307b6e5d
      Miaohe Lin 提交于
      [ Upstream commit b575b24b8eee37f10484e951b62ce2a31c579775 ]
      
      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: NMiaohe Lin <linmiaohe@huawei.com>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      307b6e5d
    • F
      vfio-ccw: Set pa_nr to 0 if memory allocation fails for pa_iova_pfn · 6f9dff8d
      Farhan Ali 提交于
      [ Upstream commit c1ab69268d124ebdbb3864580808188ccd3ea355 ]
      
      So we don't call try to call vfio_unpin_pages() incorrectly.
      
      Fixes: 0a19e61e ("vfio: ccw: introduce channel program interfaces")
      Signed-off-by: NFarhan Ali <alifm@linux.ibm.com>
      Reviewed-by: NEric Farman <farman@linux.ibm.com>
      Reviewed-by: NCornelia Huck <cohuck@redhat.com>
      Message-Id: <33a89467ad6369196ae6edf820cbcb1e2d8d050c.1562854091.git.alifm@linux.ibm.com>
      Signed-off-by: NCornelia Huck <cohuck@redhat.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      6f9dff8d
    • F
      netfilter: nfnetlink: avoid deadlock due to synchronous request_module · bb312b4a
      Florian Westphal 提交于
      [ Upstream commit 1b0890cd60829bd51455dc5ad689ed58c4408227 ]
      
      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: NThomas Jarosch <thomas.jarosch@intra2net.com>
      Reported-by: NJuliana Rodrigueiro <juliana.rodrigueiro@intra2net.com>
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      bb312b4a
    • S
      can: peak_usb: fix potential double kfree_skb() · f61c4d3a
      Stephane Grosjean 提交于
      commit fee6a8923ae0d318a7f7950c6c6c28a96cea099b 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: NStephane Grosjean <s.grosjean@peak-system.com>
      Cc: linux-stable <stable@vger.kernel.org>
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f61c4d3a
    • N
      can: rcar_canfd: fix possible IRQ storm on high load · 0e9038a2
      Nikita Yushchenko 提交于
      commit d4b890aec4bea7334ca2ca56fd3b12fb48a00cd1 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: NNikita Yushchenko <nikita.yoush@cogentembedded.com>
      Cc: linux-stable <stable@vger.kernel.org>
      Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0e9038a2
    • G
      usb: typec: tcpm: Ignore unsupported/unknown alternate mode requests · 9479a058
      Guenter Roeck 提交于
      commit 88d02c9ba2e83fc22d37ccb1f11c62ea6fc9ae50 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: NDouglas Gilbert <dgilbert@interlog.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Acked-by: NHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Tested-by: NDouglas Gilbert <dgilbert@interlog.com>
      Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
      Link: https://lore.kernel.org/r/1564761822-13984-1-git-send-email-linux@roeck-us.netSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9479a058
    • G
      usb: typec: tcpm: Add NULL check before dereferencing config · 3f524b63
      Guenter Roeck 提交于
      commit 1957de95d425d1c06560069dc7277a73a8b28683 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: NDouglas 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: NGuenter Roeck <linux@roeck-us.net>
      Cc: stable <stable@vger.kernel.org>
      Reviewed-by: NJun Li <jun.li@nxp.com>
      Reviewed-by: NHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Link: https://lore.kernel.org/r/1563979112-22483-1-git-send-email-linux@roeck-us.netSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3f524b63
    • L
      usb: typec: tcpm: remove tcpm dir if no children · bbc2e820
      Li Jun 提交于
      commit 12ca7297b8855c0af1848503d37196159b24e6b9 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: NLi Jun <jun.li@nxp.com>
      Reviewed-by: NGuenter Roeck <linux@roeck-us.net>
      Link: https://lore.kernel.org/r/20190717080646.30421-2-jun.li@nxp.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bbc2e820
    • L
      usb: typec: tcpm: free log buf memory when remove debug file · 2ec5c9b7
      Li Jun 提交于
      commit fd5da3e2cc61b4a7c877172fdc9348c82cf6ccfc 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: NLi Jun <jun.li@nxp.com>
      Reviewed-by: NGuenter Roeck <linux@roeck-us.net>
      Link: https://lore.kernel.org/r/20190717080646.30421-1-jun.li@nxp.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2ec5c9b7
    • S
      usb: yurex: Fix use-after-free in yurex_delete · 33f2240a
      Suzuki K Poulose 提交于
      commit fc05481b2fcabaaeccf63e32ac1baab54e5b6963 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: NSuzuki 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: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      33f2240a
    • Y
      usb: host: xhci-rcar: Fix timeout in xhci_suspend() · 49888a4f
      Yoshihiro Shimoda 提交于
      commit 783bda5e41acc71f98336e1a402c180f9748e5dc 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: NYoshihiro 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: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      49888a4f
    • A
      gfs2: gfs2_walk_metadata fix · 21344f05
      Andreas Gruenbacher 提交于
      commit a27a0c9b6a208722016c8ec5ad31ec96082b91ec 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: NAndreas Gruenbacher <agruenba@redhat.com>
      Reviewed-by: NBob Peterson <rpeterso@redhat.com>
      Cc: stable@vger.kernel.org # v4.18+
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      21344f05
    • N
      x86/purgatory: Use CFLAGS_REMOVE rather than reset KBUILD_CFLAGS · b674f791
      Nick Desaulniers 提交于
      commit b059f801a937d164e03b33c1848bb3dca67c0b04 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: NVaibhav Rustagi <vaibhavrustagi@google.com>
      Suggested-by: NPeter Zijlstra <peterz@infradead.org>
      Suggested-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Tested-by: NVaibhav Rustagi <vaibhavrustagi@google.com>
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/20190807221539.94583-2-ndesaulniers@google.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b674f791
    • T
      perf record: Fix module size on s390 · 0a9e41e2
      Thomas Richter 提交于
      commit 12a6d2940b5f02b4b9f71ce098e3bb02bc24a9ea 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: NStefan Liebler <stli@linux.ibm.com>
      Signed-off-by: NThomas Richter <tmricht@linux.ibm.com>
      Acked-by: NHeiko 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: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0a9e41e2
    • A
      perf db-export: Fix thread__exec_comm() · f1f66289
      Adrian Hunter 提交于
      commit 3de7ae0b2a1d86dbb23d0cb135150534fdb2e836 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: NAdrian 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: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f1f66289