1. 20 Jun, 2020 40 commits
    • Arvind Sankar's avatar
      x86/boot: Correct relocation destination on old linkers · 93b6bebe
      Arvind Sankar authored
      [ Upstream commit 5214028d ]
      
      For the 32-bit kernel, as described in
      
        6d92bc9d ("x86/build: Build compressed x86 kernels as PIE"),
      
      pre-2.26 binutils generates R_386_32 relocations in PIE mode. Since the
      startup code does not perform relocation, any reloc entry with R_386_32
      will remain as 0 in the executing code.
      
      Commit
      
        974f221c ("x86/boot: Move compressed kernel to the end of the
                       decompression buffer")
      
      added a new symbol _end but did not mark it hidden, which doesn't give
      the correct offset on older linkers. This causes the compressed kernel
      to be copied beyond the end of the decompression buffer, rather than
      flush against it. This region of memory may be reserved or already
      allocated for other purposes by the bootloader.
      
      Mark _end as hidden to fix. This changes the relocation from R_386_32 to
      R_386_RELATIVE even on the pre-2.26 binutils.
      
      For 64-bit, this is not strictly necessary, as the 64-bit kernel is only
      built as PIE if the linker supports -z noreloc-overflow, which implies
      binutils-2.27+, but for consistency, mark _end as hidden here too.
      
      The below illustrates the before/after impact of the patch using
      binutils-2.25 and gcc-4.6.4 (locally compiled from source) and QEMU.
      
        Disassembly before patch:
          48:   8b 86 60 02 00 00       mov    0x260(%esi),%eax
          4e:   2d 00 00 00 00          sub    $0x0,%eax
                                4f: R_386_32    _end
        Disassembly after patch:
          48:   8b 86 60 02 00 00       mov    0x260(%esi),%eax
          4e:   2d 00 f0 76 00          sub    $0x76f000,%eax
                                4f: R_386_RELATIVE      *ABS*
      
      Dump from extract_kernel before patch:
      	early console in extract_kernel
      	input_data: 0x0207c098 <--- this is at output + init_size
      	input_len: 0x0074fef1
      	output: 0x01000000
      	output_len: 0x00fa63d0
      	kernel_total_size: 0x0107c000
      	needed_size: 0x0107c000
      
      Dump from extract_kernel after patch:
      	early console in extract_kernel
      	input_data: 0x0190d098 <--- this is at output + init_size - _end
      	input_len: 0x0074fef1
      	output: 0x01000000
      	output_len: 0x00fa63d0
      	kernel_total_size: 0x0107c000
      	needed_size: 0x0107c000
      
      Fixes: 974f221c ("x86/boot: Move compressed kernel to the end of the decompression buffer")
      Signed-off-by: default avatarArvind Sankar <nivedita@alum.mit.edu>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Link: https://lkml.kernel.org/r/20200207214926.3564079-1-nivedita@alum.mit.eduSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      93b6bebe
    • Pali Rohár's avatar
      mwifiex: Fix memory corruption in dump_station · 33c2268e
      Pali Rohár authored
      [ Upstream commit 3aa42bae ]
      
      The mwifiex_cfg80211_dump_station() uses static variable for iterating
      over a linked list of all associated stations (when the driver is in UAP
      role). This has a race condition if .dump_station is called in parallel
      for multiple interfaces. This corruption can be triggered by registering
      multiple SSIDs and calling, in parallel for multiple interfaces
          iw dev <iface> station dump
      
      [16750.719775] Unable to handle kernel paging request at virtual address dead000000000110
      ...
      [16750.899173] Call trace:
      [16750.901696]  mwifiex_cfg80211_dump_station+0x94/0x100 [mwifiex]
      [16750.907824]  nl80211_dump_station+0xbc/0x278 [cfg80211]
      [16750.913160]  netlink_dump+0xe8/0x320
      [16750.916827]  netlink_recvmsg+0x1b4/0x338
      [16750.920861]  ____sys_recvmsg+0x7c/0x2b0
      [16750.924801]  ___sys_recvmsg+0x70/0x98
      [16750.928564]  __sys_recvmsg+0x58/0xa0
      [16750.932238]  __arm64_sys_recvmsg+0x28/0x30
      [16750.936453]  el0_svc_common.constprop.3+0x90/0x158
      [16750.941378]  do_el0_svc+0x74/0x90
      [16750.944784]  el0_sync_handler+0x12c/0x1a8
      [16750.948903]  el0_sync+0x114/0x140
      [16750.952312] Code: f9400003 f907f423 eb02007f 54fffd60 (b9401060)
      [16750.958583] ---[ end trace c8ad181c2f4b8576 ]---
      
      This patch drops the use of the static iterator, and instead every time
      the function is called iterates to the idx-th position of the
      linked-list.
      
      It would be better to convert the code not to use linked list for
      associated stations storage (since the chip has a limited number of
      associated stations anyway - it could just be an array). Such a change
      may be proposed in the future. In the meantime this patch can backported
      into stable kernels in this simple form.
      
      Fixes: 8baca1a3 ("mwifiex: dump station support in uap mode")
      Signed-off-by: default avatarPali Rohár <pali@kernel.org>
      Acked-by: default avatarGanapathi Bhat <ganapathi.bhat@nxp.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20200515075924.13841-1-pali@kernel.orgSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      33c2268e
    • Dan Carpenter's avatar
      rtlwifi: Fix a double free in _rtl_usb_tx_urb_setup() · 5f78833e
      Dan Carpenter authored
      [ Upstream commit beb12813 ]
      
      Seven years ago we tried to fix a leak but actually introduced a double
      free instead.  It was an understandable mistake because the code was a
      bit confusing and the free was done in the wrong place.  The "skb"
      pointer is freed in both _rtl_usb_tx_urb_setup() and _rtl_usb_transmit().
      The free belongs _rtl_usb_transmit() instead of _rtl_usb_tx_urb_setup()
      and I've cleaned the code up a bit to hopefully make it more clear.
      
      Fixes: 36ef0b47 ("rtlwifi: usb: add missing freeing of skbuff")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20200513093951.GD347693@mwandaSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      5f78833e
    • Guoqing Jiang's avatar
      md: don't flush workqueue unconditionally in md_open · 9e9b57c4
      Guoqing Jiang authored
      [ Upstream commit f6766ff6 ]
      
      We need to check mddev->del_work before flush workqueu since the purpose
      of flush is to ensure the previous md is disappeared. Otherwise the similar
      deadlock appeared if LOCKDEP is enabled, it is due to md_open holds the
      bdev->bd_mutex before flush workqueue.
      
      kernel: [  154.522645] ======================================================
      kernel: [  154.522647] WARNING: possible circular locking dependency detected
      kernel: [  154.522650] 5.6.0-rc7-lp151.27-default #25 Tainted: G           O
      kernel: [  154.522651] ------------------------------------------------------
      kernel: [  154.522653] mdadm/2482 is trying to acquire lock:
      kernel: [  154.522655] ffff888078529128 ((wq_completion)md_misc){+.+.}, at: flush_workqueue+0x84/0x4b0
      kernel: [  154.522673]
      kernel: [  154.522673] but task is already holding lock:
      kernel: [  154.522675] ffff88804efa9338 (&bdev->bd_mutex){+.+.}, at: __blkdev_get+0x79/0x590
      kernel: [  154.522691]
      kernel: [  154.522691] which lock already depends on the new lock.
      kernel: [  154.522691]
      kernel: [  154.522694]
      kernel: [  154.522694] the existing dependency chain (in reverse order) is:
      kernel: [  154.522696]
      kernel: [  154.522696] -> #4 (&bdev->bd_mutex){+.+.}:
      kernel: [  154.522704]        __mutex_lock+0x87/0x950
      kernel: [  154.522706]        __blkdev_get+0x79/0x590
      kernel: [  154.522708]        blkdev_get+0x65/0x140
      kernel: [  154.522709]        blkdev_get_by_dev+0x2f/0x40
      kernel: [  154.522716]        lock_rdev+0x3d/0x90 [md_mod]
      kernel: [  154.522719]        md_import_device+0xd6/0x1b0 [md_mod]
      kernel: [  154.522723]        new_dev_store+0x15e/0x210 [md_mod]
      kernel: [  154.522728]        md_attr_store+0x7a/0xc0 [md_mod]
      kernel: [  154.522732]        kernfs_fop_write+0x117/0x1b0
      kernel: [  154.522735]        vfs_write+0xad/0x1a0
      kernel: [  154.522737]        ksys_write+0xa4/0xe0
      kernel: [  154.522745]        do_syscall_64+0x64/0x2b0
      kernel: [  154.522748]        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      kernel: [  154.522749]
      kernel: [  154.522749] -> #3 (&mddev->reconfig_mutex){+.+.}:
      kernel: [  154.522752]        __mutex_lock+0x87/0x950
      kernel: [  154.522756]        new_dev_store+0xc9/0x210 [md_mod]
      kernel: [  154.522759]        md_attr_store+0x7a/0xc0 [md_mod]
      kernel: [  154.522761]        kernfs_fop_write+0x117/0x1b0
      kernel: [  154.522763]        vfs_write+0xad/0x1a0
      kernel: [  154.522765]        ksys_write+0xa4/0xe0
      kernel: [  154.522767]        do_syscall_64+0x64/0x2b0
      kernel: [  154.522769]        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      kernel: [  154.522770]
      kernel: [  154.522770] -> #2 (kn->count#253){++++}:
      kernel: [  154.522775]        __kernfs_remove+0x253/0x2c0
      kernel: [  154.522778]        kernfs_remove+0x1f/0x30
      kernel: [  154.522780]        kobject_del+0x28/0x60
      kernel: [  154.522783]        mddev_delayed_delete+0x24/0x30 [md_mod]
      kernel: [  154.522786]        process_one_work+0x2a7/0x5f0
      kernel: [  154.522788]        worker_thread+0x2d/0x3d0
      kernel: [  154.522793]        kthread+0x117/0x130
      kernel: [  154.522795]        ret_from_fork+0x3a/0x50
      kernel: [  154.522796]
      kernel: [  154.522796] -> #1 ((work_completion)(&mddev->del_work)){+.+.}:
      kernel: [  154.522800]        process_one_work+0x27e/0x5f0
      kernel: [  154.522802]        worker_thread+0x2d/0x3d0
      kernel: [  154.522804]        kthread+0x117/0x130
      kernel: [  154.522806]        ret_from_fork+0x3a/0x50
      kernel: [  154.522807]
      kernel: [  154.522807] -> #0 ((wq_completion)md_misc){+.+.}:
      kernel: [  154.522813]        __lock_acquire+0x1392/0x1690
      kernel: [  154.522816]        lock_acquire+0xb4/0x1a0
      kernel: [  154.522818]        flush_workqueue+0xab/0x4b0
      kernel: [  154.522821]        md_open+0xb6/0xc0 [md_mod]
      kernel: [  154.522823]        __blkdev_get+0xea/0x590
      kernel: [  154.522825]        blkdev_get+0x65/0x140
      kernel: [  154.522828]        do_dentry_open+0x1d1/0x380
      kernel: [  154.522831]        path_openat+0x567/0xcc0
      kernel: [  154.522834]        do_filp_open+0x9b/0x110
      kernel: [  154.522836]        do_sys_openat2+0x201/0x2a0
      kernel: [  154.522838]        do_sys_open+0x57/0x80
      kernel: [  154.522840]        do_syscall_64+0x64/0x2b0
      kernel: [  154.522842]        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      kernel: [  154.522844]
      kernel: [  154.522844] other info that might help us debug this:
      kernel: [  154.522844]
      kernel: [  154.522846] Chain exists of:
      kernel: [  154.522846]   (wq_completion)md_misc --> &mddev->reconfig_mutex --> &bdev->bd_mutex
      kernel: [  154.522846]
      kernel: [  154.522850]  Possible unsafe locking scenario:
      kernel: [  154.522850]
      kernel: [  154.522852]        CPU0                    CPU1
      kernel: [  154.522853]        ----                    ----
      kernel: [  154.522854]   lock(&bdev->bd_mutex);
      kernel: [  154.522856]                                lock(&mddev->reconfig_mutex);
      kernel: [  154.522858]                                lock(&bdev->bd_mutex);
      kernel: [  154.522860]   lock((wq_completion)md_misc);
      kernel: [  154.522861]
      kernel: [  154.522861]  *** DEADLOCK ***
      kernel: [  154.522861]
      kernel: [  154.522864] 1 lock held by mdadm/2482:
      kernel: [  154.522865]  #0: ffff88804efa9338 (&bdev->bd_mutex){+.+.}, at: __blkdev_get+0x79/0x590
      kernel: [  154.522868]
      kernel: [  154.522868] stack backtrace:
      kernel: [  154.522873] CPU: 1 PID: 2482 Comm: mdadm Tainted: G           O      5.6.0-rc7-lp151.27-default #25
      kernel: [  154.522875] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014
      kernel: [  154.522878] Call Trace:
      kernel: [  154.522881]  dump_stack+0x8f/0xcb
      kernel: [  154.522884]  check_noncircular+0x194/0x1b0
      kernel: [  154.522888]  ? __lock_acquire+0x1392/0x1690
      kernel: [  154.522890]  __lock_acquire+0x1392/0x1690
      kernel: [  154.522893]  lock_acquire+0xb4/0x1a0
      kernel: [  154.522895]  ? flush_workqueue+0x84/0x4b0
      kernel: [  154.522898]  flush_workqueue+0xab/0x4b0
      kernel: [  154.522900]  ? flush_workqueue+0x84/0x4b0
      kernel: [  154.522905]  ? md_open+0xb6/0xc0 [md_mod]
      kernel: [  154.522908]  md_open+0xb6/0xc0 [md_mod]
      kernel: [  154.522910]  __blkdev_get+0xea/0x590
      kernel: [  154.522912]  ? bd_acquire+0xc0/0xc0
      kernel: [  154.522914]  blkdev_get+0x65/0x140
      kernel: [  154.522916]  ? bd_acquire+0xc0/0xc0
      kernel: [  154.522918]  do_dentry_open+0x1d1/0x380
      kernel: [  154.522921]  path_openat+0x567/0xcc0
      kernel: [  154.522923]  ? __lock_acquire+0x380/0x1690
      kernel: [  154.522926]  do_filp_open+0x9b/0x110
      kernel: [  154.522929]  ? __alloc_fd+0xe5/0x1f0
      kernel: [  154.522935]  ? kmem_cache_alloc+0x28c/0x630
      kernel: [  154.522939]  ? do_sys_openat2+0x201/0x2a0
      kernel: [  154.522941]  do_sys_openat2+0x201/0x2a0
      kernel: [  154.522944]  do_sys_open+0x57/0x80
      kernel: [  154.522946]  do_syscall_64+0x64/0x2b0
      kernel: [  154.522948]  entry_SYSCALL_64_after_hwframe+0x49/0xbe
      kernel: [  154.522951] RIP: 0033:0x7f98d279d9ae
      
      And md_alloc also flushed the same workqueue, but the thing is different
      here. Because all the paths call md_alloc don't hold bdev->bd_mutex, and
      the flush is necessary to avoid race condition, so leave it as it is.
      Signed-off-by: default avatarGuoqing Jiang <guoqing.jiang@cloud.ionos.com>
      Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9e9b57c4
    • Daniel Thompson's avatar
      kgdb: Fix spurious true from in_dbg_master() · fb228bf2
      Daniel Thompson authored
      [ Upstream commit 3fec4aec ]
      
      Currently there is a small window where a badly timed migration could
      cause in_dbg_master() to spuriously return true. Specifically if we
      migrate to a new core after reading the processor id and the previous
      core takes a breakpoint then we will evaluate true if we read
      kgdb_active before we get the IPI to bring us to halt.
      
      Fix this by checking irqs_disabled() first. Interrupts are always
      disabled when we are executing the kgdb trap so this is an acceptable
      prerequisite. This also allows us to replace raw_smp_processor_id()
      with smp_processor_id() since the short circuit logic will prevent
      warnings from PREEMPT_DEBUG.
      
      Fixes: dcc78711 ("kgdb: core changes to support kdb")
      Suggested-by: default avatarWill Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20200506164223.2875760-1-daniel.thompson@linaro.orgReviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
      Signed-off-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fb228bf2
    • Serge Semin's avatar
      mips: cm: Fix an invalid error code of INTVN_*_ERR · bb3bcde1
      Serge Semin authored
      [ Upstream commit 8a0efb8b ]
      
      Commit 3885c2b4 ("MIPS: CM: Add support for reporting CM cache
      errors") adds cm2_causes[] array with map of error type ID and
      pointers to the short description string. There is a mistake in
      the table, since according to MIPS32 manual CM2_ERROR_TYPE = {17,18}
      correspond to INTVN_WR_ERR and INTVN_RD_ERR, while the table
      claims they have {0x17,0x18} codes. This is obviously hex-dec
      copy-paste bug. Moreover codes {0x18 - 0x1a} indicate L2 ECC errors.
      
      Fixes: 3885c2b4 ("MIPS: CM: Add support for reporting CM cache errors")
      Signed-off-by: default avatarSerge Semin <Sergey.Semin@baikalelectronics.ru>
      Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Paul Burton <paulburton@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: linux-pm@vger.kernel.org
      Cc: devicetree@vger.kernel.org
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bb3bcde1
    • Jiaxun Yang's avatar
      MIPS: Truncate link address into 32bit for 32bit kernel · 8b01fb17
      Jiaxun Yang authored
      [ Upstream commit ff487d41 ]
      
      LLD failed to link vmlinux with 64bit load address for 32bit ELF
      while bfd will strip 64bit address into 32bit silently.
      To fix LLD build, we should truncate load address provided by platform
      into 32bit for 32bit kernel.
      Signed-off-by: default avatarJiaxun Yang <jiaxun.yang@flygoat.com>
      Link: https://github.com/ClangBuiltLinux/linux/issues/786
      Link: https://sourceware.org/bugzilla/show_bug.cgi?id=25784Reviewed-by: default avatarFangrui Song <maskray@google.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Tested-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Cc: Maciej W. Rozycki <macro@linux-mips.org>
      Tested-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8b01fb17
    • Jeremy Kerr's avatar
      powerpc/spufs: fix copy_to_user while atomic · 123a8d0b
      Jeremy Kerr authored
      [ Upstream commit 88413a6b ]
      
      Currently, we may perform a copy_to_user (through
      simple_read_from_buffer()) while holding a context's register_lock,
      while accessing the context save area.
      
      This change uses a temporary buffer for the context save area data,
      which we then pass to simple_read_from_buffer.
      
      Includes changes from Christoph Hellwig <hch@lst.de>.
      
      Fixes: bf1ab978 ("[POWERPC] coredump: Add SPU elf notes to coredump.")
      Signed-off-by: default avatarJeremy Kerr <jk@ozlabs.org>
      Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
      [hch: renamed to function to avoid ___-prefixes]
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      123a8d0b
    • Yunjian Wang's avatar
      net: allwinner: Fix use correct return type for ndo_start_xmit() · 720b4f27
      Yunjian Wang authored
      [ Upstream commit 09f6c44a ]
      
      The method ndo_start_xmit() returns a value of type netdev_tx_t. Fix
      the ndo function to use the correct type. And emac_start_xmit() can
      leak one skb if 'channel' == 3.
      Signed-off-by: default avatarYunjian Wang <wangyunjian@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      720b4f27
    • Wei Yongjun's avatar
      net: lpc-enet: fix error return code in lpc_mii_init() · e6eadb14
      Wei Yongjun authored
      [ Upstream commit 88ec7cb2 ]
      
      Fix to return a negative error code from the error handling
      case instead of 0, as done elsewhere in this function.
      
      Fixes: b7370112 ("lpc32xx: Added ethernet driver")
      Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
      Acked-by: default avatarVladimir Zapolskiy <vz@mleia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e6eadb14
    • Jann Horn's avatar
      exit: Move preemption fixup up, move blocking operations down · 1e587ce7
      Jann Horn authored
      [ Upstream commit 586b58ca ]
      
      With CONFIG_DEBUG_ATOMIC_SLEEP=y and CONFIG_CGROUPS=y, kernel oopses in
      non-preemptible context look untidy; after the main oops, the kernel prints
      a "sleeping function called from invalid context" report because
      exit_signals() -> cgroup_threadgroup_change_begin() -> percpu_down_read()
      can sleep, and that happens before the preempt_count_set(PREEMPT_ENABLED)
      fixup.
      
      It looks like the same thing applies to profile_task_exit() and
      kcov_task_exit().
      
      Fix it by moving the preemption fixup up and the calls to
      profile_task_exit() and kcov_task_exit() down.
      
      Fixes: 1dc0fffc ("sched/core: Robustify preemption leak checks")
      Signed-off-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20200305220657.46800-1-jannh@google.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      1e587ce7
    • Nathan Chancellor's avatar
      lib/mpi: Fix 64-bit MIPS build with Clang · ed3cbbfe
      Nathan Chancellor authored
      [ Upstream commit 18f1ca46 ]
      
      When building 64r6_defconfig with CONFIG_MIPS32_O32 disabled and
      CONFIG_CRYPTO_RSA enabled:
      
      lib/mpi/generic_mpih-mul1.c:37:24: error: invalid use of a cast in a
      inline asm context requiring an l-value: remove the cast
      or build with -fheinous-gnu-extensions
                      umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
                      ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      lib/mpi/longlong.h:664:22: note: expanded from macro 'umul_ppmm'
                       : "=d" ((UDItype)(w0))
                               ~~~~~~~~~~^~~
      lib/mpi/generic_mpih-mul1.c:37:13: error: invalid use of a cast in a
      inline asm context requiring an l-value: remove the cast
      or build with -fheinous-gnu-extensions
                      umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
                      ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      lib/mpi/longlong.h:668:22: note: expanded from macro 'umul_ppmm'
                       : "=d" ((UDItype)(w1))
                               ~~~~~~~~~~^~~
      2 errors generated.
      
      This special case for umul_ppmm for MIPS64r6 was added in
      commit bbc25bee ("lib/mpi: Fix umul_ppmm() for MIPS64r6"), due to
      GCC being inefficient and emitting a __multi3 intrinsic.
      
      There is no such issue with clang; with this patch applied, I can build
      this configuration without any problems and there are no link errors
      like mentioned in the commit above (which I can still reproduce with
      GCC 9.3.0 when that commit is reverted). Only use this definition when
      GCC is being used.
      
      This really should have been caught by commit b0c091ae ("lib/mpi:
      Eliminate unused umul_ppmm definitions for MIPS") when I was messing
      around in this area but I was not testing 64-bit MIPS at the time.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/885Reported-by: default avatarDmitry Golovin <dima@golovin.in>
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ed3cbbfe
    • Pablo Neira Ayuso's avatar
      netfilter: nft_nat: return EOPNOTSUPP if type or flags are not supported · fbe0bd6f
      Pablo Neira Ayuso authored
      [ Upstream commit 0d7c8346 ]
      
      Instead of EINVAL which should be used for malformed netlink messages.
      
      Fixes: eb31628e ("netfilter: nf_tables: Add support for IPv6 NAT")
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fbe0bd6f
    • Tiezhu Yang's avatar
      MIPS: Make sparse_init() using top-down allocation · 6ff43399
      Tiezhu Yang authored
      [ Upstream commit 269b3a9a ]
      
      In the current code, if CONFIG_SWIOTLB is set, when failed to get IO TLB
      memory from the low pages by plat_swiotlb_setup(), it may lead to the boot
      process failed with kernel panic.
      
      (1) On the Loongson and SiByte platform
      arch/mips/loongson64/dma.c
      arch/mips/sibyte/common/dma.c
      void __init plat_swiotlb_setup(void)
      {
      	swiotlb_init(1);
      }
      
      kernel/dma/swiotlb.c
      void  __init
      swiotlb_init(int verbose)
      {
      ...
      	vstart = memblock_alloc_low(PAGE_ALIGN(bytes), PAGE_SIZE);
      	if (vstart && !swiotlb_init_with_tbl(vstart, io_tlb_nslabs, verbose))
      		return;
      ...
      	pr_warn("Cannot allocate buffer");
      	no_iotlb_memory = true;
      }
      
      phys_addr_t swiotlb_tbl_map_single()
      {
      ...
      	if (no_iotlb_memory)
      		panic("Can not allocate SWIOTLB buffer earlier ...");
      ...
      }
      
      (2) On the Cavium OCTEON platform
      arch/mips/cavium-octeon/dma-octeon.c
      void __init plat_swiotlb_setup(void)
      {
      ...
      	octeon_swiotlb = memblock_alloc_low(swiotlbsize, PAGE_SIZE);
      	if (!octeon_swiotlb)
      		panic("%s: Failed to allocate %zu bytes align=%lx\n",
      		      __func__, swiotlbsize, PAGE_SIZE);
      ...
      }
      
      Because IO_TLB_DEFAULT_SIZE is 64M, if the rest size of low memory is less
      than 64M when call plat_swiotlb_setup(), we can easily reproduce the panic
      case.
      
      In order to reduce the possibility of kernel panic when failed to get IO
      TLB memory under CONFIG_SWIOTLB, it is better to allocate low memory as
      small as possible before plat_swiotlb_setup(), so make sparse_init() using
      top-down allocation.
      Reported-by: default avatarJuxin Gao <gaojuxin@loongson.cn>
      Co-developed-by: default avatarJuxin Gao <gaojuxin@loongson.cn>
      Signed-off-by: default avatarJuxin Gao <gaojuxin@loongson.cn>
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6ff43399
    • Kieran Bingham's avatar
      media: platform: fcp: Set appropriate DMA parameters · 6ac24bdb
      Kieran Bingham authored
      [ Upstream commit dd844fb8 ]
      
      Enabling CONFIG_DMA_API_DEBUG=y and CONFIG_DMA_API_DEBUG_SG=y will
      enable extra validation on DMA operations ensuring that the size
      restraints are met.
      
      When using the FCP in conjunction with the VSP1/DU, and display frames,
      the size of the DMA operations is larger than the default maximum
      segment size reported by the DMA core (64K). With the DMA debug enabled,
      this produces a warning such as the following:
      
      "DMA-API: rcar-fcp fea27000.fcp: mapping sg segment longer than device
      claims to support [len=3145728] [max=65536]"
      
      We have no specific limitation on the segment size which isn't already
      handled by the VSP1/DU which actually handles the DMA allcoations and
      buffer management, so define a maximum segment size of up to 4GB (a 32
      bit mask).
      Reported-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Fixes: 7b49235e ("[media] v4l: Add Renesas R-Car FCP driver")
      Signed-off-by: default avatarKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
      Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Tested-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6ac24bdb
    • Colin Ian King's avatar
      media: dvb: return -EREMOTEIO on i2c transfer failure. · cef66945
      Colin Ian King authored
      [ Upstream commit 96f3a939 ]
      
      Currently when i2c transfers fail the error return -EREMOTEIO
      is assigned to err but then later overwritten when the tuner
      attach call is made.  Fix this by returning early with the
      error return code -EREMOTEIO on i2c transfer failure errors.
      
      If the transfer fails, an uninitialized value will be read from b2.
      
      Addresses-Coverity: ("Unused value")
      
      Fixes: fbfee868 ("V4L/DVB (5651): Dibusb-mb: convert pll handling to properly use dvb-pll")
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarSean Young <sean@mess.org>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cef66945
    • Jitao Shi's avatar
      dt-bindings: display: mediatek: control dpi pins mode to avoid leakage · c76a7a4a
      Jitao Shi authored
      [ Upstream commit b0ff9b59 ]
      
      Add property "pinctrl-names" to swap pin mode between gpio and dpi mode.
      Set the dpi pins to gpio mode and output-low to avoid leakage current
      when dpi disabled.
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarJitao Shi <jitao.shi@mediatek.com>
      Signed-off-by: default avatarChun-Kuang Hu <chunkuang.hu@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c76a7a4a
    • Kees Cook's avatar
      e1000: Distribute switch variables for initialization · ede1f11a
      Kees Cook authored
      [ Upstream commit a34c7f51 ]
      
      Variables declared in a switch statement before any case statements
      cannot be automatically initialized with compiler instrumentation (as
      they are not part of any execution flow). With GCC's proposed automatic
      stack variable initialization feature, this triggers a warning (and they
      don't get initialized). Clang's automatic stack variable initialization
      (via CONFIG_INIT_STACK_ALL=y) doesn't throw a warning, but it also
      doesn't initialize such variables[1]. Note that these warnings (or silent
      skipping) happen before the dead-store elimination optimization phase,
      so even when the automatic initializations are later elided in favor of
      direct initializations, the warnings remain.
      
      To avoid these problems, move such variables into the "case" where
      they're used or lift them up into the main function body.
      
      drivers/net/ethernet/intel/e1000/e1000_main.c: In function ‘e1000_xmit_frame’:
      drivers/net/ethernet/intel/e1000/e1000_main.c:3143:18: warning: statement will never be executed [-Wswitch-unreachable]
       3143 |     unsigned int pull_size;
            |                  ^~~~~~~~~
      
      [1] https://bugs.llvm.org/show_bug.cgi?id=44916Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ede1f11a
    • Christoph Hellwig's avatar
      staging: android: ion: use vmap instead of vm_map_ram · 40e12d9a
      Christoph Hellwig authored
      [ Upstream commit 5bf99174 ]
      
      vm_map_ram can keep mappings around after the vm_unmap_ram.  Using that
      with non-PAGE_KERNEL mappings can lead to all kinds of aliasing issues.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@c-s.fr>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Gao Xiang <xiang@kernel.org>
      Cc: Haiyang Zhang <haiyangz@microsoft.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: "K. Y. Srinivasan" <kys@microsoft.com>
      Cc: Laura Abbott <labbott@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Kelley <mikelley@microsoft.com>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Nitin Gupta <ngupta@vflare.org>
      Cc: Robin Murphy <robin.murphy@arm.com>
      Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
      Cc: Stephen Hemminger <sthemmin@microsoft.com>
      Cc: Sumit Semwal <sumit.semwal@linaro.org>
      Cc: Wei Liu <wei.liu@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Paul Mackerras <paulus@ozlabs.org>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Will Deacon <will@kernel.org>
      Link: http://lkml.kernel.org/r/20200414131348.444715-4-hch@lst.deSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      40e12d9a
    • Jia-Ju Bai's avatar
      net: vmxnet3: fix possible buffer overflow caused by bad DMA value in vmxnet3_get_rss() · f1e015f7
      Jia-Ju Bai authored
      [ Upstream commit 3e1c6846 ]
      
      The value adapter->rss_conf is stored in DMA memory, and it is assigned
      to rssConf, so rssConf->indTableSize can be modified at anytime by
      malicious hardware. Because rssConf->indTableSize is assigned to n,
      buffer overflow may occur when the code "rssConf->indTable[n]" is
      executed.
      
      To fix this possible bug, n is checked after being used.
      Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f1e015f7
    • Jon Doron's avatar
      x86/kvm/hyper-v: Explicitly align hcall param for kvm_hyperv_exit · 64a3108d
      Jon Doron authored
      [ Upstream commit f7d31e65 ]
      
      The problem the patch is trying to address is the fact that 'struct
      kvm_hyperv_exit' has different layout on when compiling in 32 and 64 bit
      modes.
      
      In 64-bit mode the default alignment boundary is 64 bits thus
      forcing extra gaps after 'type' and 'msr' but in 32-bit mode the
      boundary is at 32 bits thus no extra gaps.
      
      This is an issue as even when the kernel is 64 bit, the userspace using
      the interface can be both 32 and 64 bit but the same 32 bit userspace has
      to work with 32 bit kernel.
      
      The issue is fixed by forcing the 64 bit layout, this leads to ABI
      change for 32 bit builds and while we are obviously breaking '32 bit
      userspace with 32 bit kernel' case, we're fixing the '32 bit userspace
      with 64 bit kernel' one.
      
      As the interface has no (known) users and 32 bit KVM is rather baroque
      nowadays, this seems like a reasonable decision.
      Reviewed-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
      Signed-off-by: default avatarJon Doron <arilou@gmail.com>
      Message-Id: <20200424113746.3473563-2-arilou@gmail.com>
      Reviewed-by: default avatarRoman Kagan <rvkagan@yandex-team.ru>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      64a3108d
    • Linus Walleij's avatar
      ARM: 8978/1: mm: make act_mm() respect THREAD_SIZE · 58708a2f
      Linus Walleij authored
      [ Upstream commit e1de9438 ]
      
      Recent work with KASan exposed the folling hard-coded bitmask
      in arch/arm/mm/proc-macros.S:
      
        bic     rd, sp, #8128
        bic     rd, rd, #63
      
      This forms the bitmask 0x1FFF that is coinciding with
      (PAGE_SIZE << THREAD_SIZE_ORDER) - 1, this code was assuming
      that THREAD_SIZE is always 8K (8192).
      
      As KASan was increasing THREAD_SIZE_ORDER to 2, I ran into
      this bug.
      
      Fix it by this little oneline suggested by Ard:
      
        bic     rd, sp, #(THREAD_SIZE - 1) & ~63
      
      Where THREAD_SIZE is defined using THREAD_SIZE_ORDER.
      
      We have to also include <linux/const.h> since the THREAD_SIZE
      expands to use the _AC() macro.
      
      Cc: Ard Biesheuvel <ardb@kernel.org>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Suggested-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      58708a2f
    • Filipe Manana's avatar
      btrfs: do not ignore error from btrfs_next_leaf() when inserting checksums · 814d5b6f
      Filipe Manana authored
      [ Upstream commit 7e4a3f7e ]
      
      We are currently treating any non-zero return value from btrfs_next_leaf()
      the same way, by going to the code that inserts a new checksum item in the
      tree. However if btrfs_next_leaf() returns an error (a value < 0), we
      should just stop and return the error, and not behave as if nothing has
      happened, since in that case we do not have a way to know if there is a
      next leaf or we are currently at the last leaf already.
      
      So fix that by returning the error from btrfs_next_leaf().
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      814d5b6f
    • Serge Semin's avatar
      clocksource: dw_apb_timer_of: Fix missing clockevent timers · ec718fc8
      Serge Semin authored
      [ Upstream commit 6d2e16a3 ]
      
      Commit 10021488 ("clocksource: dw_apb_timer_of: use
      clocksource_of_init") replaced a publicly available driver
      initialization method with one called by the timer_probe() method
      available after CLKSRC_OF. In current implementation it traverses
      all the timers available in the system and calls their initialization
      methods if corresponding devices were either in dtb or in acpi. But
      if before the commit any number of available timers would be installed
      as clockevent and clocksource devices, after that there would be at most
      two. The rest are just ignored since default case branch doesn't do
      anything. I don't see a reason of such behaviour, neither the commit
      message explains it. Moreover this might be wrong if on some platforms
      these timers might be used for different purpose, as virtually CPU-local
      clockevent timers and as an independent broadcast timer. So in order
      to keep the compatibility with the platforms where the order of the
      timers detection has some meaning, lets add the secondly discovered
      timer to be of clocksource/sched_clock type, while the very first and
      the others would provide the clockevents service.
      
      Fixes: 10021488 ("clocksource: dw_apb_timer_of: use clocksource_of_init")
      Signed-off-by: default avatarSerge Semin <Sergey.Semin@baikalelectronics.ru>
      Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Paul Burton <paulburton@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Alessandro Zummo <a.zummo@towertech.it>
      Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: linux-mips@vger.kernel.org
      Cc: linux-rtc@vger.kernel.org
      Cc: devicetree@vger.kernel.org
      Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
      Link: https://lore.kernel.org/r/20200521204818.25436-7-Sergey.Semin@baikalelectronics.ruSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      ec718fc8
    • Serge Semin's avatar
      spi: dw: Enable interrupts in accordance with DMA xfer mode · 3824e01d
      Serge Semin authored
      [ Upstream commit 43dba9f3 ]
      
      It's pointless to track the Tx overrun interrupts if Rx-only SPI
      transfer is issued. Similarly there is no need in handling the Rx
      overrun/underrun interrupts if Tx-only SPI transfer is executed.
      So lets unmask the interrupts only if corresponding SPI
      transactions are implied.
      Co-developed-by: default avatarGeorgy Vlasov <Georgy.Vlasov@baikalelectronics.ru>
      Signed-off-by: default avatarGeorgy Vlasov <Georgy.Vlasov@baikalelectronics.ru>
      Signed-off-by: default avatarSerge Semin <Sergey.Semin@baikalelectronics.ru>
      Cc: Ramil Zaripov <Ramil.Zaripov@baikalelectronics.ru>
      Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Paul Burton <paulburton@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: linux-mips@vger.kernel.org
      Cc: devicetree@vger.kernel.org
      Link: https://lore.kernel.org/r/20200522000806.7381-3-Sergey.Semin@baikalelectronics.ruSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3824e01d
    • Douglas Anderson's avatar
      kgdb: Prevent infinite recursive entries to the debugger · d39bb8ee
      Douglas Anderson authored
      [ Upstream commit 3ca676e4 ]
      
      If we detect that we recursively entered the debugger we should hack
      our I/O ops to NULL so that the panic() in the next line won't
      actually cause another recursion into the debugger.  The first line of
      kgdb_panic() will check this and return.
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Reviewed-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
      Link: https://lore.kernel.org/r/20200507130644.v4.6.I89de39f68736c9de610e6f241e68d8dbc44bc266@changeidSigned-off-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d39bb8ee
    • Hsin-Yu Chao's avatar
      Bluetooth: Add SCO fallback for invalid LMP parameters error · 5b0660c7
      Hsin-Yu Chao authored
      [ Upstream commit 56b5453a ]
      
      Bluetooth PTS test case HFP/AG/ACC/BI-12-I accepts SCO connection
      with invalid parameter at the first SCO request expecting AG to
      attempt another SCO request with the use of "safe settings" for
      given codec, base on section 5.7.1.2 of HFP 1.7 specification.
      
      This patch addresses it by adding "Invalid LMP Parameters" (0x1e)
      to the SCO fallback case. Verified with below log:
      
      < HCI Command: Setup Synchronous Connection (0x01|0x0028) plen 17
              Handle: 256
              Transmit bandwidth: 8000
              Receive bandwidth: 8000
              Max latency: 13
              Setting: 0x0003
                Input Coding: Linear
                Input Data Format: 1's complement
                Input Sample Size: 8-bit
                # of bits padding at MSB: 0
                Air Coding Format: Transparent Data
              Retransmission effort: Optimize for link quality (0x02)
              Packet type: 0x0380
                3-EV3 may not be used
                2-EV5 may not be used
                3-EV5 may not be used
      > HCI Event: Command Status (0x0f) plen 4
            Setup Synchronous Connection (0x01|0x0028) ncmd 1
              Status: Success (0x00)
      > HCI Event: Number of Completed Packets (0x13) plen 5
              Num handles: 1
              Handle: 256
              Count: 1
      > HCI Event: Max Slots Change (0x1b) plen 3
              Handle: 256
              Max slots: 1
      > HCI Event: Synchronous Connect Complete (0x2c) plen 17
              Status: Invalid LMP Parameters / Invalid LL Parameters (0x1e)
              Handle: 0
              Address: 00:1B:DC:F2:21:59 (OUI 00-1B-DC)
              Link type: eSCO (0x02)
              Transmission interval: 0x00
              Retransmission window: 0x02
              RX packet length: 0
              TX packet length: 0
              Air mode: Transparent (0x03)
      < HCI Command: Setup Synchronous Connection (0x01|0x0028) plen 17
              Handle: 256
              Transmit bandwidth: 8000
              Receive bandwidth: 8000
              Max latency: 8
              Setting: 0x0003
                Input Coding: Linear
                Input Data Format: 1's complement
                Input Sample Size: 8-bit
                # of bits padding at MSB: 0
                Air Coding Format: Transparent Data
              Retransmission effort: Optimize for link quality (0x02)
              Packet type: 0x03c8
                EV3 may be used
                2-EV3 may not be used
                3-EV3 may not be used
                2-EV5 may not be used
                3-EV5 may not be used
      > HCI Event: Command Status (0x0f) plen 4
            Setup Synchronous Connection (0x01|0x0028) ncmd 1
              Status: Success (0x00)
      > HCI Event: Max Slots Change (0x1b) plen 3
              Handle: 256
              Max slots: 5
      > HCI Event: Max Slots Change (0x1b) plen 3
              Handle: 256
              Max slots: 1
      > HCI Event: Synchronous Connect Complete (0x2c) plen 17
              Status: Success (0x00)
              Handle: 257
              Address: 00:1B:DC:F2:21:59 (OUI 00-1B-DC)
              Link type: eSCO (0x02)
              Transmission interval: 0x06
              Retransmission window: 0x04
              RX packet length: 30
              TX packet length: 30
              Air mode: Transparent (0x03)
      Signed-off-by: default avatarHsin-Yu Chao <hychao@chromium.org>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5b0660c7
    • Andy Shevchenko's avatar
      spi: dw: Zero DMA Tx and Rx configurations on stack · 3801effa
      Andy Shevchenko authored
      [ Upstream commit 3cb97e22 ]
      
      Some DMA controller drivers do not tolerate non-zero values in
      the DMA configuration structures. Zero them to avoid issues with
      such DMA controller drivers. Even despite above this is a good
      practice per se.
      
      Fixes: 7063c0d9 ("spi/dw_spi: add DMA support")
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Acked-by: default avatarFeng Tang <feng.tang@intel.com>
      Cc: Feng Tang <feng.tang@intel.com>
      Link: https://lore.kernel.org/r/20200506153025.21441-1-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3801effa
    • Arthur Kiyanovski's avatar
      net: ena: fix error returning in ena_com_get_hash_function() · 966de7bd
      Arthur Kiyanovski authored
      [ Upstream commit e9a1de37 ]
      
      In case the "func" parameter is NULL we now return "-EINVAL".
      This shouldn't happen in general, but when it does happen, this is the
      proper way to handle it.
      
      We also check func for NULL in the beginning of the function, as there
      is no reason to do all the work and realize in the end of the function
      it was useless.
      Signed-off-by: default avatarSameeh Jubran <sameehj@amazon.com>
      Signed-off-by: default avatarArthur Kiyanovski <akiyano@amazon.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      966de7bd
    • Julien Thierry's avatar
      objtool: Ignore empty alternatives · b1f3bcd5
      Julien Thierry authored
      [ Upstream commit 7170cf47 ]
      
      The .alternatives section can contain entries with no original
      instructions. Objtool will currently crash when handling such an entry.
      
      Just skip that entry, but still give a warning to discourage useless
      entries.
      Signed-off-by: default avatarJulien Thierry <jthierry@redhat.com>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarMiroslav Benes <mbenes@suse.cz>
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b1f3bcd5
    • Brad Love's avatar
      media: si2157: Better check for running tuner in init · 4688ba5b
      Brad Love authored
      [ Upstream commit e955f959 ]
      
      Getting the Xtal trim property to check if running is less error prone.
      Reset if_frequency if state is unknown.
      
      Replaces the previous "garbage check".
      Signed-off-by: default avatarBrad Love <brad@nextdimension.cc>
      Signed-off-by: default avatarSean Young <sean@mess.org>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4688ba5b
    • Ard Biesheuvel's avatar
      ACPI: GED: use correct trigger type field in _Exx / _Lxx handling · 7cfcf05c
      Ard Biesheuvel authored
      commit e5c399b0 upstream.
      
      Commit ea6f3af4 ("ACPI: GED: add support for _Exx / _Lxx handler
      methods") added a reference to the 'triggering' field of either the
      normal or the extended ACPI IRQ resource struct, but inadvertently used
      the wrong pointer in the latter case. Note that both pointers refer to the
      same union, and the 'triggering' field appears at the same offset in both
      struct types, so it currently happens to work by accident. But let's fix
      it nonetheless
      
      Fixes: ea6f3af4 ("ACPI: GED: add support for _Exx / _Lxx handler methods")
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7cfcf05c
    • Colin Ian King's avatar
      media: dvb_frontend: ensure that inital front end status initialized · 77d5f7fe
      Colin Ian King authored
      commit a9e49980 upstream.
      
      The fe_status variable s is not initialized meaning it can have any
      random garbage status.  This could be problematic if fe->ops.tune is
      false as s is not updated by the call to fe->ops.tune() and a
      subsequent check on the change status will using a garbage value.
      Fix this by adding FE_NONE to the enum fe_status and initializing
      s to this.
      
      Detected by CoverityScan, CID#112887 ("Uninitialized scalar variable")
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Reviewed-by: default avatarShuah Khan <shuahkh@osg.samsung.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      77d5f7fe
    • Xiaolong Huang's avatar
      can: kvaser_usb: kvaser_usb_leaf: Fix some info-leaks to USB devices · c8ed03b9
      Xiaolong Huang authored
      commit da2311a6 upstream.
      
      Uninitialized Kernel memory can leak to USB devices.
      
      Fix this by using kzalloc() instead of kmalloc().
      Signed-off-by: default avatarXiaolong Huang <butterflyhuangxx@gmail.com>
      Fixes: 7259124e ("can: kvaser_usb: Split driver into kvaser_usb_core.c and kvaser_usb_leaf.c")
      Cc: linux-stable <stable@vger.kernel.org> # >= v4.19
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      [bwh: Backported to 4.9: adjust filename, context]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c8ed03b9
    • Chris Wilson's avatar
      agp/intel: Reinforce the barrier after GTT updates · 35de820e
      Chris Wilson authored
      commit f30d3ced upstream.
      
      After changing the timing between GTT updates and execution on the GPU,
      we started seeing sporadic failures on Ironlake. These were narrowed
      down to being an insufficiently strong enough barrier/delay after
      updating the GTT and scheduling execution on the GPU. By forcing the
      uncached read, and adding the missing barrier for the singular
      insert_page (relocation paths), the sporadic failures go away.
      
      Fixes: 983d308c ("agp/intel: Serialise after GTT updates")
      Fixes: 3497971a ("agp/intel: Flush chipset writes after updating a single PTE")
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Acked-by: default avatarAndi Shyti <andi.shyti@intel.com>
      Cc: stable@vger.kernel.org # v4.0+
      Link: https://patchwork.freedesktop.org/patch/msgid/20200410083535.25464-1-chris@chris-wilson.co.ukSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      35de820e
    • Barret Rhoden's avatar
      perf: Add cond_resched() to task_function_call() · 9bf3b364
      Barret Rhoden authored
      commit 2ed6edd3 upstream.
      
      Under rare circumstances, task_function_call() can repeatedly fail and
      cause a soft lockup.
      
      There is a slight race where the process is no longer running on the cpu
      we targeted by the time remote_function() runs.  The code will simply
      try again.  If we are very unlucky, this will continue to fail, until a
      watchdog fires.  This can happen in a heavily loaded, multi-core virtual
      machine.
      
      Reported-by: syzbot+bb4935a5c09b5ff79940@syzkaller.appspotmail.com
      Signed-off-by: default avatarBarret Rhoden <brho@google.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20200414222920.121401-1-brho@google.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9bf3b364
    • OGAWA Hirofumi's avatar
      fat: don't allow to mount if the FAT length == 0 · cadb31d1
      OGAWA Hirofumi authored
      commit b1b65750 upstream.
      
      If FAT length == 0, the image doesn't have any data. And it can be the
      cause of overlapping the root dir and FAT entries.
      
      Also Windows treats it as invalid format.
      
      Reported-by: syzbot+6f1624f937d9d6911e2d@syzkaller.appspotmail.com
      Signed-off-by: default avatarOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Marco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Link: http://lkml.kernel.org/r/87r1wz8mrd.fsf@mail.parknet.co.jpSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cadb31d1
    • Wang Hai's avatar
      mm/slub: fix a memory leak in sysfs_slab_add() · 248bd050
      Wang Hai authored
      commit dde3c6b7 upstream.
      
      syzkaller reports for memory leak when kobject_init_and_add() returns an
      error in the function sysfs_slab_add() [1]
      
      When this happened, the function kobject_put() is not called for the
      corresponding kobject, which potentially leads to memory leak.
      
      This patch fixes the issue by calling kobject_put() even if
      kobject_init_and_add() fails.
      
      [1]
        BUG: memory leak
        unreferenced object 0xffff8880a6d4be88 (size 8):
        comm "syz-executor.3", pid 946, jiffies 4295772514 (age 18.396s)
        hex dump (first 8 bytes):
          70 69 64 5f 33 00 ff ff                          pid_3...
        backtrace:
           kstrdup+0x35/0x70 mm/util.c:60
           kstrdup_const+0x3d/0x50 mm/util.c:82
           kvasprintf_const+0x112/0x170 lib/kasprintf.c:48
           kobject_set_name_vargs+0x55/0x130 lib/kobject.c:289
           kobject_add_varg lib/kobject.c:384 [inline]
           kobject_init_and_add+0xd8/0x170 lib/kobject.c:473
           sysfs_slab_add+0x1d8/0x290 mm/slub.c:5811
           __kmem_cache_create+0x50a/0x570 mm/slub.c:4384
           create_cache+0x113/0x1e0 mm/slab_common.c:407
           kmem_cache_create_usercopy+0x1a1/0x260 mm/slab_common.c:505
           kmem_cache_create+0xd/0x10 mm/slab_common.c:564
           create_pid_cachep kernel/pid_namespace.c:54 [inline]
           create_pid_namespace kernel/pid_namespace.c:96 [inline]
           copy_pid_ns+0x77c/0x8f0 kernel/pid_namespace.c:148
           create_new_namespaces+0x26b/0xa30 kernel/nsproxy.c:95
           unshare_nsproxy_namespaces+0xa7/0x1e0 kernel/nsproxy.c:229
           ksys_unshare+0x3d2/0x770 kernel/fork.c:2969
           __do_sys_unshare kernel/fork.c:3037 [inline]
           __se_sys_unshare kernel/fork.c:3035 [inline]
           __x64_sys_unshare+0x2d/0x40 kernel/fork.c:3035
           do_syscall_64+0xa1/0x530 arch/x86/entry/common.c:295
      
      Fixes: 80da026a ("mm/slub: fix slab double-free in case of duplicate sysfs filename")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarWang Hai <wanghai38@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Link: http://lkml.kernel.org/r/20200602115033.1054-1-wanghai38@huawei.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      248bd050
    • Casey Schaufler's avatar
      Smack: slab-out-of-bounds in vsscanf · d9010023
      Casey Schaufler authored
      commit 84e99e58 upstream.
      
      Add barrier to soob. Return -EOVERFLOW if the buffer
      is exceeded.
      Suggested-by: default avatarHillf Danton <hdanton@sina.com>
      Reported-by: syzbot+bfdd4a2f07be52351350@syzkaller.appspotmail.com
      Signed-off-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d9010023
    • Qiujun Huang's avatar
      ath9k: Fix general protection fault in ath9k_hif_usb_rx_cb · 5317abc4
      Qiujun Huang authored
      commit 2bbcaaee upstream.
      
      In ath9k_hif_usb_rx_cb interface number is assumed to be 0.
      usb_ifnum_to_if(urb->dev, 0)
      But it isn't always true.
      
      The case reported by syzbot:
      https://lore.kernel.org/linux-usb/000000000000666c9c05a1c05d12@google.com
      usb 2-1: new high-speed USB device number 2 using dummy_hcd
      usb 2-1: config 1 has an invalid interface number: 2 but max is 0
      usb 2-1: config 1 has no interface number 0
      usb 2-1: New USB device found, idVendor=0cf3, idProduct=9271, bcdDevice=
      1.08
      usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
      general protection fault, probably for non-canonical address
      0xdffffc0000000015: 0000 [#1] SMP KASAN
      KASAN: null-ptr-deref in range [0x00000000000000a8-0x00000000000000af]
      CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.6.0-rc5-syzkaller #0
      
      Call Trace
      __usb_hcd_giveback_urb+0x29a/0x550 drivers/usb/core/hcd.c:1650
      usb_hcd_giveback_urb+0x368/0x420 drivers/usb/core/hcd.c:1716
      dummy_timer+0x1258/0x32ae drivers/usb/gadget/udc/dummy_hcd.c:1966
      call_timer_fn+0x195/0x6f0 kernel/time/timer.c:1404
      expire_timers kernel/time/timer.c:1449 [inline]
      __run_timers kernel/time/timer.c:1773 [inline]
      __run_timers kernel/time/timer.c:1740 [inline]
      run_timer_softirq+0x5f9/0x1500 kernel/time/timer.c:1786
      __do_softirq+0x21e/0x950 kernel/softirq.c:292
      invoke_softirq kernel/softirq.c:373 [inline]
      irq_exit+0x178/0x1a0 kernel/softirq.c:413
      exiting_irq arch/x86/include/asm/apic.h:546 [inline]
      smp_apic_timer_interrupt+0x141/0x540 arch/x86/kernel/apic/apic.c:1146
      apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:829
      
      Reported-and-tested-by: syzbot+40d5d2e8a4680952f042@syzkaller.appspotmail.com
      Signed-off-by: default avatarQiujun Huang <hqjagain@gmail.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20200404041838.10426-6-hqjagain@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5317abc4