1. 29 Jan, 2020 40 commits
    • Johan Hovold's avatar
      Input: sur40 - fix interface sanity checks · 364ff528
      Johan Hovold authored
      commit 6b32391e upstream.
      
      Make sure to use the current alternate setting when verifying the
      interface descriptors to avoid binding to an invalid interface.
      
      This in turn could cause the driver to misbehave or trigger a WARN() in
      usb_submit_urb() that kernels with panic_on_warn set would choke on.
      
      Fixes: bdb5c57f ("Input: add sur40 driver for Samsung SUR40 (aka MS Surface 2.0/Pixelsense)")
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Acked-by: default avatarVladis Dronov <vdronov@redhat.com>
      Link: https://lore.kernel.org/r/20191210113737.4016-8-johan@kernel.orgSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      364ff528
    • Michał Mirosław's avatar
      mmc: sdhci: fix minimum clock rate for v3 controller · f98d9039
      Michał Mirosław authored
      commit 2a187d03 upstream.
      
      For SDHCIv3+ with programmable clock mode, minimal clock frequency is
      still base clock / max(divider). Minimal programmable clock frequency is
      always greater than minimal divided clock frequency. Without this patch,
      SDHCI uses out-of-spec initial frequency when multiplier is big enough:
      
      mmc1: mmc_rescan_try_freq: trying to init card at 468750 Hz
      [for 480 MHz source clock divided by 1024]
      
      The code in sdhci_calc_clk() already chooses a correct SDCLK clock mode.
      
      Fixes: c3ed3877 ("mmc: sdhci: add support for programmable clock mode")
      Cc: <stable@vger.kernel.org> # 4f6aa326: mmc: tegra: Only advertise UHS modes if IO regulator is present
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarMichał Mirosław <mirq-linux@rere.qmqm.pl>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Link: https://lore.kernel.org/r/ffb489519a446caffe7a0a05c4b9372bd52397bb.1579082031.git.mirq-linux@rere.qmqm.plSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f98d9039
    • Michał Mirosław's avatar
      mmc: tegra: fix SDR50 tuning override · 6c7937e1
      Michał Mirosław authored
      commit f571389c upstream.
      
      Commit 7ad2ed1d inadvertently mixed up a quirk flag's name and
      broke SDR50 tuning override. Use correct NVQUIRK_ name.
      
      Fixes: 7ad2ed1d ("mmc: tegra: enable UHS-I modes")
      Cc: <stable@vger.kernel.org>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Reviewed-by: default avatarThierry Reding <treding@nvidia.com>
      Tested-by: default avatarThierry Reding <treding@nvidia.com>
      Signed-off-by: default avatarMichał Mirosław <mirq-linux@rere.qmqm.pl>
      Link: https://lore.kernel.org/r/9aff1d859935e59edd81e4939e40d6c55e0b55f6.1578390388.git.mirq-linux@rere.qmqm.plSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6c7937e1
    • Alex Sverdlin's avatar
      ARM: 8950/1: ftrace/recordmcount: filter relocation types · 49bddb88
      Alex Sverdlin authored
      commit 927d780e upstream.
      
      Scenario 1, ARMv7
      =================
      
      If code in arch/arm/kernel/ftrace.c would operate on mcount() pointer
      the following may be generated:
      
      00000230 <prealloc_fixed_plts>:
       230:   b5f8            push    {r3, r4, r5, r6, r7, lr}
       232:   b500            push    {lr}
       234:   f7ff fffe       bl      0 <__gnu_mcount_nc>
                              234: R_ARM_THM_CALL     __gnu_mcount_nc
       238:   f240 0600       movw    r6, #0
                              238: R_ARM_THM_MOVW_ABS_NC      __gnu_mcount_nc
       23c:   f8d0 1180       ldr.w   r1, [r0, #384]  ; 0x180
      
      FTRACE currently is not able to deal with it:
      
      WARNING: CPU: 0 PID: 0 at .../kernel/trace/ftrace.c:1979 ftrace_bug+0x1ad/0x230()
      ...
      CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.4.116-... #1
      ...
      [<c0314e3d>] (unwind_backtrace) from [<c03115e9>] (show_stack+0x11/0x14)
      [<c03115e9>] (show_stack) from [<c051a7f1>] (dump_stack+0x81/0xa8)
      [<c051a7f1>] (dump_stack) from [<c0321c5d>] (warn_slowpath_common+0x69/0x90)
      [<c0321c5d>] (warn_slowpath_common) from [<c0321cf3>] (warn_slowpath_null+0x17/0x1c)
      [<c0321cf3>] (warn_slowpath_null) from [<c038ee9d>] (ftrace_bug+0x1ad/0x230)
      [<c038ee9d>] (ftrace_bug) from [<c038f1f9>] (ftrace_process_locs+0x27d/0x444)
      [<c038f1f9>] (ftrace_process_locs) from [<c08915bd>] (ftrace_init+0x91/0xe8)
      [<c08915bd>] (ftrace_init) from [<c0885a67>] (start_kernel+0x34b/0x358)
      [<c0885a67>] (start_kernel) from [<00308095>] (0x308095)
      ---[ end trace cb88537fdc8fa200 ]---
      ftrace failed to modify [<c031266c>] prealloc_fixed_plts+0x8/0x60
       actual: 44:f2:e1:36
      ftrace record flags: 0
       (0)   expected tramp: c03143e9
      
      Scenario 2, ARMv4T
      ==================
      
      ftrace: allocating 14435 entries in 43 pages
      ------------[ cut here ]------------
      WARNING: CPU: 0 PID: 0 at kernel/trace/ftrace.c:2029 ftrace_bug+0x204/0x310
      CPU: 0 PID: 0 Comm: swapper Not tainted 4.19.5 #1
      Hardware name: Cirrus Logic EDB9302 Evaluation Board
      [<c0010a24>] (unwind_backtrace) from [<c000ecb0>] (show_stack+0x20/0x2c)
      [<c000ecb0>] (show_stack) from [<c03c72e8>] (dump_stack+0x20/0x30)
      [<c03c72e8>] (dump_stack) from [<c0021c18>] (__warn+0xdc/0x104)
      [<c0021c18>] (__warn) from [<c0021d7c>] (warn_slowpath_null+0x4c/0x5c)
      [<c0021d7c>] (warn_slowpath_null) from [<c0095360>] (ftrace_bug+0x204/0x310)
      [<c0095360>] (ftrace_bug) from [<c04dabac>] (ftrace_init+0x3b4/0x4d4)
      [<c04dabac>] (ftrace_init) from [<c04cef4c>] (start_kernel+0x20c/0x410)
      [<c04cef4c>] (start_kernel) from [<00000000>] (  (null))
      ---[ end trace 0506a2f5dae6b341 ]---
      ftrace failed to modify
      [<c000c350>] perf_trace_sys_exit+0x5c/0xe8
       actual:   1e:ff:2f:e1
      Initializing ftrace call sites
      ftrace record flags: 0
       (0)
       expected tramp: c000fb24
      
      The analysis for this problem has been already performed previously,
      refer to the link below.
      
      Fix the above problems by allowing only selected reloc types in
      __mcount_loc. The list itself comes from the legacy recordmcount.pl
      script.
      
      Link: https://lore.kernel.org/lkml/56961010.6000806@pengutronix.de/
      Cc: stable@vger.kernel.org
      Fixes: ed60453f ("ARM: 6511/1: ftrace: add ARM support for C version of recordmcount")
      Signed-off-by: default avatarAlexander Sverdlin <alexander.sverdlin@nokia.com>
      Acked-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      49bddb88
    • Johan Hovold's avatar
      Input: keyspan-remote - fix control-message timeouts · e676bda8
      Johan Hovold authored
      commit ba9a103f upstream.
      
      The driver was issuing synchronous uninterruptible control requests
      without using a timeout. This could lead to the driver hanging on probe
      due to a malfunctioning (or malicious) device until the device is
      physically disconnected. While sleeping in probe the driver prevents
      other devices connected to the same hub from being added to (or removed
      from) the bus.
      
      The USB upper limit of five seconds per request should be more than
      enough.
      
      Fixes: 99f83c9c ("[PATCH] USB: add driver for Keyspan Digital Remote")
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: stable <stable@vger.kernel.org>     # 2.6.13
      Link: https://lore.kernel.org/r/20200113171715.30621-1-johan@kernel.orgSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e676bda8
    • Guenter Roeck's avatar
      hwmon: (core) Do not use device managed functions for memory allocations · 974185ee
      Guenter Roeck authored
      commit 3bf8bdcf upstream.
      
      The hwmon core uses device managed functions, tied to the hwmon parent
      device, for various internal memory allocations. This is problematic
      since hwmon device lifetime does not necessarily match its parent's
      device lifetime. If there is a mismatch, memory leaks will accumulate
      until the parent device is released.
      
      Fix the problem by managing all memory allocations internally. The only
      exception is memory allocation for thermal device registration, which
      can be tied to the hwmon device, along with thermal device registration
      itself.
      
      Fixes: d560168b ("hwmon: (core) New hwmon registration API")
      Cc: stable@vger.kernel.org # v4.14.x: 47c332de: hwmon: Deal with errors from the thermal subsystem
      Cc: stable@vger.kernel.org # v4.14.x: 74e35127: hwmon: (core) Fix double-free in __hwmon_device_register()
      Cc: stable@vger.kernel.org # v4.9.x: 3a412d5e: hwmon: (core) Simplify sysfs attribute name allocation
      Cc: stable@vger.kernel.org # v4.9.x: 47c332de: hwmon: Deal with errors from the thermal subsystem
      Cc: stable@vger.kernel.org # v4.9.x: 74e35127: hwmon: (core) Fix double-free in __hwmon_device_register()
      Cc: stable@vger.kernel.org # v4.9+
      Cc: Martin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      974185ee
    • Dmitry Osipenko's avatar
      hwmon: (core) Fix double-free in __hwmon_device_register() · 81ca3dc3
      Dmitry Osipenko authored
      commit 74e35127 upstream.
      
      Fix double-free that happens when thermal zone setup fails, see KASAN log
      below.
      
      ==================================================================
      BUG: KASAN: double-free or invalid-free in __hwmon_device_register+0x5dc/0xa7c
      
      CPU: 0 PID: 132 Comm: kworker/0:2 Tainted: G    B             4.19.0-rc8-next-20181016-00042-gb52cd80401e9-dirty #41
      Hardware name: NVIDIA Tegra SoC (Flattened Device Tree)
      Workqueue: events deferred_probe_work_func
      Backtrace:
      [<c0110540>] (dump_backtrace) from [<c0110944>] (show_stack+0x20/0x24)
      [<c0110924>] (show_stack) from [<c105cb08>] (dump_stack+0x9c/0xb0)
      [<c105ca6c>] (dump_stack) from [<c02fdaec>] (print_address_description+0x68/0x250)
      [<c02fda84>] (print_address_description) from [<c02fd4ac>] (kasan_report_invalid_free+0x68/0x88)
      [<c02fd444>] (kasan_report_invalid_free) from [<c02fc85c>] (__kasan_slab_free+0x1f4/0x200)
      [<c02fc668>] (__kasan_slab_free) from [<c02fd0c0>] (kasan_slab_free+0x14/0x18)
      [<c02fd0ac>] (kasan_slab_free) from [<c02f9c6c>] (kfree+0x90/0x294)
      [<c02f9bdc>] (kfree) from [<c0b41bbc>] (__hwmon_device_register+0x5dc/0xa7c)
      [<c0b415e0>] (__hwmon_device_register) from [<c0b421e8>] (hwmon_device_register_with_info+0xa0/0xa8)
      [<c0b42148>] (hwmon_device_register_with_info) from [<c0b42324>] (devm_hwmon_device_register_with_info+0x74/0xb4)
      [<c0b422b0>] (devm_hwmon_device_register_with_info) from [<c0b4481c>] (lm90_probe+0x414/0x578)
      [<c0b44408>] (lm90_probe) from [<c0aeeff4>] (i2c_device_probe+0x35c/0x384)
      [<c0aeec98>] (i2c_device_probe) from [<c08776cc>] (really_probe+0x290/0x3e4)
      [<c087743c>] (really_probe) from [<c0877a2c>] (driver_probe_device+0x80/0x1c4)
      [<c08779ac>] (driver_probe_device) from [<c0877da8>] (__device_attach_driver+0x104/0x11c)
      [<c0877ca4>] (__device_attach_driver) from [<c0874dd8>] (bus_for_each_drv+0xa4/0xc8)
      [<c0874d34>] (bus_for_each_drv) from [<c08773b0>] (__device_attach+0xf0/0x15c)
      [<c08772c0>] (__device_attach) from [<c0877e24>] (device_initial_probe+0x1c/0x20)
      [<c0877e08>] (device_initial_probe) from [<c08762f4>] (bus_probe_device+0xdc/0xec)
      [<c0876218>] (bus_probe_device) from [<c0876a08>] (deferred_probe_work_func+0xa8/0xd4)
      [<c0876960>] (deferred_probe_work_func) from [<c01527c4>] (process_one_work+0x3dc/0x96c)
      [<c01523e8>] (process_one_work) from [<c01541e0>] (worker_thread+0x4ec/0x8bc)
      [<c0153cf4>] (worker_thread) from [<c015b238>] (kthread+0x230/0x240)
      [<c015b008>] (kthread) from [<c01010bc>] (ret_from_fork+0x14/0x38)
      Exception stack(0xcf743fb0 to 0xcf743ff8)
      3fa0:                                     00000000 00000000 00000000 00000000
      3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      3fe0: 00000000 00000000 00000000 00000000 00000013 00000000
      
      Allocated by task 132:
       kasan_kmalloc.part.1+0x58/0xf4
       kasan_kmalloc+0x90/0xa4
       kmem_cache_alloc_trace+0x90/0x2a0
       __hwmon_device_register+0xbc/0xa7c
       hwmon_device_register_with_info+0xa0/0xa8
       devm_hwmon_device_register_with_info+0x74/0xb4
       lm90_probe+0x414/0x578
       i2c_device_probe+0x35c/0x384
       really_probe+0x290/0x3e4
       driver_probe_device+0x80/0x1c4
       __device_attach_driver+0x104/0x11c
       bus_for_each_drv+0xa4/0xc8
       __device_attach+0xf0/0x15c
       device_initial_probe+0x1c/0x20
       bus_probe_device+0xdc/0xec
       deferred_probe_work_func+0xa8/0xd4
       process_one_work+0x3dc/0x96c
       worker_thread+0x4ec/0x8bc
       kthread+0x230/0x240
       ret_from_fork+0x14/0x38
         (null)
      
      Freed by task 132:
       __kasan_slab_free+0x12c/0x200
       kasan_slab_free+0x14/0x18
       kfree+0x90/0x294
       hwmon_dev_release+0x1c/0x20
       device_release+0x4c/0xe8
       kobject_put+0xac/0x11c
       device_unregister+0x2c/0x30
       __hwmon_device_register+0xa58/0xa7c
       hwmon_device_register_with_info+0xa0/0xa8
       devm_hwmon_device_register_with_info+0x74/0xb4
       lm90_probe+0x414/0x578
       i2c_device_probe+0x35c/0x384
       really_probe+0x290/0x3e4
       driver_probe_device+0x80/0x1c4
       __device_attach_driver+0x104/0x11c
       bus_for_each_drv+0xa4/0xc8
       __device_attach+0xf0/0x15c
       device_initial_probe+0x1c/0x20
       bus_probe_device+0xdc/0xec
       deferred_probe_work_func+0xa8/0xd4
       process_one_work+0x3dc/0x96c
       worker_thread+0x4ec/0x8bc
       kthread+0x230/0x240
       ret_from_fork+0x14/0x38
         (null)
      
      Cc: <stable@vger.kernel.org> # v4.15+
      Fixes: 47c332de ("hwmon: Deal with errors from the thermal subsystem")
      Signed-off-by: default avatarDmitry Osipenko <digetx@gmail.com>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      81ca3dc3
    • Linus Walleij's avatar
      hwmon: Deal with errors from the thermal subsystem · a34d0230
      Linus Walleij authored
      commit 47c332de upstream.
      
      If the thermal subsystem returne -EPROBE_DEFER or any other error
      when hwmon calls devm_thermal_zone_of_sensor_register(), this is
      silently ignored.
      
      I ran into this with an incorrectly defined thermal zone, making
      it non-existing and thus this call failed with -EPROBE_DEFER
      assuming it would appear later. The sensor was still added
      which is incorrect: sensors must strictly be added after the
      thermal zones, so deferred probe must be respected.
      
      Fixes: d560168b ("hwmon: (core) New hwmon registration API")
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a34d0230
    • Guenter Roeck's avatar
      hwmon: (core) Simplify sysfs attribute name allocation · cb4412e3
      Guenter Roeck authored
      commit 3a412d5e upstream.
      
      Allocating the sysfs attribute name only if needed and only with the
      required minimum length looks optimal, but does not take the additional
      overhead for both devm_ data structures and the allocation header itself
      into account. This also results in unnecessary memory fragmentation.
      Move the sysfs name string into struct hwmon_device_attribute and give it
      a sufficient length to reduce this overhead.
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cb4412e3
    • Luuk Paulussen's avatar
      hwmon: (adt7475) Make volt2reg return same reg as reg2volt input · c5e1aae0
      Luuk Paulussen authored
      commit cf3ca187 upstream.
      
      reg2volt returns the voltage that matches a given register value.
      Converting this back the other way with volt2reg didn't return the same
      register value because it used truncation instead of rounding.
      
      This meant that values read from sysfs could not be written back to sysfs
      to set back the same register value.
      
      With this change, volt2reg will return the same value for every voltage
      previously returned by reg2volt (for the set of possible input values)
      Signed-off-by: default avatarLuuk Paulussen <luuk.paulussen@alliedtelesis.co.nz>
      Link: https://lore.kernel.org/r/20191205231659.1301-1-luuk.paulussen@alliedtelesis.co.nz
      cc: stable@vger.kernel.org
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c5e1aae0
    • Eric Dumazet's avatar
      gtp: make sure only SOCK_DGRAM UDP sockets are accepted · 3410eb22
      Eric Dumazet authored
      [ Upstream commit 940ba149 ]
      
      A malicious user could use RAW sockets and fool
      GTP using them as standard SOCK_DGRAM UDP sockets.
      
      BUG: KMSAN: uninit-value in udp_tunnel_encap_enable include/net/udp_tunnel.h:174 [inline]
      BUG: KMSAN: uninit-value in setup_udp_tunnel_sock+0x45e/0x6f0 net/ipv4/udp_tunnel.c:85
      CPU: 0 PID: 11262 Comm: syz-executor613 Not tainted 5.5.0-rc5-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       __dump_stack lib/dump_stack.c:77 [inline]
       dump_stack+0x1c9/0x220 lib/dump_stack.c:118
       kmsan_report+0xf7/0x1e0 mm/kmsan/kmsan_report.c:118
       __msan_warning+0x58/0xa0 mm/kmsan/kmsan_instr.c:215
       udp_tunnel_encap_enable include/net/udp_tunnel.h:174 [inline]
       setup_udp_tunnel_sock+0x45e/0x6f0 net/ipv4/udp_tunnel.c:85
       gtp_encap_enable_socket+0x37f/0x5a0 drivers/net/gtp.c:827
       gtp_encap_enable drivers/net/gtp.c:844 [inline]
       gtp_newlink+0xfb/0x1e50 drivers/net/gtp.c:666
       __rtnl_newlink net/core/rtnetlink.c:3305 [inline]
       rtnl_newlink+0x2973/0x3920 net/core/rtnetlink.c:3363
       rtnetlink_rcv_msg+0x1153/0x1570 net/core/rtnetlink.c:5424
       netlink_rcv_skb+0x451/0x650 net/netlink/af_netlink.c:2477
       rtnetlink_rcv+0x50/0x60 net/core/rtnetlink.c:5442
       netlink_unicast_kernel net/netlink/af_netlink.c:1302 [inline]
       netlink_unicast+0xf9e/0x1100 net/netlink/af_netlink.c:1328
       netlink_sendmsg+0x1248/0x14d0 net/netlink/af_netlink.c:1917
       sock_sendmsg_nosec net/socket.c:639 [inline]
       sock_sendmsg net/socket.c:659 [inline]
       ____sys_sendmsg+0x12b6/0x1350 net/socket.c:2330
       ___sys_sendmsg net/socket.c:2384 [inline]
       __sys_sendmsg+0x451/0x5f0 net/socket.c:2417
       __do_sys_sendmsg net/socket.c:2426 [inline]
       __se_sys_sendmsg+0x97/0xb0 net/socket.c:2424
       __x64_sys_sendmsg+0x4a/0x70 net/socket.c:2424
       do_syscall_64+0xb8/0x160 arch/x86/entry/common.c:296
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      RIP: 0033:0x441359
      Code: e8 ac e8 ff ff 48 83 c4 18 c3 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 eb 08 fc ff c3 66 2e 0f 1f 84 00 00 00 00
      RSP: 002b:00007fff1cd0ac28 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
      RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000441359
      RDX: 0000000000000000 RSI: 0000000020000100 RDI: 0000000000000003
      RBP: 00000000006cb018 R08: 00000000004002c8 R09: 00000000004002c8
      R10: 00000000004002c8 R11: 0000000000000246 R12: 00000000004020d0
      R13: 0000000000402160 R14: 0000000000000000 R15: 0000000000000000
      
      Uninit was created at:
       kmsan_save_stack_with_flags+0x3c/0x90 mm/kmsan/kmsan.c:144
       kmsan_internal_alloc_meta_for_pages mm/kmsan/kmsan_shadow.c:307 [inline]
       kmsan_alloc_page+0x12a/0x310 mm/kmsan/kmsan_shadow.c:336
       __alloc_pages_nodemask+0x57f2/0x5f60 mm/page_alloc.c:4800
       alloc_pages_current+0x67d/0x990 mm/mempolicy.c:2207
       alloc_pages include/linux/gfp.h:534 [inline]
       alloc_slab_page+0x111/0x12f0 mm/slub.c:1511
       allocate_slab mm/slub.c:1656 [inline]
       new_slab+0x2bc/0x1130 mm/slub.c:1722
       new_slab_objects mm/slub.c:2473 [inline]
       ___slab_alloc+0x1533/0x1f30 mm/slub.c:2624
       __slab_alloc mm/slub.c:2664 [inline]
       slab_alloc_node mm/slub.c:2738 [inline]
       slab_alloc mm/slub.c:2783 [inline]
       kmem_cache_alloc+0xb23/0xd70 mm/slub.c:2788
       sk_prot_alloc+0xf2/0x620 net/core/sock.c:1597
       sk_alloc+0xf0/0xbe0 net/core/sock.c:1657
       inet_create+0x7c7/0x1370 net/ipv4/af_inet.c:321
       __sock_create+0x8eb/0xf00 net/socket.c:1420
       sock_create net/socket.c:1471 [inline]
       __sys_socket+0x1a1/0x600 net/socket.c:1513
       __do_sys_socket net/socket.c:1522 [inline]
       __se_sys_socket+0x8d/0xb0 net/socket.c:1520
       __x64_sys_socket+0x4a/0x70 net/socket.c:1520
       do_syscall_64+0xb8/0x160 arch/x86/entry/common.c:296
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Fixes: 459aa660 ("gtp: add initial driver for datapath of GPRS Tunneling Protocol (GTP-U)")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Pablo Neira <pablo@netfilter.org>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3410eb22
    • James Hughes's avatar
      net: usb: lan78xx: Add .ndo_features_check · 91f9202f
      James Hughes authored
      [ Upstream commit ce896476 ]
      
      As reported by Eric Dumazet, there are still some outstanding
      cases where the driver does not handle TSO correctly when skb's
      are over a certain size. Most cases have been fixed, this patch
      should ensure that forwarded SKB's that are greater than
      MAX_SINGLE_PACKET_SIZE - TX_OVERHEAD are software segmented
      and handled correctly.
      Signed-off-by: default avatarJames Hughes <james.hughes@raspberrypi.org>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      91f9202f
    • Wen Yang's avatar
      tcp_bbr: improve arithmetic division in bbr_update_bw() · 57d3e48b
      Wen Yang authored
      [ Upstream commit 5b2f1f30 ]
      
      do_div() does a 64-by-32 division. Use div64_long() instead of it
      if the divisor is long, to avoid truncation to 32-bit.
      And as a nice side effect also cleans up the function a bit.
      Signed-off-by: default avatarWen Yang <wenyang@linux.alibaba.com>
      Cc: Eric Dumazet <edumazet@google.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
      Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
      Cc: netdev@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      57d3e48b
    • Cong Wang's avatar
      net_sched: fix datalen for ematch · 627996d4
      Cong Wang authored
      [ Upstream commit 61678d28 ]
      
      syzbot reported an out-of-bound access in em_nbyte. As initially
      analyzed by Eric, this is because em_nbyte sets its own em->datalen
      in em_nbyte_change() other than the one specified by user, but this
      value gets overwritten later by its caller tcf_em_validate().
      We should leave em->datalen untouched to respect their choices.
      
      I audit all the in-tree ematch users, all of those implement
      ->change() set em->datalen, so we can just avoid setting it twice
      in this case.
      
      Reported-and-tested-by: syzbot+5af9a90dad568aa9f611@syzkaller.appspotmail.com
      Reported-by: syzbot+2f07903a5b05e7f36410@syzkaller.appspotmail.com
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: Eric Dumazet <eric.dumazet@gmail.com>
      Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      627996d4
    • William Dauchy's avatar
      net, ip_tunnel: fix namespaces move · 6769626b
      William Dauchy authored
      [ Upstream commit d0f41851 ]
      
      in the same manner as commit 690afc16 ("net: ip6_gre: fix moving
      ip6gre between namespaces"), fix namespace moving as it was broken since
      commit 2e15ea39 ("ip_gre: Add support to collect tunnel metadata.").
      Indeed, the ip6_gre commit removed the local flag for collect_md
      condition, so there is no reason to keep it for ip_gre/ip_tunnel.
      
      this patch will fix both ip_tunnel and ip_gre modules.
      
      Fixes: 2e15ea39 ("ip_gre: Add support to collect tunnel metadata.")
      Signed-off-by: default avatarWilliam Dauchy <w.dauchy@criteo.com>
      Acked-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6769626b
    • William Dauchy's avatar
      net, ip6_tunnel: fix namespaces move · db049045
      William Dauchy authored
      [ Upstream commit 5311a69a ]
      
      in the same manner as commit d0f41851 ("net, ip_tunnel: fix
      namespaces move"), fix namespace moving as it was broken since commit
      8d79266b ("ip6_tunnel: add collect_md mode to IPv6 tunnel"), but for
      ipv6 this time; there is no reason to keep it for ip6_tunnel.
      
      Fixes: 8d79266b ("ip6_tunnel: add collect_md mode to IPv6 tunnel")
      Signed-off-by: default avatarWilliam Dauchy <w.dauchy@criteo.com>
      Acked-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      db049045
    • Michael Ellerman's avatar
      net: cxgb3_main: Add CAP_NET_ADMIN check to CHELSIO_GET_MEM · a99fb020
      Michael Ellerman authored
      [ Upstream commit 3546d8f1 =
      
      The cxgb3 driver for "Chelsio T3-based gigabit and 10Gb Ethernet
      adapters" implements a custom ioctl as SIOCCHIOCTL/SIOCDEVPRIVATE in
      cxgb_extension_ioctl().
      
      One of the subcommands of the ioctl is CHELSIO_GET_MEM, which appears
      to read memory directly out of the adapter and return it to userspace.
      It's not entirely clear what the contents of the adapter memory
      contains, but the assumption is that it shouldn't be accessible to all
      users.
      
      So add a CAP_NET_ADMIN check to the CHELSIO_GET_MEM case. Put it after
      the is_offload() check, which matches two of the other subcommands in
      the same function which also check for is_offload() and CAP_NET_ADMIN.
      
      Found by Ilja by code inspection, not tested as I don't have the
      required hardware.
      Reported-by: default avatarIlja Van Sprundel <ivansprundel@ioactive.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a99fb020
    • Wenwen Wang's avatar
      firestream: fix memory leaks · 35f8ab22
      Wenwen Wang authored
      [ Upstream commit fa865ba1 ]
      
      In fs_open(), 'vcc' is allocated through kmalloc() and assigned to
      'atm_vcc->dev_data.' In the following execution, if an error occurs, e.g.,
      there is no more free channel, an error code EBUSY or ENOMEM will be
      returned. However, 'vcc' is not deallocated, leading to memory leaks. Note
      that, in normal cases where fs_open() returns 0, 'vcc' will be deallocated
      in fs_close(). But, if fs_open() fails, there is no guarantee that
      fs_close() will be invoked.
      
      To fix this issue, deallocate 'vcc' before the error code is returned.
      Signed-off-by: default avatarWenwen Wang <wenwen@cs.uga.edu>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      35f8ab22
    • Richard Palethorpe's avatar
      can, slip: Protect tty->disc_data in write_wakeup and close with RCU · 0beba1d7
      Richard Palethorpe authored
      [ Upstream commit 0ace17d5 ]
      
      write_wakeup can happen in parallel with close/hangup where tty->disc_data
      is set to NULL and the netdevice is freed thus also freeing
      disc_data. write_wakeup accesses disc_data so we must prevent close from
      freeing the netdev while write_wakeup has a non-NULL view of
      tty->disc_data.
      
      We also need to make sure that accesses to disc_data are atomic. Which can
      all be done with RCU.
      
      This problem was found by Syzkaller on SLCAN, but the same issue is
      reproducible with the SLIP line discipline using an LTP test based on the
      Syzkaller reproducer.
      
      A fix which didn't use RCU was posted by Hillf Danton.
      
      Fixes: 661f7fda ("slip: Fix deadlock in write_wakeup")
      Fixes: a8e83b17 ("slcan: Port write_wakeup deadlock fix from slip")
      Reported-by: syzbot+017e491ae13c0068598a@syzkaller.appspotmail.com
      Signed-off-by: default avatarRichard Palethorpe <rpalethorpe@suse.com>
      Cc: Wolfgang Grandegger <wg@grandegger.com>
      Cc: Marc Kleine-Budde <mkl@pengutronix.de>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Tyler Hall <tylerwhall@gmail.com>
      Cc: linux-can@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: syzkaller@googlegroups.com
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0beba1d7
    • Florian Fainelli's avatar
      net: phy: Keep reporting transceiver type · a3f89d26
      Florian Fainelli authored
      commit ceb62813 upstream.
      
      With commit 2d55173e ("phy: add generic function to support
      ksetting support"), we lost the ability to report the transceiver type
      like we used to. Now that we have added back the transceiver type to
      ethtool_link_settings, we can report it back like we used to and have no
      loss of information.
      
      Fixes: 3f1ac7a7 ("net: ethtool: add new ETHTOOL_xLINKSETTINGS API")
      Fixes: 2d55173e ("phy: add generic function to support ksetting support")
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a3f89d26
    • Florian Fainelli's avatar
      net: ethtool: Add back transceiver type · e9cd6721
      Florian Fainelli authored
      commit 19cab887 upstream.
      
      Commit 3f1ac7a7 ("net: ethtool: add new ETHTOOL_xLINKSETTINGS API")
      deprecated the ethtool_cmd::transceiver field, which was fine in
      premise, except that the PHY library was actually using it to report the
      type of transceiver: internal or external.
      
      Use the first word of the reserved field to put this __u8 transceiver
      field back in. It is made read-only, and we don't expect the
      ETHTOOL_xLINKSETTINGS API to be doing anything with this anyway, so this
      is mostly for the legacy path where we do:
      
      ethtool_get_settings()
      -> dev->ethtool_ops->get_link_ksettings()
         -> convert_link_ksettings_to_legacy_settings()
      
      to have no information loss compared to the legacy get_settings API.
      
      Fixes: 3f1ac7a7 ("net: ethtool: add new ETHTOOL_xLINKSETTINGS API")
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e9cd6721
    • Finn Thain's avatar
      m68k: Call timer_interrupt() with interrupts disabled · 064ce3a1
      Finn Thain authored
      [ Upstream commit 1efdd4bd ]
      
      Some platforms execute their timer handler with the interrupt priority
      level set below 6. That means the handler could be interrupted by another
      driver and this could lead to re-entry of the timer core.
      
      Avoid this by use of local_irq_save/restore for timer interrupt dispatch.
      This provides mutual exclusion around the timer interrupt flag access
      which is needed later in this series for the clocksource conversion.
      Reported-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/alpine.DEB.2.21.1811131407120.2697@nanos.tec.linutronix.deSigned-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
      Signed-off-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      064ce3a1
    • Max Gurtovoy's avatar
      IB/iser: Fix dma_nents type definition · 60c58d84
      Max Gurtovoy authored
      [ Upstream commit c1545f1a ]
      
      The retured value from ib_dma_map_sg saved in dma_nents variable. To avoid
      future mismatch between types, define dma_nents as an integer instead of
      unsigned.
      
      Fixes: 57b26497 ("IB/iser: Pass the correct number of entries for dma mapped SGL")
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Reviewed-by: default avatarIsrael Rukshin <israelr@mellanox.com>
      Signed-off-by: default avatarMax Gurtovoy <maxg@mellanox.com>
      Acked-by: default avatarSagi Grimberg <sagi@grimberg.me>
      Reviewed-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      60c58d84
    • Andre Przywara's avatar
      arm64: dts: juno: Fix UART frequency · 096ad855
      Andre Przywara authored
      [ Upstream commit 39a1a894 ]
      
      Older versions of the Juno *SoC* TRM [1] recommended that the UART clock
      source should be 7.2738 MHz, whereas the *system* TRM [2] stated a more
      correct value of 7.3728 MHz. Somehow the wrong value managed to end up in
      our DT.
      
      Doing a prime factorisation, a modulo divide by 115200 and trying
      to buy a 7.2738 MHz crystal at your favourite electronics dealer suggest
      that the old value was actually a typo. The actual UART clock is driven
      by a PLL, configured via a parameter in some board.txt file in the
      firmware, which reads 7.37 MHz (sic!).
      
      Fix this to correct the baud rate divisor calculation on the Juno board.
      
      [1] http://infocenter.arm.com/help/topic/com.arm.doc.ddi0515b.b/DDI0515B_b_juno_arm_development_platform_soc_trm.pdf
      [2] http://infocenter.arm.com/help/topic/com.arm.doc.100113_0000_07_en/arm_versatile_express_juno_development_platform_(v2m_juno)_technical_reference_manual_100113_0000_07_en.pdf
      
      Fixes: 71f867ec ("arm64: Add Juno board device tree.")
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      Acked-by: default avatarLiviu Dudau <liviu.dudau@arm.com>
      Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      096ad855
    • Sam Bobroff's avatar
      drm/radeon: fix bad DMA from INTERRUPT_CNTL2 · 18faefde
      Sam Bobroff authored
      [ Upstream commit 62d91dd2 ]
      
      The INTERRUPT_CNTL2 register expects a valid DMA address, but is
      currently set with a GPU MC address.  This can cause problems on
      systems that detect the resulting DMA read from an invalid address
      (found on a Power8 guest).
      
      Instead, use the DMA address of the dummy page because it will always
      be safe.
      
      Fixes: d8f60cfc ("drm/radeon/kms: Add support for interrupts on r6xx/r7xx chips (v3)")
      Fixes: 25a857fb ("drm/radeon/kms: add support for interrupts on SI")
      Fixes: a59781bb ("drm/radeon: add support for interrupts on CIK (v5)")
      Signed-off-by: default avatarSam Bobroff <sbobroff@linux.ibm.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      18faefde
    • Chuhong Yuan's avatar
      dmaengine: ti: edma: fix missed failure handling · a52766fa
      Chuhong Yuan authored
      [ Upstream commit 340049d4 ]
      
      When devm_kcalloc fails, it forgets to call edma_free_slot.
      Replace direct return with failure handler to fix it.
      
      Fixes: 1be5336b ("dmaengine: edma: New device tree binding")
      Signed-off-by: default avatarChuhong Yuan <hslester96@gmail.com>
      Link: https://lore.kernel.org/r/20191118073802.28424-1-hslester96@gmail.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a52766fa
    • Eric Dumazet's avatar
      packet: fix data-race in fanout_flow_is_huge() · 451081e3
      Eric Dumazet authored
      [ Upstream commit b756ad92 ]
      
      KCSAN reported the following data-race [1]
      
      Adding a couple of READ_ONCE()/WRITE_ONCE() should silence it.
      
      Since the report hinted about multiple cpus using the history
      concurrently, I added a test avoiding writing on it if the
      victim slot already contains the desired value.
      
      [1]
      
      BUG: KCSAN: data-race in fanout_demux_rollover / fanout_demux_rollover
      
      read to 0xffff8880b01786cc of 4 bytes by task 18921 on cpu 1:
       fanout_flow_is_huge net/packet/af_packet.c:1303 [inline]
       fanout_demux_rollover+0x33e/0x3f0 net/packet/af_packet.c:1353
       packet_rcv_fanout+0x34e/0x490 net/packet/af_packet.c:1453
       deliver_skb net/core/dev.c:1888 [inline]
       dev_queue_xmit_nit+0x15b/0x540 net/core/dev.c:1958
       xmit_one net/core/dev.c:3195 [inline]
       dev_hard_start_xmit+0x3f5/0x430 net/core/dev.c:3215
       __dev_queue_xmit+0x14ab/0x1b40 net/core/dev.c:3792
       dev_queue_xmit+0x21/0x30 net/core/dev.c:3825
       neigh_direct_output+0x1f/0x30 net/core/neighbour.c:1530
       neigh_output include/net/neighbour.h:511 [inline]
       ip6_finish_output2+0x7a2/0xec0 net/ipv6/ip6_output.c:116
       __ip6_finish_output net/ipv6/ip6_output.c:142 [inline]
       __ip6_finish_output+0x2d7/0x330 net/ipv6/ip6_output.c:127
       ip6_finish_output+0x41/0x160 net/ipv6/ip6_output.c:152
       NF_HOOK_COND include/linux/netfilter.h:294 [inline]
       ip6_output+0xf2/0x280 net/ipv6/ip6_output.c:175
       dst_output include/net/dst.h:436 [inline]
       ip6_local_out+0x74/0x90 net/ipv6/output_core.c:179
       ip6_send_skb+0x53/0x110 net/ipv6/ip6_output.c:1795
       udp_v6_send_skb.isra.0+0x3ec/0xa70 net/ipv6/udp.c:1173
       udpv6_sendmsg+0x1906/0x1c20 net/ipv6/udp.c:1471
       inet6_sendmsg+0x6d/0x90 net/ipv6/af_inet6.c:576
       sock_sendmsg_nosec net/socket.c:637 [inline]
       sock_sendmsg+0x9f/0xc0 net/socket.c:657
       ___sys_sendmsg+0x2b7/0x5d0 net/socket.c:2311
       __sys_sendmmsg+0x123/0x350 net/socket.c:2413
       __do_sys_sendmmsg net/socket.c:2442 [inline]
       __se_sys_sendmmsg net/socket.c:2439 [inline]
       __x64_sys_sendmmsg+0x64/0x80 net/socket.c:2439
       do_syscall_64+0xcc/0x370 arch/x86/entry/common.c:290
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      write to 0xffff8880b01786cc of 4 bytes by task 18922 on cpu 0:
       fanout_flow_is_huge net/packet/af_packet.c:1306 [inline]
       fanout_demux_rollover+0x3a4/0x3f0 net/packet/af_packet.c:1353
       packet_rcv_fanout+0x34e/0x490 net/packet/af_packet.c:1453
       deliver_skb net/core/dev.c:1888 [inline]
       dev_queue_xmit_nit+0x15b/0x540 net/core/dev.c:1958
       xmit_one net/core/dev.c:3195 [inline]
       dev_hard_start_xmit+0x3f5/0x430 net/core/dev.c:3215
       __dev_queue_xmit+0x14ab/0x1b40 net/core/dev.c:3792
       dev_queue_xmit+0x21/0x30 net/core/dev.c:3825
       neigh_direct_output+0x1f/0x30 net/core/neighbour.c:1530
       neigh_output include/net/neighbour.h:511 [inline]
       ip6_finish_output2+0x7a2/0xec0 net/ipv6/ip6_output.c:116
       __ip6_finish_output net/ipv6/ip6_output.c:142 [inline]
       __ip6_finish_output+0x2d7/0x330 net/ipv6/ip6_output.c:127
       ip6_finish_output+0x41/0x160 net/ipv6/ip6_output.c:152
       NF_HOOK_COND include/linux/netfilter.h:294 [inline]
       ip6_output+0xf2/0x280 net/ipv6/ip6_output.c:175
       dst_output include/net/dst.h:436 [inline]
       ip6_local_out+0x74/0x90 net/ipv6/output_core.c:179
       ip6_send_skb+0x53/0x110 net/ipv6/ip6_output.c:1795
       udp_v6_send_skb.isra.0+0x3ec/0xa70 net/ipv6/udp.c:1173
       udpv6_sendmsg+0x1906/0x1c20 net/ipv6/udp.c:1471
       inet6_sendmsg+0x6d/0x90 net/ipv6/af_inet6.c:576
       sock_sendmsg_nosec net/socket.c:637 [inline]
       sock_sendmsg+0x9f/0xc0 net/socket.c:657
       ___sys_sendmsg+0x2b7/0x5d0 net/socket.c:2311
       __sys_sendmmsg+0x123/0x350 net/socket.c:2413
       __do_sys_sendmmsg net/socket.c:2442 [inline]
       __se_sys_sendmmsg net/socket.c:2439 [inline]
       __x64_sys_sendmmsg+0x64/0x80 net/socket.c:2439
       do_syscall_64+0xcc/0x370 arch/x86/entry/common.c:290
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Reported by Kernel Concurrency Sanitizer on:
      CPU: 0 PID: 18922 Comm: syz-executor.3 Not tainted 5.4.0-rc6+ #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      
      Fixes: 3b3a5b0a ("packet: rollover huge flows before small flows")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Willem de Bruijn <willemb@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      451081e3
    • Eric Dumazet's avatar
      net: neigh: use long type to store jiffies delta · ce556411
      Eric Dumazet authored
      [ Upstream commit 9d027e3a ]
      
      A difference of two unsigned long needs long storage.
      
      Fixes: c7fb64db ("[NETLINK]: Neighbour table configuration and statistics via rtnetlink")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ce556411
    • Tiezhu Yang's avatar
      MIPS: Loongson: Fix return value of loongson_hwmon_init · 00a9d1a8
      Tiezhu Yang authored
      [ Upstream commit dece3c2a ]
      
      When call function hwmon_device_register failed, use the actual
      return value instead of always -ENOMEM.
      
      Fixes: 64f09aa9 ("MIPS: Loongson-3: Add CPU Hwmon platform driver")
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: default avatarPaul Burton <paulburton@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: linux-mips@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      00a9d1a8
    • Janusz Krzysztofik's avatar
      media: ov6650: Fix .get_fmt() V4L2_SUBDEV_FORMAT_TRY support · 44369fbe
      Janusz Krzysztofik authored
      [ Upstream commit 39034bb0 ]
      
      Commit da298c6d ("[media] v4l2: replace video op g_mbus_fmt by pad
      op get_fmt") converted a former ov6650_g_fmt() video operation callback
      to an ov6650_get_fmt() pad operation callback.  However, the converted
      function disregards a format->which flag that pad operations should
      obey and always returns active frame format settings.
      
      That can be fixed by always responding to V4L2_SUBDEV_FORMAT_TRY with
      -EINVAL, or providing the response from a pad config argument, likely
      updated by a former user call to V4L2_SUBDEV_FORMAT_TRY .set_fmt().
      Since implementation of the latter is trivial, go for it.
      
      Fixes: da298c6d ("[media] v4l2: replace video op g_mbus_fmt by pad op get_fmt")
      Signed-off-by: default avatarJanusz Krzysztofik <jmkrzyszt@gmail.com>
      Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      44369fbe
    • Janusz Krzysztofik's avatar
      media: ov6650: Fix some format attributes not under control · 4da060ae
      Janusz Krzysztofik authored
      [ Upstream commit 1c6a2b63 ]
      
      User arguments passed to .get/set_fmt() pad operation callbacks may
      contain unsupported values.  The driver takes control over frame size
      and pixel code as well as colorspace and field attributes but has never
      cared for remainig format attributes, i.e., ycbcr_enc, quantization
      and xfer_func, introduced by commit 11ff030c ("[media]
      v4l2-mediabus: improve colorspace support").  Fix it.
      
      Set up a static v4l2_mbus_framefmt structure with attributes
      initialized to reasonable defaults and use it for updating content of
      user provided arguments.  In case of V4L2_SUBDEV_FORMAT_ACTIVE,
      postpone frame size update, now performed from inside ov6650_s_fmt()
      helper, util the user argument is first updated in ov6650_set_fmt() with
      default frame format content.  For V4L2_SUBDEV_FORMAT_TRY, don't copy
      all attributes to pad config, only those handled by the driver, then
      fill the response with the default frame format updated with resulting
      pad config format code and frame size.
      
      Fixes: 11ff030c ("[media] v4l2-mediabus: improve colorspace support")
      Signed-off-by: default avatarJanusz Krzysztofik <jmkrzyszt@gmail.com>
      Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4da060ae
    • Janusz Krzysztofik's avatar
      media: ov6650: Fix incorrect use of JPEG colorspace · c0a3bcd0
      Janusz Krzysztofik authored
      [ Upstream commit 12500731 ]
      
      Since its initial submission, the driver selects V4L2_COLORSPACE_JPEG
      for supported formats other than V4L2_MBUS_FMT_SBGGR8_1X8.  According
      to v4l2-compliance test program, V4L2_COLORSPACE_JPEG applies
      exclusively to V4L2_PIX_FMT_JPEG.  Since the sensor does not support
      JPEG format, fix it to always select V4L2_COLORSPACE_SRGB.
      
      Fixes: 2f6e2404 ("[media] SoC Camera: add driver for OV6650 sensor")
      Signed-off-by: default avatarJanusz Krzysztofik <jmkrzyszt@gmail.com>
      Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c0a3bcd0
    • Marc Dionne's avatar
      afs: Fix large file support · d05ad8ba
      Marc Dionne authored
      [ Upstream commit b485275f ]
      
      By default s_maxbytes is set to MAX_NON_LFS, which limits the usable
      file size to 2GB, enforced by the vfs.
      
      Commit b9b1f8d5 ("AFS: write support fixes") added support for the
      64-bit fetch and store server operations, but did not change this value.
      As a result, attempts to write past the 2G mark result in EFBIG errors:
      
       $ dd if=/dev/zero of=foo bs=1M count=1 seek=2048
       dd: error writing 'foo': File too large
      
      Set s_maxbytes to MAX_LFS_FILESIZE.
      
      Fixes: b9b1f8d5 ("AFS: write support fixes")
      Signed-off-by: default avatarMarc Dionne <marc.dionne@auristor.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d05ad8ba
    • Stefan Wahren's avatar
      net: qca_spi: Move reset_count to struct qcaspi · 153d04c3
      Stefan Wahren authored
      [ Upstream commit bc19c329 ]
      
      The reset counter is specific for every QCA700x chip. So move this
      into the private driver struct. Otherwise we get unpredictable reset
      behavior in setups with multiple QCA700x chips.
      
      Fixes: 291ab06e (net: qualcomm: new Ethernet over SPI driver for QCA7000)
      Signed-off-by: default avatarStefan Wahren <stefan.wahren@in-tech.com>
      Signed-off-by: default avatarStefan Wahren <wahrenst@gmx.net>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      153d04c3
    • Jakub Kicinski's avatar
      net: netem: correct the parent's backlog when corrupted packet was dropped · 37b41ca4
      Jakub Kicinski authored
      [ Upstream commit e0ad032e ]
      
      If packet corruption failed we jump to finish_segs and return
      NET_XMIT_SUCCESS. Seeing success will make the parent qdisc
      increment its backlog, that's incorrect - we need to return
      NET_XMIT_DROP.
      
      Fixes: 6071bd1a ("netem: Segment GSO packets on enqueue")
      Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Reviewed-by: default avatarSimon Horman <simon.horman@netronome.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      37b41ca4
    • Jakub Kicinski's avatar
      net: netem: fix error path for corrupted GSO frames · 21a554f9
      Jakub Kicinski authored
      [ Upstream commit a7fa12d1 ]
      
      To corrupt a GSO frame we first perform segmentation.  We then
      proceed using the first segment instead of the full GSO skb and
      requeue the rest of the segments as separate packets.
      
      If there are any issues with processing the first segment we
      still want to process the rest, therefore we jump to the
      finish_segs label.
      
      Commit 177b8007 ("net: netem: fix backlog accounting for
      corrupted GSO frames") started using the pointer to the first
      segment in the "rest of segments processing", but as mentioned
      above the first segment may had already been freed at this point.
      
      Backlog corrections for parent qdiscs have to be adjusted.
      
      Fixes: 177b8007 ("net: netem: fix backlog accounting for corrupted GSO frames")
      Reported-by: default avatarkbuild test robot <lkp@intel.com>
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Reported-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Reviewed-by: default avatarSimon Horman <simon.horman@netronome.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      21a554f9
    • Robin Gong's avatar
      dmaengine: imx-sdma: fix size check for sdma script_number · 9e0951ca
      Robin Gong authored
      [ Upstream commit bd73dfab ]
      
      Illegal memory will be touch if SDMA_SCRIPT_ADDRS_ARRAY_SIZE_V3
      (41) exceed the size of structure sdma_script_start_addrs(40),
      thus cause memory corrupt such as slob block header so that kernel
      trap into while() loop forever in slob_free(). Please refer to below
      code piece in imx-sdma.c:
      for (i = 0; i < sdma->script_number; i++)
      	if (addr_arr[i] > 0)
      		saddr_arr[i] = addr_arr[i]; /* memory corrupt here */
      That issue was brought by commit a572460b ("dmaengine: imx-sdma: Add
      support for version 3 firmware") because SDMA_SCRIPT_ADDRS_ARRAY_SIZE_V3
      (38->41 3 scripts added) not align with script number added in
      sdma_script_start_addrs(2 scripts).
      
      Fixes: a572460b ("dmaengine: imx-sdma: Add support for version 3 firmware")
      Cc: stable@vger.kernel
      Link: https://www.spinics.net/lists/arm-kernel/msg754895.htmlSigned-off-by: default avatarRobin Gong <yibin.gong@nxp.com>
      Reported-by: default avatarJurgen Lambrecht <J.Lambrecht@TELEVIC.com>
      Link: https://lore.kernel.org/r/1569347584-3478-1-git-send-email-yibin.gong@nxp.com
      [vkoul: update the patch title]
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9e0951ca
    • Jeffrey Hugo's avatar
      drm/msm/dsi: Implement reset correctly · a3d539f3
      Jeffrey Hugo authored
      [ Upstream commit 78e31c42 ]
      
      On msm8998, vblank timeouts are observed because the DSI controller is not
      reset properly, which ends up stalling the MDP.  This is because the reset
      logic is not correct per the hardware documentation.
      
      The documentation states that after asserting reset, software should wait
      some time (no indication of how long), or poll the status register until it
      returns 0 before deasserting reset.
      
      wmb() is insufficient for this purpose since it just ensures ordering, not
      timing between writes.  Since asserting and deasserting reset occurs on the
      same register, ordering is already guaranteed by the architecture, making
      the wmb extraneous.
      
      Since we would define a timeout for polling the status register to avoid a
      possible infinite loop, lets just use a static delay of 20 ms, since 16.666
      ms is the time available to process one frame at 60 fps.
      
      Fixes: a689554b ("drm/msm: Initial add DSI connector support")
      Cc: Hai Li <hali@codeaurora.org>
      Cc: Rob Clark <robdclark@gmail.com>
      Signed-off-by: default avatarJeffrey Hugo <jeffrey.l.hugo@gmail.com>
      Reviewed-by: default avatarSean Paul <sean@poorly.run>
      [seanpaul renamed RESET_DELAY to DSI_RESET_TOGGLE_DELAY_MS]
      Signed-off-by: default avatarSean Paul <seanpaul@chromium.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/20191011133939.16551-1-jeffrey.l.hugo@gmail.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      a3d539f3
    • YueHaibing's avatar
      act_mirred: Fix mirred_init_module error handling · ac639902
      YueHaibing authored
      [ Upstream commit 11c9a7d3 ]
      
      If tcf_register_action failed, mirred_device_notifier
      should be unregistered.
      
      Fixes: 3b87956e ("net sched: fix race in mirred device removal")
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ac639902
    • Antonio Borneo's avatar
      net: stmmac: fix length of PTP clock's name string · 8b998543
      Antonio Borneo authored
      [ Upstream commit 5da202c8 ]
      
      The field "name" in struct ptp_clock_info has a fixed size of 16
      chars and is used as zero terminated string by clock_name_show()
      in drivers/ptp/ptp_sysfs.c
      The current initialization value requires 17 chars to fit also the
      null termination, and this causes overflow to the next bytes in
      the struct when the string is read as null terminated:
      	hexdump -C /sys/class/ptp/ptp0/clock_name
      	00000000  73 74 6d 6d 61 63 5f 70  74 70 5f 63 6c 6f 63 6b  |stmmac_ptp_clock|
      	00000010  a0 ac b9 03 0a                                    |.....|
      where the extra 4 bytes (excluding the newline) after the string
      represent the integer 0x03b9aca0 = 62500000 assigned to the field
      "max_adj" that follows "name" in the same struct.
      
      There is no strict requirement for the "name" content and in the
      comment in ptp_clock_kernel.h it's reported it should just be 'A
      short "friendly name" to identify the clock'.
      Replace it with "stmmac ptp".
      Signed-off-by: default avatarAntonio Borneo <antonio.borneo@st.com>
      Fixes: 92ba6888 ("stmmac: add the support for PTP hw clock driver")
      Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8b998543