1. 25 Mar, 2020 18 commits
    • Carlo Nonato's avatar
      block, bfq: fix overwrite of bfq_group pointer in bfq_find_set_group() · 3cbfc33d
      Carlo Nonato authored
      [ Upstream commit 14afc593 ]
      
      The bfq_find_set_group() function takes as input a blkcg (which represents
      a cgroup) and retrieves the corresponding bfq_group, then it updates the
      bfq internal group hierarchy (see comments inside the function for why
      this is needed) and finally it returns the bfq_group.
      In the hierarchy update cycle, the pointer holding the correct bfq_group
      that has to be returned is mistakenly used to traverse the hierarchy
      bottom to top, meaning that in each iteration it gets overwritten with the
      parent of the current group. Since the update cycle stops at root's
      children (depth = 2), the overwrite becomes a problem only if the blkcg
      describes a cgroup at a hierarchy level deeper than that (depth > 2). In
      this case the root's child that happens to be also an ancestor of the
      correct bfq_group is returned. The main consequence is that processes
      contained in a cgroup at depth greater than 2 are wrongly placed in the
      group described above by BFQ.
      
      This commits fixes this problem by using a different bfq_group pointer in
      the update cycle in order to avoid the overwrite of the variable holding
      the original group reference.
      Reported-by: default avatarKwon Je Oh <kwonje.oh2@gmail.com>
      Signed-off-by: default avatarCarlo Nonato <carlo.nonato95@gmail.com>
      Signed-off-by: default avatarPaolo Valente <paolo.valente@linaro.org>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3cbfc33d
    • Dongli Zhang's avatar
      xenbus: req->err should be updated before req->state · c4e8290c
      Dongli Zhang authored
      [ Upstream commit 8130b9d5 ]
      
      This patch adds the barrier to guarantee that req->err is always updated
      before req->state.
      
      Otherwise, read_reply() would not return ERR_PTR(req->err) but
      req->body, when process_writes()->xb_write() is failed.
      Signed-off-by: default avatarDongli Zhang <dongli.zhang@oracle.com>
      Link: https://lore.kernel.org/r/20200303221423.21962-2-dongli.zhang@oracle.comReviewed-by: default avatarJulien Grall <jgrall@amazon.com>
      Signed-off-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c4e8290c
    • Dongli Zhang's avatar
      xenbus: req->body should be updated before req->state · d0f7d091
      Dongli Zhang authored
      [ Upstream commit 1b6a51e8 ]
      
      The req->body should be updated before req->state is updated and the
      order should be guaranteed by a barrier.
      
      Otherwise, read_reply() might return req->body = NULL.
      
      Below is sample callstack when the issue is reproduced on purpose by
      reordering the updates of req->body and req->state and adding delay in
      code between updates of req->state and req->body.
      
      [   22.356105] general protection fault: 0000 [#1] SMP PTI
      [   22.361185] CPU: 2 PID: 52 Comm: xenwatch Not tainted 5.5.0xen+ #6
      [   22.366727] Hardware name: Xen HVM domU, BIOS ...
      [   22.372245] RIP: 0010:_parse_integer_fixup_radix+0x6/0x60
      ... ...
      [   22.392163] RSP: 0018:ffffb2d64023fdf0 EFLAGS: 00010246
      [   22.395933] RAX: 0000000000000000 RBX: 75746e7562755f6d RCX: 0000000000000000
      [   22.400871] RDX: 0000000000000000 RSI: ffffb2d64023fdfc RDI: 75746e7562755f6d
      [   22.405874] RBP: 0000000000000000 R08: 00000000000001e8 R09: 0000000000cdcdcd
      [   22.410945] R10: ffffb2d6402ffe00 R11: ffff9d95395eaeb0 R12: ffff9d9535935000
      [   22.417613] R13: ffff9d9526d4a000 R14: ffff9d9526f4f340 R15: ffff9d9537654000
      [   22.423726] FS:  0000000000000000(0000) GS:ffff9d953bc80000(0000) knlGS:0000000000000000
      [   22.429898] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   22.434342] CR2: 000000c4206a9000 CR3: 00000001ea3fc002 CR4: 00000000001606e0
      [   22.439645] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [   22.444941] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [   22.450342] Call Trace:
      [   22.452509]  simple_strtoull+0x27/0x70
      [   22.455572]  xenbus_transaction_start+0x31/0x50
      [   22.459104]  netback_changed+0x76c/0xcc1 [xen_netfront]
      [   22.463279]  ? find_watch+0x40/0x40
      [   22.466156]  xenwatch_thread+0xb4/0x150
      [   22.469309]  ? wait_woken+0x80/0x80
      [   22.472198]  kthread+0x10e/0x130
      [   22.474925]  ? kthread_park+0x80/0x80
      [   22.477946]  ret_from_fork+0x35/0x40
      [   22.480968] Modules linked in: xen_kbdfront xen_fbfront(+) xen_netfront xen_blkfront
      [   22.486783] ---[ end trace a9222030a747c3f7 ]---
      [   22.490424] RIP: 0010:_parse_integer_fixup_radix+0x6/0x60
      
      The virt_rmb() is added in the 'true' path of test_reply(). The "while"
      is changed to "do while" so that test_reply() is used as a read memory
      barrier.
      Signed-off-by: default avatarDongli Zhang <dongli.zhang@oracle.com>
      Link: https://lore.kernel.org/r/20200303221423.21962-1-dongli.zhang@oracle.comReviewed-by: default avatarJulien Grall <jgrall@amazon.com>
      Signed-off-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d0f7d091
    • Josip Pavic's avatar
      drm/amd/display: fix dcc swath size calculations on dcn1 · 345acf45
      Josip Pavic authored
      [ Upstream commit a0275dfc ]
      
      [Why]
      Swath sizes are being calculated incorrectly. The horizontal swath size
      should be the product of block height, viewport width, and bytes per
      element, but the calculation uses viewport height instead of width. The
      vertical swath size is similarly incorrectly calculated. The effect of
      this is that we report the wrong DCC caps.
      
      [How]
      Use viewport width in the horizontal swath size calculation and viewport
      height in the vertical swath size calculation.
      Signed-off-by: default avatarJosip Pavic <Josip.Pavic@amd.com>
      Reviewed-by: default avatarAric Cyr <Aric.Cyr@amd.com>
      Acked-by: default avatarRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      345acf45
    • Bhawanpreet Lakha's avatar
      drm/amd/display: Clear link settings on MST disable connector · f2580144
      Bhawanpreet Lakha authored
      [ Upstream commit 5ac7fd2f ]
      
      [Why]
      If we have a single MST display and we disconnect it, we dont disable that
      link. This causes the old link settings to still exist
      
      Now on a replug for MST we think its a link loss and will try to reallocate
      mst payload which will fail, throwing warning below.
      
      [  129.374192] [drm] Failed to updateMST allocation table forpipe idx:0
      [  129.374206] ------------[ cut here ]------------
      [  129.374284] WARNING: CPU: 14 PID: 1710 at
      drivers/gpu/drm/amd/amdgpu/../dal-dev/dc/core/dc_link.c:3153
      dc_link_allocate_mst_payload+0x1f7/0x220 [amdgpu]
      
      [  129.374285] Modules linked in: amdgpu(OE) amd_iommu_v2 gpu_sched ttm
      drm_kms_helper drm fb_sys_fops syscopyarea sysfillrect sysimgblt
      binfmt_misc nls_iso8859_1 edac_mce_amd snd_hda_codec_realtek
      snd_hda_codec_generic ledtrig_audio kvm snd_hda_codec_hdmi snd_hda_intel
      snd_intel_nhlt snd_hda_codec irqbypass snd_hda_core snd_hwdep snd_pcm
      snd_seq_midi snd_seq_midi_event snd_rawmidi crct10dif_pclmul snd_seq
      crc32_pclmul ghash_clmulni_intel snd_seq_device snd_timer snd aesni_intel
      eeepc_wmi crypto_simd asus_wmi joydev cryptd sparse_keymap input_leds
      soundcore video glue_helper wmi_bmof mxm_wmi k10temp ccp mac_hid
      sch_fq_codel parport_pc ppdev lp parport ip_tables x_tables autofs4
      hid_generic usbhid hid igb i2c_algo_bit ahci dca i2c_piix4 libahci
      gpio_amdpt wmi gpio_generic
      
      [  129.374318] CPU: 14 PID: 1710 Comm: kworker/14:2 Tainted: G        W  OE     5.4.0-rc7bhawan+ #480
      [  129.374318] Hardware name: System manufacturer System Product Name/PRIME X370-PRO, BIOS 0515 03/30/2017
      [  129.374397] Workqueue: events dm_irq_work_func [amdgpu]
      [  129.374468] RIP: 0010:dc_link_allocate_mst_payload+0x1f7/0x220 [amdgpu]
      [  129.374470] Code: 52 20 e8 1c 63 ad f4 48 8b 5d d0 65 48 33 1c 25 28 00
      00 00 b8 01 00 00 00 75 16 48 8d 65 d8 5b 41 5c 41 5d 41 5e 41 5f 5d c3
      <0f> 0b e9 fa fe ff ff e8 ed 5b d6 f3 41 0f b6 b6 c4 02 00 00 48 c7
      [  129.374471] RSP: 0018:ffff9f9141e7fcc0 EFLAGS: 00010246
      [  129.374472] RAX: 0000000000000000 RBX: ffff91ef0762f800 RCX: 0000000000000000
      [  129.374473] RDX: 0000000000000005 RSI: ffffffffc0c4a988 RDI: 0000000000000004
      [  129.374474] RBP: ffff9f9141e7fd10 R08: 0000000000000005 R09: 0000000000000000
      [  129.374475] R10: 0000000000000002 R11: 0000000000000001 R12: ffff91eebd510c00
      [  129.374475] R13: ffff91eebd510e58 R14: ffff91ef052c01b8 R15: 0000000000000006
      [  129.374476] FS:  0000000000000000(0000) GS:ffff91ef0ef80000(0000) knlGS:0000000000000000
      [  129.374477] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  129.374478] CR2: 000055623ea01d50 CR3: 0000000408a8c000 CR4: 00000000003406e0
      [  129.374479] Call Trace:
      [  129.374550]  dc_link_reallocate_mst_payload+0x12e/0x150 [amdgpu]
      [  129.374617]  dc_link_handle_hpd_rx_irq+0x6d4/0x6e0 [amdgpu]
      [  129.374693]  handle_hpd_rx_irq+0x77/0x310 [amdgpu]
      [  129.374768]  dm_irq_work_func+0x53/0x70 [amdgpu]
      [  129.374774]  process_one_work+0x1fd/0x3f0
      [  129.374776]  worker_thread+0x255/0x410
      [  129.374778]  kthread+0x121/0x140
      [  129.374780]  ? process_one_work+0x3f0/0x3f0
      [  129.374781]  ? kthread_park+0x90/0x90
      [  129.374785]  ret_from_fork+0x22/0x40
      
      [How]
      when we disable MST we should clear the cur link settings (lane_count=0 is
      good enough). This will cause us to not reallocate payloads earlier than
      expected and not throw the warning
      Signed-off-by: default avatarBhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
      Reviewed-by: default avatarHersen Wu <hersenxs.wu@amd.com>
      Acked-by: default avatarRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f2580144
    • Vincent Chen's avatar
      riscv: avoid the PIC offset of static percpu data in module beyond 2G limits · f70da80a
      Vincent Chen authored
      [ Upstream commit 0cff8bff ]
      
      The compiler uses the PIC-relative method to access static variables
      instead of GOT when the code model is PIC. Therefore, the limitation of
      the access range from the instruction to the symbol address is +-2GB.
      Under this circumstance, the kernel cannot load a kernel module if this
      module has static per-CPU symbols declared by DEFINE_PER_CPU(). The reason
      is that kernel relocates the .data..percpu section of the kernel module to
      the end of kernel's .data..percpu. Hence, the distance between the per-CPU
      symbols and the instruction will exceed the 2GB limits. To solve this
      problem, the kernel should place the loaded module in the memory area
      [&_end-2G, VMALLOC_END].
      Signed-off-by: default avatarVincent Chen <vincent.chen@sifive.com>
      Suggested-by: default avatarAlexandre Ghiti <alex@ghiti.fr>
      Suggested-by: default avatarAnup Patel <anup@brainfault.org>
      Tested-by: default avatarAlexandre Ghiti <alex@ghiti.fr>
      Tested-by: default avatarCarlos de Paula <me@carlosedp.com>
      Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f70da80a
    • Mike Snitzer's avatar
      dm integrity: use dm_bio_record and dm_bio_restore · 1ea3bdf9
      Mike Snitzer authored
      [ Upstream commit 248aa264 ]
      
      In cases where dec_in_flight() has to requeue the integrity_bio_wait
      work to transfer the rest of the data, the bio's __bi_remaining might
      already have been decremented to 0, e.g.: if bio passed to underlying
      data device was split via blk_queue_split().
      
      Use dm_bio_{record,restore} rather than effectively open-coding them in
      dm-integrity -- these methods now manage __bi_remaining too.
      
      Depends-on: f7f0b057a9c1 ("dm bio record: save/restore bi_end_io and bi_integrity")
      Reported-by: default avatarDaniel Glöckner <dg@emlix.com>
      Suggested-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1ea3bdf9
    • Mike Snitzer's avatar
      dm bio record: save/restore bi_end_io and bi_integrity · da23154f
      Mike Snitzer authored
      [ Upstream commit 1b17159e ]
      
      Also, save/restore __bi_remaining in case the bio was used in a
      BIO_CHAIN (e.g. due to blk_queue_split).
      Suggested-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      da23154f
    • Daniel Axtens's avatar
      altera-stapl: altera_get_note: prevent write beyond end of 'key' · 9cffdf96
      Daniel Axtens authored
      [ Upstream commit 3745488e ]
      
      altera_get_note is called from altera_init, where key is kzalloc(33).
      
      When the allocation functions are annotated to allow the compiler to see
      the sizes of objects, and with FORTIFY_SOURCE, we see:
      
      In file included from drivers/misc/altera-stapl/altera.c:14:0:
      In function ‘strlcpy’,
          inlined from ‘altera_init’ at drivers/misc/altera-stapl/altera.c:2189:5:
      include/linux/string.h:378:4: error: call to ‘__write_overflow’ declared with attribute error: detected write beyond size of object passed as 1st parameter
          __write_overflow();
          ^~~~~~~~~~~~~~~~~~
      
      That refers to this code in altera_get_note:
      
          if (key != NULL)
                  strlcpy(key, &p[note_strings +
                                  get_unaligned_be32(
                                  &p[note_table + (8 * i)])],
                          length);
      
      The error triggers because the length of 'key' is 33, but the copy
      uses length supplied as the 'length' parameter, which is always
      256. Split the size parameter into key_len and val_len, and use the
      appropriate length depending on what is being copied.
      
      Detected by compiler error, only compile-tested.
      
      Cc: "Igor M. Liplianin" <liplianin@netup.ru>
      Signed-off-by: default avatarDaniel Axtens <dja@axtens.net>
      Link: https://lore.kernel.org/r/20200120074344.504-2-dja@axtens.netSigned-off-by: default avatarKees Cook <keescook@chromium.org>
      Link: https://lore.kernel.org/r/202002251042.D898E67AC@keescookSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9cffdf96
    • luanshi's avatar
      drivers/perf: arm_pmu_acpi: Fix incorrect checking of gicc pointer · b3e9f82b
      luanshi authored
      [ Upstream commit 3ba52ad5 ]
      
      Fix bogus NULL checks on the return value of acpi_cpu_get_madt_gicc()
      by checking for a 0 'gicc->performance_interrupt' value instead.
      Signed-off-by: default avatarLiguang Zhang <zhangliguang@linux.alibaba.com>
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b3e9f82b
    • Marek Szyprowski's avatar
      drm/exynos: dsi: fix workaround for the legacy clock name · a832f5e0
      Marek Szyprowski authored
      [ Upstream commit c0fd99d6 ]
      
      Writing to the built-in strings arrays doesn't work if driver is loaded
      as kernel module. This is also considered as a bad pattern. Fix this by
      adding a call to clk_get() with legacy clock name. This fixes following
      kernel oops if driver is loaded as module:
      
      Unable to handle kernel paging request at virtual address bf047978
       pgd = (ptrval)
       [bf047978] *pgd=59344811, *pte=5903c6df, *ppte=5903c65f
       Internal error: Oops: 80f [#1] SMP ARM
       Modules linked in: mc exynosdrm(+) analogix_dp rtc_s3c exynos_ppmu i2c_gpio
       CPU: 1 PID: 212 Comm: systemd-udevd Not tainted 5.6.0-rc2-next-20200219 #326
       videodev: Linux video capture interface: v2.00
       Hardware name: Samsung Exynos (Flattened Device Tree)
       PC is at exynos_dsi_probe+0x1f0/0x384 [exynosdrm]
       LR is at exynos_dsi_probe+0x1dc/0x384 [exynosdrm]
       ...
       Process systemd-udevd (pid: 212, stack limit = 0x(ptrval))
       ...
       [<bf03cf14>] (exynos_dsi_probe [exynosdrm]) from [<c09b1ca0>] (platform_drv_probe+0x6c/0xa4)
       [<c09b1ca0>] (platform_drv_probe) from [<c09afcb8>] (really_probe+0x210/0x350)
       [<c09afcb8>] (really_probe) from [<c09aff74>] (driver_probe_device+0x60/0x1a0)
       [<c09aff74>] (driver_probe_device) from [<c09b0254>] (device_driver_attach+0x58/0x60)
       [<c09b0254>] (device_driver_attach) from [<c09b02dc>] (__driver_attach+0x80/0xbc)
       [<c09b02dc>] (__driver_attach) from [<c09ade00>] (bus_for_each_dev+0x68/0xb4)
       [<c09ade00>] (bus_for_each_dev) from [<c09aefd8>] (bus_add_driver+0x130/0x1e8)
       [<c09aefd8>] (bus_add_driver) from [<c09b0d64>] (driver_register+0x78/0x110)
       [<c09b0d64>] (driver_register) from [<bf038558>] (exynos_drm_init+0xe8/0x11c [exynosdrm])
       [<bf038558>] (exynos_drm_init [exynosdrm]) from [<c0302fa8>] (do_one_initcall+0x50/0x220)
       [<c0302fa8>] (do_one_initcall) from [<c03dd02c>] (do_init_module+0x60/0x210)
       [<c03dd02c>] (do_init_module) from [<c03dbf44>] (load_module+0x1c0c/0x2310)
       [<c03dbf44>] (load_module) from [<c03dc85c>] (sys_finit_module+0xac/0xbc)
       [<c03dc85c>] (sys_finit_module) from [<c0301000>] (ret_fast_syscall+0x0/0x54)
       Exception stack(0xd979bfa8 to 0xd979bff0)
       ...
       ---[ end trace db16efe05faab470 ]---
      Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
      Reviewed-by: default avatarAndrzej Hajda <a.hajda@samsung.com>
      Signed-off-by: default avatarInki Dae <inki.dae@samsung.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a832f5e0
    • Marek Szyprowski's avatar
      drm/exynos: dsi: propagate error value and silence meaningless warning · df263df8
      Marek Szyprowski authored
      [ Upstream commit 0a9d1e3f ]
      
      Properly propagate error value from devm_regulator_bulk_get() and don't
      confuse user with meaningless warning about failure in getting regulators
      in case of deferred probe.
      Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
      Reviewed-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
      Signed-off-by: default avatarInki Dae <inki.dae@samsung.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      df263df8
    • Thommy Jakobsson's avatar
      spi/zynqmp: remove entry that causes a cs glitch · 8be07044
      Thommy Jakobsson authored
      [ Upstream commit 5dd83049 ]
      
      In the public interface for chipselect, there is always an entry
      commented as "Dummy generic FIFO entry" pushed down to the fifo right
      after the activate/deactivate command. The dummy entry is 0x0,
      irregardless if the intention was to activate or deactive the cs. This
      causes the cs line to glitch rather than beeing activated in the case
      when there was an activate command.
      
      This has been observed on oscilloscope, and have caused problems for at
      least one specific flash device type connected to the qspi port. After
      the change the glitch is gone and cs goes active when intended.
      
      The reason why this worked before (except for the glitch) was because
      when sending the actual data, the CS bits are once again set. Since
      most flashes uses mode 0, there is always a half clk period anyway for
      cs to clk active setup time. If someone would rely on timing from a
      chip_select call to a transfer_one, it would fail though.
      
      It is unknown why the dummy entry was there in the first place, git log
      seems to be of no help in this case. The reference manual gives no
      indication of the necessity of this. In fact the lower 8 bits are a
      setup (or hold in case of deactivate) time expressed in cycles. So this
      should not be needed to fulfill any setup/hold timings.
      Signed-off-by: default avatarThommy Jakobsson <thommyj@gmail.com>
      Reviewed-by: default avatarNaga Sureshkumar Relli <naga.sureshkumar.relli@xilinx.com>
      Link: https://lore.kernel.org/r/20200224162643.29102-1-thommyj@gmail.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8be07044
    • Evan Green's avatar
      spi: pxa2xx: Add CS control clock quirk · 2ace1407
      Evan Green authored
      [ Upstream commit 683f65de ]
      
      In some circumstances on Intel LPSS controllers, toggling the LPSS
      CS control register doesn't actually cause the CS line to toggle.
      This seems to be failure of dynamic clock gating that occurs after
      going through a suspend/resume transition, where the controller
      is sent through a reset transition. This ruins SPI transactions
      that either rely on delay_usecs, or toggle the CS line without
      sending data.
      
      Whenever CS is toggled, momentarily set the clock gating register
      to "Force On" to poke the controller into acting on CS.
      Signed-off-by: default avatarRajat Jain <rajatja@google.com>
      Signed-off-by: default avatarEvan Green <evgreen@chromium.org>
      Link: https://lore.kernel.org/r/20200211223700.110252-1-rajatja@google.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2ace1407
    • Kishon Vijay Abraham I's avatar
      ARM: dts: dra7: Add "dma-ranges" property to PCIe RC DT nodes · 8cdbdc24
      Kishon Vijay Abraham I authored
      [ Upstream commit 27f13774 ]
      
      'dma-ranges' in a PCI bridge node does correctly set dma masks for PCI
      devices not described in the DT. Certain DRA7 platforms (e.g., DRA76)
      has RAM above 32-bit boundary (accessible with LPAE config) though the
      PCIe bridge will be able to access only 32-bits. Add 'dma-ranges'
      property in PCIe RC DT nodes to indicate the host bridge can access
      only 32 bits.
      Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
      Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8cdbdc24
    • Naveen N. Rao's avatar
      powerpc: Include .BTF section · 9a1d6966
      Naveen N. Rao authored
      [ Upstream commit cb0cc635 ]
      
      Selecting CONFIG_DEBUG_INFO_BTF results in the below warning from ld:
        ld: warning: orphan section `.BTF' from `.btf.vmlinux.bin.o' being placed in section `.BTF'
      
      Include .BTF section in vmlinux explicitly to fix the same.
      Signed-off-by: default avatarNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20200220113132.857132-1-naveen.n.rao@linux.vnet.ibm.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      9a1d6966
    • Yuji Sasaki's avatar
      spi: qup: call spi_qup_pm_resume_runtime before suspending · b84530ba
      Yuji Sasaki authored
      [ Upstream commit 136b5cd2 ]
      
      spi_qup_suspend() will cause synchronous external abort when
      runtime suspend is enabled and applied, as it tries to
      access SPI controller register while clock is already disabled
      in spi_qup_pm_suspend_runtime().
      Signed-off-by: default avatarYuji sasaki <sasakiy@chromium.org>
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Link: https://lore.kernel.org/r/20200214074340.2286170-1-vkoul@kernel.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b84530ba
    • Evan Benn's avatar
      drm/mediatek: Find the cursor plane instead of hard coding it · 21c6189d
      Evan Benn authored
      [ Upstream commit 318caac7 ]
      
      The cursor and primary planes were hard coded.
      Now search for them for passing to drm_crtc_init_with_planes
      Signed-off-by: default avatarEvan Benn <evanbenn@chromium.org>
      Reviewed-by: default avatarSean Paul <seanpaul@chromium.org>
      Signed-off-by: default avatarCK Hu <ck.hu@mediatek.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      21c6189d
  2. 20 Mar, 2020 22 commits
    • Greg Kroah-Hartman's avatar
      Linux 4.19.112 · 14cfdbd3
      Greg Kroah-Hartman authored
      14cfdbd3
    • Matteo Croce's avatar
      ipv4: ensure rcu_read_lock() in cipso_v4_error() · b4176d3b
      Matteo Croce authored
      commit 3e72dfdf upstream.
      
      Similarly to commit c543cb4a ("ipv4: ensure rcu_read_lock() in
      ipv4_link_failure()"), __ip_options_compile() must be called under rcu
      protection.
      
      Fixes: 3da1ed7a ("net: avoid use IPCB in cipso_v4_error")
      Suggested-by: default avatarGuillaume Nault <gnault@redhat.com>
      Signed-off-by: default avatarMatteo Croce <mcroce@redhat.com>
      Acked-by: default avatarPaul Moore <paul@paul-moore.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b4176d3b
    • Waiman Long's avatar
      efi: Fix debugobjects warning on 'efi_rts_work' · a44324b0
      Waiman Long authored
      commit ef1491e7 upstream.
      
      The following commit:
      
        9dbbedaa ("efi: Make efi_rts_work accessible to efi page fault handler")
      
      converted 'efi_rts_work' from an auto variable to a global variable.
      However, when submitting the work, INIT_WORK_ONSTACK() was still used,
      causing the following complaint from debugobjects:
      
        ODEBUG: object 00000000ed27b500 is NOT on stack 00000000c7d38760, but annotated.
      
      Change the macro to just INIT_WORK() to eliminate the warning.
      Signed-off-by: default avatarWaiman Long <longman@redhat.com>
      Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Acked-by: default avatarSai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-efi@vger.kernel.org
      Fixes: 9dbbedaa ("efi: Make efi_rts_work accessible to efi page fault handler")
      Link: http://lkml.kernel.org/r/20181114175544.12860-2-ard.biesheuvel@linaro.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a44324b0
    • Chen-Tsung Hsieh's avatar
      HID: google: add moonball USB id · 705d1b54
      Chen-Tsung Hsieh authored
      commit 58322a15 upstream.
      
      Add 1 additional hammer-like device.
      Signed-off-by: default avatarChen-Tsung Hsieh <chentsung@chromium.org>
      Reviewed-by: default avatarNicolas Boichat <drinkcat@chromium.org>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      705d1b54
    • Jann Horn's avatar
      mm: slub: add missing TID bump in kmem_cache_alloc_bulk() · 30f6cae7
      Jann Horn authored
      commit fd4d9c7d upstream.
      
      When kmem_cache_alloc_bulk() attempts to allocate N objects from a percpu
      freelist of length M, and N > M > 0, it will first remove the M elements
      from the percpu freelist, then call ___slab_alloc() to allocate the next
      element and repopulate the percpu freelist. ___slab_alloc() can re-enable
      IRQs via allocate_slab(), so the TID must be bumped before ___slab_alloc()
      to properly commit the freelist head change.
      
      Fix it by unconditionally bumping c->tid when entering the slowpath.
      
      Cc: stable@vger.kernel.org
      Fixes: ebe909e0 ("slub: improve bulk alloc strategy")
      Signed-off-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      30f6cae7
    • Kees Cook's avatar
      ARM: 8958/1: rename missed uaccess .fixup section · c1a9559a
      Kees Cook authored
      commit f87b1c49 upstream.
      
      When the uaccess .fixup section was renamed to .text.fixup, one case was
      missed. Under ld.bfd, the orphaned section was moved close to .text
      (since they share the "ax" bits), so things would work normally on
      uaccess faults. Under ld.lld, the orphaned section was placed outside
      the .text section, making it unreachable.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/282
      Link: https://bugs.chromium.org/p/chromium/issues/detail?id=1020633#c44
      Link: https://lore.kernel.org/r/nycvar.YSQ.7.76.1912032147340.17114@knanqh.ubzr
      Link: https://lore.kernel.org/lkml/202002071754.F5F073F1D@keescook/
      
      Fixes: c4a84ae3 ("ARM: 8322/1: keep .text and .fixup regions closer together")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c1a9559a
    • Florian Fainelli's avatar
      ARM: 8957/1: VDSO: Match ARMv8 timer in cntvct_functional() · 8cf58ea4
      Florian Fainelli authored
      commit 45939ce2 upstream.
      
      It is possible for a system with an ARMv8 timer to run a 32-bit kernel.
      When this happens we will unconditionally have the vDSO code remove the
      __vdso_gettimeofday and __vdso_clock_gettime symbols because
      cntvct_functional() returns false since it does not match that
      compatibility string.
      
      Fixes: ecf99a43 ("ARM: 8331/1: VDSO initialization, mapping, and synchronization")
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8cf58ea4
    • Carl Huang's avatar
      net: qrtr: fix len of skb_put_padto in qrtr_node_enqueue · bc97a345
      Carl Huang authored
      commit ce57785b upstream.
      
      The len used for skb_put_padto is wrong, it need to add len of hdr.
      
      In qrtr_node_enqueue, local variable size_t len is assign with
      skb->len, then skb_push(skb, sizeof(*hdr)) will add skb->len with
      sizeof(*hdr), so local variable size_t len is not same with skb->len
      after skb_push(skb, sizeof(*hdr)).
      
      Then the purpose of skb_put_padto(skb, ALIGN(len, 4)) is to add add
      pad to the end of the skb's data if skb->len is not aligned to 4, but
      unfortunately it use len instead of skb->len, at this line, skb->len
      is 32 bytes(sizeof(*hdr)) more than len, for example, len is 3 bytes,
      then skb->len is 35 bytes(3 + 32), and ALIGN(len, 4) is 4 bytes, so
      __skb_put_padto will do nothing after check size(35) < len(4), the
      correct value should be 36(sizeof(*hdr) + ALIGN(len, 4) = 32 + 4),
      then __skb_put_padto will pass check size(35) < len(36) and add 1 byte
      to the end of skb's data, then logic is correct.
      
      function of skb_push:
      void *skb_push(struct sk_buff *skb, unsigned int len)
      {
      	skb->data -= len;
      	skb->len  += len;
      	if (unlikely(skb->data < skb->head))
      		skb_under_panic(skb, len, __builtin_return_address(0));
      	return skb->data;
      }
      
      function of skb_put_padto
      static inline int skb_put_padto(struct sk_buff *skb, unsigned int len)
      {
      	return __skb_put_padto(skb, len, true);
      }
      
      function of __skb_put_padto
      static inline int __skb_put_padto(struct sk_buff *skb, unsigned int len,
      				  bool free_on_error)
      {
      	unsigned int size = skb->len;
      
      	if (unlikely(size < len)) {
      		len -= size;
      		if (__skb_pad(skb, len, free_on_error))
      			return -ENOMEM;
      		__skb_put(skb, len);
      	}
      	return 0;
      }
      Signed-off-by: default avatarCarl Huang <cjhuang@codeaurora.org>
      Signed-off-by: default avatarWen Gong <wgong@codeaurora.org>
      Cc: Doug Anderson <dianders@chromium.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bc97a345
    • Rafael J. Wysocki's avatar
      driver core: Fix creation of device links with PM-runtime flags · cda3bca0
      Rafael J. Wysocki authored
      commit fb583c8e upstream.
      
      After commit 515db266 ("driver core: Remove device link creation
      limitation"), if PM-runtime flags are passed to device_link_add(), it
      will fail (returning NULL) due to an overly restrictive flags check
      introduced by that commit.
      
      Fix this issue by extending the check in question to cover the
      PM-runtime flags too.
      
      Fixes: 515db266 ("driver core: Remove device link creation limitation")
      Reported-by: default avatarDmitry Osipenko <digetx@gmail.com>
      Tested-by: default avatarJon Hunter <jonathanh@nvidia.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: default avatarDmitry Osipenko <digetx@gmail.com>
      Tested-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
      Link: https://lore.kernel.org/r/7674989.cD04D8YV3U@kreacherSigned-off-by: default avatarSaravana Kannan <saravanak@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cda3bca0
    • Rafael J. Wysocki's avatar
      driver core: Remove device link creation limitation · 53a895ff
      Rafael J. Wysocki authored
      commit 515db266 upstream.
      
      If device_link_add() is called for a consumer/supplier pair with an
      existing device link between them and the existing link's type is
      not in agreement with the flags passed to that function by its
      caller, NULL will be returned.  That is seriously inconvenient,
      because it forces the callers of device_link_add() to worry about
      what others may or may not do even if that is not relevant to them
      for any other reasons.
      
      It turns out, however, that this limitation can be made go away
      relatively easily.
      
      The underlying observation is that if DL_FLAG_STATELESS has been
      passed to device_link_add() in flags for the given consumer/supplier
      pair at least once, calling either device_link_del() or
      device_link_remove() to release the link returned by it should work,
      but there are no other requirements associated with that flag.  In
      turn, if at least one of the callers of device_link_add() for the
      given consumer/supplier pair has not passed DL_FLAG_STATELESS to it
      in flags, the driver core should track the status of the link and act
      on it as appropriate (ie. the link should be treated as "managed").
      This means that DL_FLAG_STATELESS needs to be set for managed device
      links and it should be valid to call device_link_del() or
      device_link_remove() to drop references to them in certain
      sutiations.
      
      To allow that to happen, introduce a new (internal) device link flag
      called DL_FLAG_MANAGED and make device_link_add() set it automatically
      whenever DL_FLAG_STATELESS is not passed to it.  Also make it take
      additional references to existing device links that were previously
      stateless (that is, with DL_FLAG_STATELESS set and DL_FLAG_MANAGED
      unset) and will need to be managed going forward and initialize
      their status (which has been DL_STATE_NONE so far).
      
      Accordingly, when a managed device link is dropped automatically
      by the driver core, make it clear DL_FLAG_MANAGED, reset the link's
      status back to DL_STATE_NONE and drop the reference to it associated
      with DL_FLAG_MANAGED instead of just deleting it right away (to
      allow it to stay around in case it still needs to be released
      explicitly by someone).
      
      With that, since setting DL_FLAG_STATELESS doesn't mean that the
      device link in question is not managed any more, replace all of the
      status-tracking checks against DL_FLAG_STATELESS with analogous
      checks against DL_FLAG_MANAGED and update the documentation to
      reflect these changes.
      
      While at it, make device_link_add() reject flags that it does not
      recognize, including DL_FLAG_MANAGED.
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Reviewed-by: default avatarSaravana Kannan <saravanak@google.com>
      Tested-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
      Review-by: default avatarSaravana Kannan <saravanak@google.com>
      Link: https://lore.kernel.org/r/2305283.AStDPdUUnE@kreacherSigned-off-by: default avatarSaravana Kannan <saravanak@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      53a895ff
    • Rafael J. Wysocki's avatar
      driver core: Add device link flag DL_FLAG_AUTOPROBE_CONSUMER · 822e87b7
      Rafael J. Wysocki authored
      commit e7dd4010 upstream.
      
      Add a new device link flag, DL_FLAG_AUTOPROBE_CONSUMER, to request the
      driver core to probe for a consumer driver automatically after binding
      a driver to the supplier device on a persistent managed device link.
      
      As unbinding the supplier driver on a managed device link causes the
      consumer driver to be detached from its device automatically, this
      flag provides a complementary mechanism which is needed to address
      some "composite device" use cases.
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarSaravana Kannan <saravanak@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      822e87b7
    • Rafael J. Wysocki's avatar
      driver core: Make driver core own stateful device links · 1f5102cb
      Rafael J. Wysocki authored
      commit 72175d4e upstream.
      
      Even though stateful device links are managed by the driver core in
      principle, their creators are allowed and sometimes even expected
      to drop references to them via device_link_del() or
      device_link_remove(), but that doesn't really play well with the
      "persistent" link concept.
      
      If "persistent" managed device links are created from driver
      probe callbacks, device_link_add() called to do that will take a
      new reference on the link each time the callback runs and those
      references will never be dropped, which kind of isn't nice.
      
      This issues arises because of the link reference counting carried
      out by device_link_add() for existing links, but that is only done to
      avoid deleting device links that may still be necessary, which
      shouldn't be a concern for managed (stateful) links.  These device
      links are managed by the driver core and whoever creates one of them
      will need it at least as long as until the consumer driver is detached
      from its device and deleting it may be left to the driver core just
      fine.
      
      For this reason, rework device_link_add() to apply the reference
      counting to stateless links only and make device_link_del() and
      device_link_remove() drop references to stateless links only too.
      After this change, if called to add a stateful device link for
      a consumer-supplier pair for which a stateful device link is
      present already, device_link_add() will return the existing link
      without incrementing its reference counter.  Accordingly,
      device_link_del() and device_link_remove() will WARN() and do
      nothing when called to drop a reference to a stateful link.  Thus,
      effectively, all stateful device links will be owned by the driver
      core.
      
      In addition, clean up the handling of the link management flags,
      DL_FLAG_AUTOREMOVE_CONSUMER and DL_FLAG_AUTOREMOVE_SUPPLIER, so that
      (a) they are never set at the same time and (b) if device_link_add()
      is called for a consumer-supplier pair with an existing stateful link
      between them, the flags of that link will be combined with the flags
      passed to device_link_add() to ensure that the life time of the link
      is sufficient for all of the callers of device_link_add() for the
      same consumer-supplier pair.
      
      Update the device_link_add() kerneldoc comment to reflect the
      above changes.
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarSaravana Kannan <saravanak@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1f5102cb
    • Rafael J. Wysocki's avatar
      driver core: Fix adding device links to probing suppliers · 1c89b531
      Rafael J. Wysocki authored
      commit 15cfb094 upstream.
      
      Currently, it is not valid to add a device link from a consumer
      driver ->probe callback to a supplier that is still probing too, but
      generally this is a valid use case.  For example, if the consumer has
      just acquired a resource that can only be available if the supplier
      is functional, adding a device link to that supplier right away
      should be safe (and even desirable arguably), but device_link_add()
      doesn't handle that case correctly and the initial state of the link
      created by it is wrong then.
      
      To address this problem, change the initial state of device links
      added between a probing supplier and a probing consumer to
      DL_STATE_CONSUMER_PROBE and update device_links_driver_bound() to
      skip such links on the supplier side.
      
      With this change, if the supplier probe completes first,
      device_links_driver_bound() called for it will skip the link state
      update and when it is called for the consumer, the link state will
      be updated to "active".  In turn, if the consumer probe completes
      first, device_links_driver_bound() called for it will change the
      state of the link to "active" and when it is called for the
      supplier, the link status update will be skipped.
      
      However, in principle the supplier or consumer probe may still fail
      after the link has been added, so modify device_links_no_driver() to
      change device links in the "active" or "consumer probe" state to
      "dormant" on the supplier side and update __device_links_no_driver()
      to change the link state to "available" only if it is "consumer
      probe" or "active".
      
      Then, if the supplier probe fails first, the leftover link to the
      probing consumer will become "dormant" and device_links_no_driver()
      called for the consumer (when its probe fails) will clean it up.
      In turn, if the consumer probe fails first, it will either drop the
      link, or change its state to "available" and, in the latter case,
      when device_links_no_driver() is called for the supplier, it will
      update the link state to "dormant".  [If the supplier probe fails,
      but the consumer probe succeeds, which should not happen as long as
      the consumer driver is correct, the link still will be around, but
      it will be "dormant" until the supplier is probed again.]
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarSaravana Kannan <saravanak@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1c89b531
    • Yong Wu's avatar
      driver core: Remove the link if there is no driver with AUTO flag · b600c5a1
      Yong Wu authored
      commit 0fe6f787 upstream.
      
      DL_FLAG_AUTOREMOVE_CONSUMER/SUPPLIER means "Remove the link
      automatically on consumer/supplier driver unbind", that means we should
      remove whole the device_link when there is no this driver no matter what
      the ref_count of the link is.
      
      CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarYong Wu <yong.wu@mediatek.com>
      Signed-off-by: default avatarSaravana Kannan <saravanak@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b600c5a1
    • Faiz Abbas's avatar
      mmc: sdhci-omap: Fix Tuning procedure for temperatures < -20C · 6bdf6513
      Faiz Abbas authored
      [ Upstream commit feb40824 ]
      
      According to the App note[1] detailing the tuning algorithm, for
      temperatures < -20C, the initial tuning value should be min(largest value
      in LPW - 24, ceil(13/16 ratio of LPW)). The largest value in LPW is
      (max_window + 4 * (max_len - 1)) and not (max_window + 4 * max_len) itself.
      Fix this implementation.
      
      [1] http://www.ti.com/lit/an/spraca9b/spraca9b.pdf
      
      Fixes: 961de0a8 ("mmc: sdhci-omap: Workaround errata regarding SDR104/HS200 tuning failures (i929)")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarFaiz Abbas <faiz_abbas@ti.com>
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6bdf6513
    • Faiz Abbas's avatar
      mmc: sdhci-omap: Don't finish_mrq() on a command error during tuning · 3f909e15
      Faiz Abbas authored
      [ Upstream commit 5c41ea6d ]
      
      commit 5b0d6210 ("mmc: sdhci-omap: Add platform specific reset
      callback") skips data resets during tuning operation. Because of this,
      a data error or data finish interrupt might still arrive after a command
      error has been handled and the mrq ended. This ends up with a "mmc0: Got
      data interrupt 0x00000002 even though no data operation was in progress"
      error message.
      
      Fix this by adding a platform specific callback for sdhci_irq. Mark the
      mrq as a failure but wait for a data interrupt instead of calling
      finish_mrq().
      
      Fixes: 5b0d6210 ("mmc: sdhci-omap: Add platform specific reset
      callback")
      Signed-off-by: default avatarFaiz Abbas <faiz_abbas@ti.com>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3f909e15
    • Navid Emamdoost's avatar
      wimax: i2400: Fix memory leak in i2400m_op_rfkill_sw_toggle · dfb82701
      Navid Emamdoost authored
      [ Upstream commit 6f3ef5c2 ]
      
      In the implementation of i2400m_op_rfkill_sw_toggle() the allocated
      buffer for cmd should be released before returning. The
      documentation for i2400m_msg_to_dev() says when it returns the buffer
      can be reused. Meaning cmd should be released in either case. Move
      kfree(cmd) before return to be reached by all execution paths.
      
      Fixes: 2507e6ab ("wimax: i2400: fix memory leak")
      Signed-off-by: default avatarNavid Emamdoost <navid.emamdoost@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      dfb82701
    • Navid Emamdoost's avatar
      wimax: i2400: fix memory leak · dd5a1463
      Navid Emamdoost authored
      [ Upstream commit 2507e6ab ]
      
      In i2400m_op_rfkill_sw_toggle cmd buffer should be released along with
      skb response.
      Signed-off-by: default avatarNavid Emamdoost <navid.emamdoost@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      dd5a1463
    • Qian Cai's avatar
      jbd2: fix data races at struct journal_head · b0caab0e
      Qian Cai authored
      [ Upstream commit 6c5d9112 ]
      
      journal_head::b_transaction and journal_head::b_next_transaction could
      be accessed concurrently as noticed by KCSAN,
      
       LTP: starting fsync04
       /dev/zero: Can't open blockdev
       EXT4-fs (loop0): mounting ext3 file system using the ext4 subsystem
       EXT4-fs (loop0): mounted filesystem with ordered data mode. Opts: (null)
       ==================================================================
       BUG: KCSAN: data-race in __jbd2_journal_refile_buffer [jbd2] / jbd2_write_access_granted [jbd2]
      
       write to 0xffff99f9b1bd0e30 of 8 bytes by task 25721 on cpu 70:
        __jbd2_journal_refile_buffer+0xdd/0x210 [jbd2]
        __jbd2_journal_refile_buffer at fs/jbd2/transaction.c:2569
        jbd2_journal_commit_transaction+0x2d15/0x3f20 [jbd2]
        (inlined by) jbd2_journal_commit_transaction at fs/jbd2/commit.c:1034
        kjournald2+0x13b/0x450 [jbd2]
        kthread+0x1cd/0x1f0
        ret_from_fork+0x27/0x50
      
       read to 0xffff99f9b1bd0e30 of 8 bytes by task 25724 on cpu 68:
        jbd2_write_access_granted+0x1b2/0x250 [jbd2]
        jbd2_write_access_granted at fs/jbd2/transaction.c:1155
        jbd2_journal_get_write_access+0x2c/0x60 [jbd2]
        __ext4_journal_get_write_access+0x50/0x90 [ext4]
        ext4_mb_mark_diskspace_used+0x158/0x620 [ext4]
        ext4_mb_new_blocks+0x54f/0xca0 [ext4]
        ext4_ind_map_blocks+0xc79/0x1b40 [ext4]
        ext4_map_blocks+0x3b4/0x950 [ext4]
        _ext4_get_block+0xfc/0x270 [ext4]
        ext4_get_block+0x3b/0x50 [ext4]
        __block_write_begin_int+0x22e/0xae0
        __block_write_begin+0x39/0x50
        ext4_write_begin+0x388/0xb50 [ext4]
        generic_perform_write+0x15d/0x290
        ext4_buffered_write_iter+0x11f/0x210 [ext4]
        ext4_file_write_iter+0xce/0x9e0 [ext4]
        new_sync_write+0x29c/0x3b0
        __vfs_write+0x92/0xa0
        vfs_write+0x103/0x260
        ksys_write+0x9d/0x130
        __x64_sys_write+0x4c/0x60
        do_syscall_64+0x91/0xb05
        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
       5 locks held by fsync04/25724:
        #0: ffff99f9911093f8 (sb_writers#13){.+.+}, at: vfs_write+0x21c/0x260
        #1: ffff99f9db4c0348 (&sb->s_type->i_mutex_key#15){+.+.}, at: ext4_buffered_write_iter+0x65/0x210 [ext4]
        #2: ffff99f5e7dfcf58 (jbd2_handle){++++}, at: start_this_handle+0x1c1/0x9d0 [jbd2]
        #3: ffff99f9db4c0168 (&ei->i_data_sem){++++}, at: ext4_map_blocks+0x176/0x950 [ext4]
        #4: ffffffff99086b40 (rcu_read_lock){....}, at: jbd2_write_access_granted+0x4e/0x250 [jbd2]
       irq event stamp: 1407125
       hardirqs last  enabled at (1407125): [<ffffffff980da9b7>] __find_get_block+0x107/0x790
       hardirqs last disabled at (1407124): [<ffffffff980da8f9>] __find_get_block+0x49/0x790
       softirqs last  enabled at (1405528): [<ffffffff98a0034c>] __do_softirq+0x34c/0x57c
       softirqs last disabled at (1405521): [<ffffffff97cc67a2>] irq_exit+0xa2/0xc0
      
       Reported by Kernel Concurrency Sanitizer on:
       CPU: 68 PID: 25724 Comm: fsync04 Tainted: G L 5.6.0-rc2-next-20200221+ #7
       Hardware name: HPE ProLiant DL385 Gen10/ProLiant DL385 Gen10, BIOS A40 07/10/2019
      
      The plain reads are outside of jh->b_state_lock critical section which result
      in data races. Fix them by adding pairs of READ|WRITE_ONCE().
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarQian Cai <cai@lca.pw>
      Link: https://lore.kernel.org/r/20200222043111.2227-1-cai@lca.pwSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b0caab0e
    • Alex Maftei (amaftei)'s avatar
      sfc: fix timestamp reconstruction at 16-bit rollover points · 04a244c8
      Alex Maftei (amaftei) authored
      [ Upstream commit 23797b98 ]
      
      We can't just use the top bits of the last sync event as they could be
      off-by-one every 65,536 seconds, giving an error in reconstruction of
      65,536 seconds.
      
      This patch uses the difference in the bottom 16 bits (mod 2^16) to
      calculate an offset that needs to be applied to the last sync event to
      get to the current time.
      Signed-off-by: default avatarAlexandru-Mihai Maftei <amaftei@solarflare.com>
      Acked-by: default avatarMartin Habets <mhabets@solarflare.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      04a244c8
    • Taehee Yoo's avatar
      net: rmnet: fix packet forwarding in rmnet bridge mode · 5043d35d
      Taehee Yoo authored
      [ Upstream commit ad3cc31b ]
      
      Packet forwarding is not working in rmnet bridge mode.
      Because when a packet is forwarded, skb_push() for an ethernet header
      is needed. But it doesn't call skb_push().
      So, the ethernet header will be lost.
      
      Test commands:
          modprobe rmnet
          ip netns add nst
          ip netns add nst2
          ip link add veth0 type veth peer name veth1
          ip link add veth2 type veth peer name veth3
          ip link set veth1 netns nst
          ip link set veth3 netns nst2
      
          ip link add rmnet0 link veth0 type rmnet mux_id 1
          ip link set veth2 master rmnet0
          ip link set veth0 up
          ip link set veth2 up
          ip link set rmnet0 up
          ip a a 192.168.100.1/24 dev rmnet0
      
          ip netns exec nst ip link set veth1 up
          ip netns exec nst ip a a 192.168.100.2/24 dev veth1
          ip netns exec nst2 ip link set veth3 up
          ip netns exec nst2 ip a a 192.168.100.3/24 dev veth3
          ip netns exec nst2 ping 192.168.100.2
      
      Fixes: 60d58f97 ("net: qualcomm: rmnet: Implement bridge mode")
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5043d35d
    • Taehee Yoo's avatar
      net: rmnet: fix bridge mode bugs · 8cf81bf8
      Taehee Yoo authored
      [ Upstream commit d939b6d3 ]
      
      In order to attach a bridge interface to the rmnet interface,
      "master" operation is used.
      (e.g. ip link set dummy1 master rmnet0)
      But, in the rmnet_add_bridge(), which is a callback of ->ndo_add_slave()
      doesn't register lower interface.
      So, ->ndo_del_slave() doesn't work.
      There are other problems too.
      1. It couldn't detect circular upper/lower interface relationship.
      2. It couldn't prevent stack overflow because of too deep depth
      of upper/lower interface
      3. It doesn't check the number of lower interfaces.
      4. Panics because of several reasons.
      
      The root problem of these issues is actually the same.
      So, in this patch, these all problems will be fixed.
      
      Test commands:
          modprobe rmnet
          ip link add dummy0 type dummy
          ip link add rmnet0 link dummy0 type rmnet mux_id 1
          ip link add dummy1 master rmnet0 type dummy
          ip link add dummy2 master rmnet0 type dummy
          ip link del rmnet0
          ip link del dummy2
          ip link del dummy1
      
      Splat looks like:
      [   41.867595][ T1164] general protection fault, probably for non-canonical address 0xdffffc0000000101I
      [   41.869993][ T1164] KASAN: null-ptr-deref in range [0x0000000000000808-0x000000000000080f]
      [   41.872950][ T1164] CPU: 0 PID: 1164 Comm: ip Not tainted 5.6.0-rc1+ #447
      [   41.873915][ T1164] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
      [   41.875161][ T1164] RIP: 0010:rmnet_unregister_bridge.isra.6+0x71/0xf0 [rmnet]
      [   41.876178][ T1164] Code: 48 89 ef 48 89 c6 5b 5d e9 fc fe ff ff e8 f7 f3 ff ff 48 8d b8 08 08 00 00 48 ba 00 7
      [   41.878925][ T1164] RSP: 0018:ffff8880c4d0f188 EFLAGS: 00010202
      [   41.879774][ T1164] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000101
      [   41.887689][ T1164] RDX: dffffc0000000000 RSI: ffffffffb8cf64f0 RDI: 0000000000000808
      [   41.888727][ T1164] RBP: ffff8880c40e4000 R08: ffffed101b3c0e3c R09: 0000000000000001
      [   41.889749][ T1164] R10: 0000000000000001 R11: ffffed101b3c0e3b R12: 1ffff110189a1e3c
      [   41.890783][ T1164] R13: ffff8880c4d0f200 R14: ffffffffb8d56160 R15: ffff8880ccc2c000
      [   41.891794][ T1164] FS:  00007f4300edc0c0(0000) GS:ffff8880d9c00000(0000) knlGS:0000000000000000
      [   41.892953][ T1164] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   41.893800][ T1164] CR2: 00007f43003bc8c0 CR3: 00000000ca53e001 CR4: 00000000000606f0
      [   41.894824][ T1164] Call Trace:
      [   41.895274][ T1164]  ? rcu_is_watching+0x2c/0x80
      [   41.895895][ T1164]  rmnet_config_notify_cb+0x1f7/0x590 [rmnet]
      [   41.896687][ T1164]  ? rmnet_unregister_bridge.isra.6+0xf0/0xf0 [rmnet]
      [   41.897611][ T1164]  ? rmnet_unregister_bridge.isra.6+0xf0/0xf0 [rmnet]
      [   41.898508][ T1164]  ? __module_text_address+0x13/0x140
      [   41.899162][ T1164]  notifier_call_chain+0x90/0x160
      [   41.899814][ T1164]  rollback_registered_many+0x660/0xcf0
      [   41.900544][ T1164]  ? netif_set_real_num_tx_queues+0x780/0x780
      [   41.901316][ T1164]  ? __lock_acquire+0xdfe/0x3de0
      [   41.901958][ T1164]  ? memset+0x1f/0x40
      [   41.902468][ T1164]  ? __nla_validate_parse+0x98/0x1ab0
      [   41.903166][ T1164]  unregister_netdevice_many.part.133+0x13/0x1b0
      [   41.903988][ T1164]  rtnl_delete_link+0xbc/0x100
      [ ... ]
      
      Fixes: 60d58f97 ("net: qualcomm: rmnet: Implement bridge mode")
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8cf81bf8