1. 11 Jun, 2020 13 commits
    • Fan Yang's avatar
      mm: Fix mremap not considering huge pmd devmap · c915cffd
      Fan Yang authored
      commit 5bfea2d9 upstream.
      
      The original code in mm/mremap.c checks huge pmd by:
      
      		if (is_swap_pmd(*old_pmd) || pmd_trans_huge(*old_pmd)) {
      
      However, a DAX mapped nvdimm is mapped as huge page (by default) but it
      is not transparent huge page (_PAGE_PSE | PAGE_DEVMAP).  This commit
      changes the condition to include the case.
      
      This addresses CVE-2020-10757.
      
      Fixes: 5c7fb56e ("mm, dax: dax-pmd vs thp-pmd vs hugetlbfs-pmd")
      Cc: <stable@vger.kernel.org>
      Reported-by: default avatarFan Yang <Fan_Yang@sjtu.edu.cn>
      Signed-off-by: default avatarFan Yang <Fan_Yang@sjtu.edu.cn>
      Tested-by: default avatarFan Yang <Fan_Yang@sjtu.edu.cn>
      Tested-by: default avatarDan Williams <dan.j.williams@intel.com>
      Reviewed-by: default avatarDan Williams <dan.j.williams@intel.com>
      Acked-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c915cffd
    • Guillaume Nault's avatar
      pppoe: only process PADT targeted at local interfaces · b1fa53f2
      Guillaume Nault authored
      We don't want to disconnect a session because of a stray PADT arriving
      while the interface is in promiscuous mode.
      Furthermore, multicast and broadcast packets make no sense here, so
      only PACKET_HOST is accepted.
      Reported-by: default avatarDavid Balažic <xerces9@gmail.com>
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarGuillaume Nault <gnault@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b1fa53f2
    • Dinghao Liu's avatar
      net: smsc911x: Fix runtime PM imbalance on error · 0e776721
      Dinghao Liu authored
      [ Upstream commit 539d39ad ]
      
      Remove runtime PM usage counter decrement when the
      increment function has not been called to keep the
      counter balanced.
      Signed-off-by: default avatarDinghao Liu <dinghao.liu@zju.edu.cn>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0e776721
    • Jonathan McDowell's avatar
      net: ethernet: stmmac: Enable interface clocks on probe for IPQ806x · 7b880cc0
      Jonathan McDowell authored
      [ Upstream commit a96ac8a0 ]
      
      The ipq806x_gmac_probe() function enables the PTP clock but not the
      appropriate interface clocks. This means that if the bootloader hasn't
      done so attempting to bring up the interface will fail with an error
      like:
      
      [   59.028131] ipq806x-gmac-dwmac 37600000.ethernet: Failed to reset the dma
      [   59.028196] ipq806x-gmac-dwmac 37600000.ethernet eth1: stmmac_hw_setup: DMA engine initialization failed
      [   59.034056] ipq806x-gmac-dwmac 37600000.ethernet eth1: stmmac_open: Hw setup failed
      
      This patch, a slightly cleaned up version of one posted by Sergey
      Sergeev in:
      
      https://forum.openwrt.org/t/support-for-mikrotik-rb3011uias-rm/4064/257
      
      correctly enables the clock; we have already configured the source just
      before this.
      
      Tested on a MikroTik RB3011.
      Signed-off-by: default avatarJonathan McDowell <noodles@earth.li>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7b880cc0
    • Valentin Longchamp's avatar
      net/ethernet/freescale: rework quiesce/activate for ucc_geth · dee26e88
      Valentin Longchamp authored
      [ Upstream commit 79dde73c ]
      
      ugeth_quiesce/activate are used to halt the controller when there is a
      link change that requires to reconfigure the mac.
      
      The previous implementation called netif_device_detach(). This however
      causes the initial activation of the netdevice to fail precisely because
      it's detached. For details, see [1].
      
      A possible workaround was the revert of commit
      net: linkwatch: add check for netdevice being present to linkwatch_do_dev
      However, the check introduced in the above commit is correct and shall be
      kept.
      
      The netif_device_detach() is thus replaced with
      netif_tx_stop_all_queues() that prevents any tranmission. This allows to
      perform mac config change required by the link change, without detaching
      the corresponding netdevice and thus not preventing its initial
      activation.
      
      [1] https://lists.openwall.net/netdev/2020/01/08/201Signed-off-by: default avatarValentin Longchamp <valentin@longchamp.me>
      Acked-by: default avatarMatteo Ghidoni <matteo.ghidoni@ch.abb.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      dee26e88
    • Jeremy Kerr's avatar
      net: bmac: Fix read of MAC address from ROM · 9849292d
      Jeremy Kerr authored
      [ Upstream commit ef01cee2 ]
      
      In bmac_get_station_address, We're reading two bytes at a time from ROM,
      but we do that six times, resulting in 12 bytes of read & writes. This
      means we will write off the end of the six-byte destination buffer.
      
      This change fixes the for-loop to only read/write six bytes.
      
      Based on a proposed fix from Finn Thain <fthain@telegraphics.com.au>.
      Signed-off-by: default avatarJeremy Kerr <jk@ozlabs.org>
      Reported-by: default avatarStan Johnson <userm57@yahoo.com>
      Tested-by: default avatarStan Johnson <userm57@yahoo.com>
      Reported-by: default avatarFinn Thain <fthain@telegraphics.com.au>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9849292d
    • Nathan Chancellor's avatar
      x86/mmiotrace: Use cpumask_available() for cpumask_var_t variables · c4400d9d
      Nathan Chancellor authored
      [ Upstream commit d7110a26 ]
      
      When building with Clang + -Wtautological-compare and
      CONFIG_CPUMASK_OFFSTACK unset:
      
        arch/x86/mm/mmio-mod.c:375:6: warning: comparison of array 'downed_cpus'
        equal to a null pointer is always false [-Wtautological-pointer-compare]
                if (downed_cpus == NULL &&
                    ^~~~~~~~~~~    ~~~~
        arch/x86/mm/mmio-mod.c:405:6: warning: comparison of array 'downed_cpus'
        equal to a null pointer is always false [-Wtautological-pointer-compare]
                if (downed_cpus == NULL || cpumask_weight(downed_cpus) == 0)
                    ^~~~~~~~~~~    ~~~~
        2 warnings generated.
      
      Commit
      
        f7e30f01 ("cpumask: Add helper cpumask_available()")
      
      added cpumask_available() to fix warnings of this nature. Use that here
      so that clang does not warn regardless of CONFIG_CPUMASK_OFFSTACK's
      value.
      Reported-by: default avatarSedat Dilek <sedat.dilek@gmail.com>
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Acked-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Link: https://github.com/ClangBuiltLinux/linux/issues/982
      Link: https://lkml.kernel.org/r/20200408205323.44490-1-natechancellor@gmail.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      c4400d9d
    • Eugeniy Paltsev's avatar
      ARC: Fix ICCM & DCCM runtime size checks · d7106057
      Eugeniy Paltsev authored
      [ Upstream commit 43900edf ]
      
      As of today the ICCM and DCCM size checks are incorrectly using
      mismatched units (KiB checked against bytes). The CONFIG_ARC_DCCM_SZ
      and CONFIG_ARC_ICCM_SZ are in KiB, but the size calculated in
      runtime and stored in cpu->dccm.sz and cpu->iccm.sz is in bytes.
      
      Fix that.
      Reported-by: default avatarPaul Greco <pmgreco@us.ibm.com>
      Signed-off-by: default avatarEugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
      Signed-off-by: default avatarVineet Gupta <vgupta@synopsys.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d7106057
    • Vasily Gorbik's avatar
      s390/ftrace: save traced function caller · 4237e949
      Vasily Gorbik authored
      [ Upstream commit b4adfe55 ]
      
      A typical backtrace acquired from ftraced function currently looks like
      the following (e.g. for "path_openat"):
      
      arch_stack_walk+0x15c/0x2d8
      stack_trace_save+0x50/0x68
      stack_trace_call+0x15a/0x3b8
      ftrace_graph_caller+0x0/0x1c
      0x3e0007e3c98 <- ftraced function caller (should be do_filp_open+0x7c/0xe8)
      do_open_execat+0x70/0x1b8
      __do_execve_file.isra.0+0x7d8/0x860
      __s390x_sys_execve+0x56/0x68
      system_call+0xdc/0x2d8
      
      Note random "0x3e0007e3c98" stack value as ftraced function caller. This
      value causes either imprecise unwinder result or unwinding failure.
      That "0x3e0007e3c98" comes from r14 of ftraced function stack frame, which
      it haven't had a chance to initialize since the very first instruction
      calls ftrace code ("ftrace_caller"). (ftraced function might never
      save r14 as well). Nevertheless according to s390 ABI any function
      is called with stack frame allocated for it and r14 contains return
      address. "ftrace_caller" itself is called with "brasl %r0,ftrace_caller".
      So, to fix this issue simply always save traced function caller onto
      ftraced function stack frame.
      Reported-by: default avatarSven Schnelle <svens@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4237e949
    • Xinwei Kong's avatar
      spi: dw: use "smp_mb()" to avoid sending spi data error · 5720901b
      Xinwei Kong authored
      [ Upstream commit bfda0445 ]
      
      Because of out-of-order execution about some CPU architecture,
      In this debug stage we find Completing spi interrupt enable ->
      prodrucing TXEI interrupt -> running "interrupt_transfer" function
      will prior to set "dw->rx and dws->rx_end" data, so this patch add
      memory barrier to enable dw->rx and dw->rx_end to be visible and
      solve to send SPI data error.
      eg:
      it will fix to this following low possibility error in testing environment
      which using SPI control to connect TPM Modules
      
      kernel: tpm tpm0: Operation Timed out
      kernel: tpm tpm0: tpm_relinquish_locality: : error -1
      Signed-off-by: default avatarfengsheng <fengsheng5@huawei.com>
      Signed-off-by: default avatarXinwei Kong <kong.kongxinwei@hisilicon.com>
      Link: https://lore.kernel.org/r/1578019930-55858-1-git-send-email-kong.kongxinwei@hisilicon.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5720901b
    • Zhen Lei's avatar
      esp6: fix memleak on error path in esp6_input · 7aebadb4
      Zhen Lei authored
      commit 7284fdf3 upstream.
      
      This ought to be an omission in e6194923 ("esp: Fix memleaks on error
      paths."). The memleak on error path in esp6_input is similar to esp_input
      of esp4.
      
      Fixes: e6194923 ("esp: Fix memleaks on error paths.")
      Fixes: 3f297707 ("ipsec: check return value of skb_to_sgvec always")
      Signed-off-by: default avatarZhen Lei <thunder.leizhen@huawei.com>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7aebadb4
    • Eugeniu Rosca's avatar
      usb: gadget: f_uac2: fix error handling in afunc_bind (again) · a7add20e
      Eugeniu Rosca authored
      commit e87581fe upstream.
      
      If usb_ep_autoconfig() fails (i.e. returns a null endpoint descriptor),
      we expect afunc_bind() to fail (i.e. return a negative error code).
      
      However, due to v4.10-rc1 commit f1d3861d ("usb: gadget: f_uac2: fix
      error handling at afunc_bind"), afunc_bind() returns zero, telling the
      caller that it succeeded. This then generates NULL pointer dereference
      in below scenario on Rcar H3-ES20-Salvator-X target:
      
      rcar-gen3:/home/root# modprobe g_audio
      [  626.521155] g_audio gadget: afunc_bind:565 Error!
      [  626.526319] g_audio gadget: Linux USB Audio Gadget, version: Feb 2, 2012
      [  626.533405] g_audio gadget: g_audio ready
      rcar-gen3:/home/root#
      rcar-gen3:/home/root# modprobe -r g_audio
      [  728.256707] ==================================================================
      [  728.264293] BUG: KASAN: null-ptr-deref in u_audio_stop_capture+0x70/0x268 [u_audio]
      [  728.272244] Read of size 8 at addr 00000000000000a0 by task modprobe/2545
      [  728.279309]
      [  728.280849] CPU: 0 PID: 2545 Comm: modprobe Tainted: G        WC      4.14.47+ #152
      [  728.288778] Hardware name: Renesas Salvator-X board based on r8a7795 ES2.0+ (DT)
      [  728.296454] Call trace:
      [  728.299151] [<ffff2000080925ac>] dump_backtrace+0x0/0x364
      [  728.304808] [<ffff200008092924>] show_stack+0x14/0x1c
      [  728.310081] [<ffff200008f8d5cc>] dump_stack+0x108/0x174
      [  728.315522] [<ffff2000083c77c8>] kasan_report+0x1fc/0x354
      [  728.321134] [<ffff2000083c611c>] __asan_load8+0x24/0x94
      [  728.326600] [<ffff2000021e1618>] u_audio_stop_capture+0x70/0x268 [u_audio]
      [  728.333735] [<ffff2000021f8b7c>] afunc_disable+0x44/0x60 [usb_f_uac2]
      [  728.340503] [<ffff20000218177c>] usb_remove_function+0x9c/0x210 [libcomposite]
      [  728.348060] [<ffff200002183320>] remove_config.isra.2+0x1d8/0x218 [libcomposite]
      [  728.355788] [<ffff200002186c54>] __composite_unbind+0x104/0x1f8 [libcomposite]
      [  728.363339] [<ffff200002186d58>] composite_unbind+0x10/0x18 [libcomposite]
      [  728.370536] [<ffff20000152f158>] usb_gadget_remove_driver+0xc0/0x170 [udc_core]
      [  728.378172] [<ffff20000153154c>] usb_gadget_unregister_driver+0x1cc/0x258 [udc_core]
      [  728.386274] [<ffff200002180de8>] usb_composite_unregister+0x10/0x18 [libcomposite]
      [  728.394116] [<ffff2000021d035c>] audio_driver_exit+0x14/0x28 [g_audio]
      [  728.400878] [<ffff200008213ed4>] SyS_delete_module+0x288/0x32c
      [  728.406935] Exception stack(0xffff8006cf6c7ec0 to 0xffff8006cf6c8000)
      [  728.413624] 7ec0: 0000000006136428 0000000000000800 0000000000000000 0000ffffd706efe8
      [  728.421718] 7ee0: 0000ffffd706efe9 000000000000000a 1999999999999999 0000000000000000
      [  728.429792] 7f00: 000000000000006a 000000000042c078 0000000000000000 0000000000000005
      [  728.437870] 7f20: 0000000000000000 0000000000000000 0000000000000004 0000000000000000
      [  728.445952] 7f40: 000000000042bfc8 0000ffffbc7c8f40 0000000000000000 00000000061363c0
      [  728.454035] 7f60: 0000000006136428 0000000000000000 0000000000000000 0000000006136428
      [  728.462114] 7f80: 000000000042c000 0000ffffd7071448 000000000042c000 0000000000000000
      [  728.470190] 7fa0: 00000000061350c0 0000ffffd7070010 000000000041129c 0000ffffd7070010
      [  728.478281] 7fc0: 0000ffffbc7c8f48 0000000060000000 0000000006136428 000000000000006a
      [  728.486351] 7fe0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
      [  728.494434] [<ffff200008084780>] el0_svc_naked+0x34/0x38
      [  728.499957] ==================================================================
      [  728.507801] Unable to handle kernel NULL pointer dereference at virtual address 000000a0
      [  728.517742] Mem abort info:
      [  728.520993]   Exception class = DABT (current EL), IL = 32 bits
      [  728.527375]   SET = 0, FnV = 0
      [  728.530731]   EA = 0, S1PTW = 0
      [  728.534361] Data abort info:
      [  728.537650]   ISV = 0, ISS = 0x00000006
      [  728.541863]   CM = 0, WnR = 0
      [  728.545167] user pgtable: 4k pages, 48-bit VAs, pgd = ffff8006c6100000
      [  728.552156] [00000000000000a0] *pgd=0000000716a8d003
      [  728.557519] , *pud=00000007116fc003
      [  728.561259] , *pmd=0000000000000000
      [  728.564985] Internal error: Oops: 96000006 [#1] PREEMPT SMP
      [  728.570815] Modules linked in:
      [  728.574023]  usb_f_uac2
      [  728.576560]  u_audio
      [  728.578827]  g_audio(-)
      [  728.581361]  libcomposite
      [  728.584071]  configfs
      [  728.586428]  aes_ce_blk
      [  728.588960]  sata_rcar
      [  728.591421]  crypto_simd
      [  728.594039]  cryptd
      [  728.596217]  libata
      [  728.598396]  aes_ce_cipher
      [  728.601188]  crc32_ce
      [  728.603542]  ghash_ce
      [  728.605896]  gf128mul
      [  728.608250]  aes_arm64
      [  728.610692]  scsi_mod
      [  728.613046]  sha2_ce
      [  728.615313]  xhci_plat_hcd
      [  728.618106]  sha256_arm64
      [  728.620811]  sha1_ce
      [  728.623077]  renesas_usbhs
      [  728.625869]  xhci_hcd
      [  728.628243]  renesas_usb3
      [  728.630948]  sha1_generic
      [  728.633670]  ravb_streaming(C)
      [  728.636814]  udc_core
      [  728.639168]  cpufreq_dt
      [  728.641697]  rcar_gen3_thermal
      [  728.644840]  usb_dmac
      [  728.647194]  pwm_rcar
      [  728.649548]  thermal_sys
      [  728.652165]  virt_dma
      [  728.654519]  mch_core(C)
      [  728.657137]  pwm_bl
      [  728.659315]  snd_soc_rcar
      [  728.662020]  snd_aloop
      [  728.664462]  snd_soc_generic_card
      [  728.667869]  snd_soc_ak4613
      [  728.670749]  ipv6
      [  728.672768]  autofs4
      [  728.675052] CPU: 0 PID: 2545 Comm: modprobe Tainted: G    B   WC      4.14.47+ #152
      [  728.682973] Hardware name: Renesas Salvator-X board based on r8a7795 ES2.0+ (DT)
      [  728.690637] task: ffff8006ced38000 task.stack: ffff8006cf6c0000
      [  728.696814] PC is at u_audio_stop_capture+0x70/0x268 [u_audio]
      [  728.702896] LR is at u_audio_stop_capture+0x70/0x268 [u_audio]
      [  728.708964] pc : [<ffff2000021e1618>] lr : [<ffff2000021e1618>] pstate: 60000145
      [  728.716620] sp : ffff8006cf6c7a50
      [  728.720154] x29: ffff8006cf6c7a50
      [  728.723760] x28: ffff8006ced38000
      [  728.727272] x27: ffff200008fd7000
      [  728.730857] x26: ffff2000021d2340
      [  728.734361] x25: 0000000000000000
      [  728.737948] x24: ffff200009e94b08
      [  728.741452] x23: 00000000000000a0
      [  728.745052] x22: 00000000000000a8
      [  728.748558] x21: 1ffff000d9ed8f7c
      [  728.752142] x20: ffff8006d671a800
      [  728.755646] x19: 0000000000000000
      [  728.759231] x18: 0000000000000000
      [  728.762736] x17: 0000ffffbc7c8f40
      [  728.766320] x16: ffff200008213c4c
      [  728.769823] x15: 0000000000000000
      [  728.773408] x14: 0720072007200720
      [  728.776912] x13: 0720072007200720
      [  728.780497] x12: ffffffffffffffff
      [  728.784001] x11: 0000000000000040
      [  728.787598] x10: 0000000000001600
      [  728.791103] x9 : ffff8006cf6c77a0
      [  728.794689] x8 : ffff8006ced39660
      [  728.798193] x7 : ffff20000811c738
      [  728.801794] x6 : 0000000000000000
      [  728.805299] x5 : dfff200000000000
      [  728.808885] x4 : ffff8006ced38000
      [  728.812390] x3 : ffff200008fb46e8
      [  728.815976] x2 : 0000000000000007
      [  728.819480] x1 : 3ba68643e7431500
      [  728.823066] x0 : 0000000000000000
      [  728.826574] Process modprobe (pid: 2545, stack limit = 0xffff8006cf6c0000)
      [  728.833704] Call trace:
      [  728.836292] Exception stack(0xffff8006cf6c7910 to 0xffff8006cf6c7a50)
      [  728.842987] 7900:                                   0000000000000000 3ba68643e7431500
      [  728.851084] 7920: 0000000000000007 ffff200008fb46e8 ffff8006ced38000 dfff200000000000
      [  728.859173] 7940: 0000000000000000 ffff20000811c738 ffff8006ced39660 ffff8006cf6c77a0
      [  728.867248] 7960: 0000000000001600 0000000000000040 ffffffffffffffff 0720072007200720
      [  728.875323] 7980: 0720072007200720 0000000000000000 ffff200008213c4c 0000ffffbc7c8f40
      [  728.883412] 79a0: 0000000000000000 0000000000000000 ffff8006d671a800 1ffff000d9ed8f7c
      [  728.891485] 79c0: 00000000000000a8 00000000000000a0 ffff200009e94b08 0000000000000000
      [  728.899561] 79e0: ffff2000021d2340 ffff200008fd7000 ffff8006ced38000 ffff8006cf6c7a50
      [  728.907636] 7a00: ffff2000021e1618 ffff8006cf6c7a50 ffff2000021e1618 0000000060000145
      [  728.915710] 7a20: 0000000000000008 0000000000000000 0000ffffffffffff 3ba68643e7431500
      [  728.923780] 7a40: ffff8006cf6c7a50 ffff2000021e1618
      [  728.928880] [<ffff2000021e1618>] u_audio_stop_capture+0x70/0x268 [u_audio]
      [  728.936032] [<ffff2000021f8b7c>] afunc_disable+0x44/0x60 [usb_f_uac2]
      [  728.942822] [<ffff20000218177c>] usb_remove_function+0x9c/0x210 [libcomposite]
      [  728.950385] [<ffff200002183320>] remove_config.isra.2+0x1d8/0x218 [libcomposite]
      [  728.958134] [<ffff200002186c54>] __composite_unbind+0x104/0x1f8 [libcomposite]
      [  728.965689] [<ffff200002186d58>] composite_unbind+0x10/0x18 [libcomposite]
      [  728.972882] [<ffff20000152f158>] usb_gadget_remove_driver+0xc0/0x170 [udc_core]
      [  728.980522] [<ffff20000153154c>] usb_gadget_unregister_driver+0x1cc/0x258 [udc_core]
      [  728.988638] [<ffff200002180de8>] usb_composite_unregister+0x10/0x18 [libcomposite]
      [  728.996472] [<ffff2000021d035c>] audio_driver_exit+0x14/0x28 [g_audio]
      [  729.003231] [<ffff200008213ed4>] SyS_delete_module+0x288/0x32c
      [  729.009278] Exception stack(0xffff8006cf6c7ec0 to 0xffff8006cf6c8000)
      [  729.015946] 7ec0: 0000000006136428 0000000000000800 0000000000000000 0000ffffd706efe8
      [  729.024022] 7ee0: 0000ffffd706efe9 000000000000000a 1999999999999999 0000000000000000
      [  729.032099] 7f00: 000000000000006a 000000000042c078 0000000000000000 0000000000000005
      [  729.040172] 7f20: 0000000000000000 0000000000000000 0000000000000004 0000000000000000
      [  729.048263] 7f40: 000000000042bfc8 0000ffffbc7c8f40 0000000000000000 00000000061363c0
      [  729.056337] 7f60: 0000000006136428 0000000000000000 0000000000000000 0000000006136428
      [  729.064411] 7f80: 000000000042c000 0000ffffd7071448 000000000042c000 0000000000000000
      [  729.072484] 7fa0: 00000000061350c0 0000ffffd7070010 000000000041129c 0000ffffd7070010
      [  729.080563] 7fc0: 0000ffffbc7c8f48 0000000060000000 0000000006136428 000000000000006a
      [  729.088636] 7fe0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
      [  729.096733] [<ffff200008084780>] el0_svc_naked+0x34/0x38
      [  729.102259] Code: 9597d1b3 aa1703e0 9102a276 958792b9 (f9405275)
      [  729.108617] ---[ end trace 7560c5fa3d100243 ]---
      
      After this patch is applied, the issue is fixed:
      rcar-gen3:/home/root# modprobe g_audio
      [   59.217127] g_audio gadget: afunc_bind:565 Error!
      [   59.222329] g_audio ee020000.usb: failed to start g_audio: -19
      modprobe: ERROR: could not insert 'g_audio': No such device
      rcar-gen3:/home/root# modprobe -r g_audio
      rcar-gen3:/home/root#
      
      Fixes: f1d3861d ("usb: gadget: f_uac2: fix error handling at afunc_bind")
      Signed-off-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a7add20e
    • Hannes Reinecke's avatar
      scsi: scsi_devinfo: fixup string compare · d74a350d
      Hannes Reinecke authored
      commit b8018b97 upstream.
      
      When checking the model and vendor string we need to use the minimum
      value of either string, otherwise we'll miss out on wildcard matches.
      
      And we should take care when matching with zero size strings; results
      might be unpredictable.  With this patch the rules for matching devinfo
      strings are as follows:
      
      - Vendor strings must match exactly
      - Empty Model strings will only match if the devinfo model
        is also empty
      - Model strings shorter than the devinfo model string will
        not match
      
      Fixes: 5e7ff2ca ("SCSI: fix new bug in scsi_dev_info_list string matching")
      Signed-off-by: default avatarHannes Reinecke <hare@suse.com>
      Reviewed-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Reviewed-by: default avatarBart Van Assche <bart.vanassche@wdc.com>
      Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d74a350d
  2. 03 Jun, 2020 27 commits
    • Greg Kroah-Hartman's avatar
      Linux 4.9.226 · af5595c4
      Greg Kroah-Hartman authored
      af5595c4
    • Benjamin Block's avatar
      scsi: zfcp: fix request object use-after-free in send path causing wrong traces · f2411632
      Benjamin Block authored
      [ Upstream commit 106d45f3 ]
      
      When tracing instances where we open and close WKA ports, we also pass the
      request-ID of the respective FSF command.
      
      But after successfully sending the FSF command we must not use the
      request-object anymore, as this might result in an use-after-free (see
      "zfcp: fix request object use-after-free in send path causing seqno
      errors" ).
      
      To fix this add a new variable that caches the request-ID before sending
      the request. This won't change during the hand-off to the FCP channel,
      and so it's safe to trace this cached request-ID later, instead of using
      the request object.
      Signed-off-by: default avatarBenjamin Block <bblock@linux.ibm.com>
      Fixes: d27a7cb9 ("zfcp: trace on request for open and close of WKA port")
      Cc: <stable@vger.kernel.org> #2.6.38+
      Reviewed-by: default avatarSteffen Maier <maier@linux.ibm.com>
      Reviewed-by: default avatarJens Remus <jremus@linux.ibm.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f2411632
    • Salil Mehta's avatar
      net: hns: Fixes the missing put_device in positive leg for roce reset · bd756613
      Salil Mehta authored
      commit 4d96e13e upstream.
      
      This patch fixes the missing device reference release-after-use in
      the positive leg of the roce reset API of the HNS DSAF.
      
      Fixes: c969c6e7 ("net: hns: Fix object reference leaks in hns_dsaf_roce_reset()")
      Reported-by: default avatarJohn Garry <john.garry@huawei.com>
      Signed-off-by: default avatarSalil Mehta <salil.mehta@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bd756613
    • Guoqing Jiang's avatar
      sc16is7xx: move label 'err_spi' to correct section · d5375ed9
      Guoqing Jiang authored
      commit e00164a0 upstream.
      
      err_spi is used when SERIAL_SC16IS7XX_SPI is enabled, so make
      the label only available under SERIAL_SC16IS7XX_SPI option.
      Otherwise, the below warning appears.
      
      drivers/tty/serial/sc16is7xx.c:1523:1: warning: label ‘err_spi’ defined but not used [-Wunused-label]
       err_spi:
        ^~~~~~~
      Signed-off-by: default avatarGuoqing Jiang <gqjiang@suse.com>
      Fixes: ac0cdb3d ("sc16is7xx: missing unregister/delete driver on error in sc16is7xx_init()")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d5375ed9
    • Liviu Dudau's avatar
      mm/vmalloc.c: don't dereference possible NULL pointer in __vunmap() · d20b134f
      Liviu Dudau authored
      commit 6ade2032 upstream.
      
      find_vmap_area() can return a NULL pointer and we're going to
      dereference it without checking it first.  Use the existing
      find_vm_area() function which does exactly what we want and checks for
      the NULL pointer.
      
      Link: http://lkml.kernel.org/r/20181228171009.22269-1-liviu@dudau.co.uk
      Fixes: f3c01d2f ("mm: vmalloc: avoid racy handling of debugobjects in vunmap")
      Signed-off-by: default avatarLiviu Dudau <liviu@dudau.co.uk>
      Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Chintan Pandya <cpandya@codeaurora.org>
      Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d20b134f
    • Roopa Prabhu's avatar
      net: rtnl_configure_link: fix dev flags changes arg to __dev_notify_flags · fba023f8
      Roopa Prabhu authored
      commit 56a49d70 upstream.
      
      This fix addresses https://bugzilla.kernel.org/show_bug.cgi?id=201071
      
      Commit 5025f7f7 wrongly relied on __dev_change_flags to notify users of
      dev flag changes in the case when dev->rtnl_link_state = RTNL_LINK_INITIALIZED.
      Fix it by indicating flag changes explicitly to __dev_notify_flags.
      
      Fixes: 5025f7f7 ("rtnetlink: add rtnl_link_state check in rtnl_configure_link")
      Reported-By: default avatarLiam mcbirnie <liam.mcbirnie@boeing.com>
      Signed-off-by: default avatarRoopa Prabhu <roopa@cumulusnetworks.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fba023f8
    • Thomas Gleixner's avatar
      genirq/generic_pending: Do not lose pending affinity update · 6e3885a3
      Thomas Gleixner authored
      commit a33a5d2d upstream.
      
      The generic pending interrupt mechanism moves interrupts from the interrupt
      handler on the original target CPU to the new destination CPU. This is
      required for x86 and ia64 due to the way the interrupt delivery and
      acknowledge works if the interrupts are not remapped.
      
      However that update can fail for various reasons. Some of them are valid
      reasons to discard the pending update, but the case, when the previous move
      has not been fully cleaned up is not a legit reason to fail.
      
      Check the return value of irq_do_set_affinity() for -EBUSY, which indicates
      a pending cleanup, and rearm the pending move in the irq dexcriptor so it's
      tried again when the next interrupt arrives.
      
      Fixes: 996c5912 ("x86/irq: Plug vector cleanup race")
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Tested-by: default avatarSong Liu <songliubraving@fb.com>
      Cc: Joerg Roedel <jroedel@suse.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <liu.song.a23@gmail.com>
      Cc: Dmitry Safonov <0x7f454c46@gmail.com>
      Cc: stable@vger.kernel.org
      Cc: Mike Travis <mike.travis@hpe.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Tariq Toukan <tariqt@mellanox.com>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Link: https://lkml.kernel.org/r/20180604162224.386544292@linutronix.deSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6e3885a3
    • Pablo Neira Ayuso's avatar
      netfilter: nf_conntrack_pptp: fix compilation warning with W=1 build · 2395335b
      Pablo Neira Ayuso authored
      commit 4946ea5c upstream.
      
      >> include/linux/netfilter/nf_conntrack_pptp.h:13:20: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers]
      extern const char *const pptp_msg_name(u_int16_t msg);
      ^~~~~~
      Reported-by: default avatarkbuild test robot <lkp@intel.com>
      Fixes: 4c559f15 ("netfilter: nf_conntrack_pptp: prevent buffer overflows in debug code")
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2395335b
    • Qiushi Wu's avatar
      bonding: Fix reference count leak in bond_sysfs_slave_add. · cd678077
      Qiushi Wu authored
      commit a068aab4 upstream.
      
      kobject_init_and_add() takes reference even when it fails.
      If this function returns an error, kobject_put() must be called to
      properly clean up the memory associated with the object. Previous
      commit "b8eb7183" fixed a similar problem.
      
      Fixes: 07699f9a ("bonding: add sysfs /slave dir for bond slave devices.")
      Signed-off-by: default avatarQiushi Wu <wu000273@umn.edu>
      Acked-by: default avatarJay Vosburgh <jay.vosburgh@canonical.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cd678077
    • Qiushi Wu's avatar
      qlcnic: fix missing release in qlcnic_83xx_interrupt_test. · 0dee5beb
      Qiushi Wu authored
      commit 15c97385 upstream.
      
      In function qlcnic_83xx_interrupt_test(), function
      qlcnic_83xx_diag_alloc_res() is not handled by function
      qlcnic_83xx_diag_free_res() after a call of the function
      qlcnic_alloc_mbx_args() failed. Fix this issue by adding
      a jump target "fail_mbx_args", and jump to this new target
      when qlcnic_alloc_mbx_args() failed.
      
      Fixes: b6b4316c ("qlcnic: Handle qlcnic_alloc_mbx_args() failure")
      Signed-off-by: default avatarQiushi Wu <wu000273@umn.edu>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0dee5beb
    • Pablo Neira Ayuso's avatar
      netfilter: nf_conntrack_pptp: prevent buffer overflows in debug code · 8ef57649
      Pablo Neira Ayuso authored
      commit 4c559f15 upstream.
      
      Dan Carpenter says: "Smatch complains that the value for "cmd" comes
      from the network and can't be trusted."
      
      Add pptp_msg_name() helper function that checks for the array boundary.
      
      Fixes: f09943fe ("[NETFILTER]: nf_conntrack/nf_nat: add PPTP helper port")
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8ef57649
    • Phil Sutter's avatar
      netfilter: ipset: Fix subcounter update skip · 12e42759
      Phil Sutter authored
      commit a164b95a upstream.
      
      If IPSET_FLAG_SKIP_SUBCOUNTER_UPDATE is set, user requested to not
      update counters in sub sets. Therefore IPSET_FLAG_SKIP_COUNTER_UPDATE
      must be set, not unset.
      
      Fixes: 6e01781d ("netfilter: ipset: set match: add support to match the counters")
      Signed-off-by: default avatarPhil Sutter <phil@nwl.cc>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      12e42759
    • Michael Braun's avatar
      netfilter: nft_reject_bridge: enable reject with bridge vlan · b614b864
      Michael Braun authored
      commit e9c284ec upstream.
      
      Currently, using the bridge reject target with tagged packets
      results in untagged packets being sent back.
      
      Fix this by mirroring the vlan id as well.
      
      Fixes: 85f5b308 ("netfilter: bridge: add reject support")
      Signed-off-by: default avatarMichael Braun <michael-dev@fami-braun.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b614b864
    • Xin Long's avatar
      ip_vti: receive ipip packet by calling ip_tunnel_rcv · c67ec7f9
      Xin Long authored
      commit 976eba8a upstream.
      
      In Commit dd9ee344 ("vti4: Fix a ipip packet processing bug in
      'IPCOMP' virtual tunnel"), it tries to receive IPIP packets in vti
      by calling xfrm_input(). This case happens when a small packet or
      frag sent by peer is too small to get compressed.
      
      However, xfrm_input() will still get to the IPCOMP path where skb
      sec_path is set, but never dropped while it should have been done
      in vti_ipcomp4_protocol.cb_handler(vti_rcv_cb), as it's not an
      ipcomp4 packet. This will cause that the packet can never pass
      xfrm4_policy_check() in the upper protocol rcv functions.
      
      So this patch is to call ip_tunnel_rcv() to process IPIP packets
      instead.
      
      Fixes: dd9ee344 ("vti4: Fix a ipip packet processing bug in 'IPCOMP' virtual tunnel")
      Reported-by: default avatarXiumei Mu <xmu@redhat.com>
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c67ec7f9
    • Jeremy Sowden's avatar
      vti4: eliminated some duplicate code. · 60dbd1a3
      Jeremy Sowden authored
      commit f981c57f upstream.
      
      The ipip tunnel introduced in commit dd9ee344 ("vti4: Fix a ipip
      packet processing bug in 'IPCOMP' virtual tunnel") largely duplicated
      the existing vti_input and vti_recv functions.  Refactored to
      deduplicate the common code.
      Signed-off-by: default avatarJeremy Sowden <jeremy@azazel.net>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      60dbd1a3
    • Xin Long's avatar
      xfrm: fix a NULL-ptr deref in xfrm_local_error · 52914acf
      Xin Long authored
      commit f6a23d85 upstream.
      
      This patch is to fix a crash:
      
        [ ] kasan: GPF could be caused by NULL-ptr deref or user memory access
        [ ] general protection fault: 0000 [#1] SMP KASAN PTI
        [ ] RIP: 0010:ipv6_local_error+0xac/0x7a0
        [ ] Call Trace:
        [ ]  xfrm6_local_error+0x1eb/0x300
        [ ]  xfrm_local_error+0x95/0x130
        [ ]  __xfrm6_output+0x65f/0xb50
        [ ]  xfrm6_output+0x106/0x46f
        [ ]  udp_tunnel6_xmit_skb+0x618/0xbf0 [ip6_udp_tunnel]
        [ ]  vxlan_xmit_one+0xbc6/0x2c60 [vxlan]
        [ ]  vxlan_xmit+0x6a0/0x4276 [vxlan]
        [ ]  dev_hard_start_xmit+0x165/0x820
        [ ]  __dev_queue_xmit+0x1ff0/0x2b90
        [ ]  ip_finish_output2+0xd3e/0x1480
        [ ]  ip_do_fragment+0x182d/0x2210
        [ ]  ip_output+0x1d0/0x510
        [ ]  ip_send_skb+0x37/0xa0
        [ ]  raw_sendmsg+0x1b4c/0x2b80
        [ ]  sock_sendmsg+0xc0/0x110
      
      This occurred when sending a v4 skb over vxlan6 over ipsec, in which case
      skb->protocol == htons(ETH_P_IPV6) while skb->sk->sk_family == AF_INET in
      xfrm_local_error(). Then it will go to xfrm6_local_error() where it tries
      to get ipv6 info from a ipv4 sk.
      
      This issue was actually fixed by Commit 628e341f ("xfrm: make local
      error reporting more robust"), but brought back by Commit 844d4874
      ("xfrm: choose protocol family by skb protocol").
      
      So to fix it, we should call xfrm6_local_error() only when skb->protocol
      is htons(ETH_P_IPV6) and skb->sk->sk_family is AF_INET6.
      
      Fixes: 844d4874 ("xfrm: choose protocol family by skb protocol")
      Reported-by: default avatarXiumei Mu <xmu@redhat.com>
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      52914acf
    • Xin Long's avatar
      xfrm: fix a warning in xfrm_policy_insert_list · 6215d490
      Xin Long authored
      commit ed17b8d3 upstream.
      
      This waring can be triggered simply by:
      
        # ip xfrm policy update src 192.168.1.1/24 dst 192.168.1.2/24 dir in \
          priority 1 mark 0 mask 0x10  #[1]
        # ip xfrm policy update src 192.168.1.1/24 dst 192.168.1.2/24 dir in \
          priority 2 mark 0 mask 0x1   #[2]
        # ip xfrm policy update src 192.168.1.1/24 dst 192.168.1.2/24 dir in \
          priority 2 mark 0 mask 0x10  #[3]
      
      Then dmesg shows:
      
        [ ] WARNING: CPU: 1 PID: 7265 at net/xfrm/xfrm_policy.c:1548
        [ ] RIP: 0010:xfrm_policy_insert_list+0x2f2/0x1030
        [ ] Call Trace:
        [ ]  xfrm_policy_inexact_insert+0x85/0xe50
        [ ]  xfrm_policy_insert+0x4ba/0x680
        [ ]  xfrm_add_policy+0x246/0x4d0
        [ ]  xfrm_user_rcv_msg+0x331/0x5c0
        [ ]  netlink_rcv_skb+0x121/0x350
        [ ]  xfrm_netlink_rcv+0x66/0x80
        [ ]  netlink_unicast+0x439/0x630
        [ ]  netlink_sendmsg+0x714/0xbf0
        [ ]  sock_sendmsg+0xe2/0x110
      
      The issue was introduced by Commit 7cb8a939 ("xfrm: Allow inserting
      policies with matching mark and different priorities"). After that, the
      policies [1] and [2] would be able to be added with different priorities.
      
      However, policy [3] will actually match both [1] and [2]. Policy [1]
      was matched due to the 1st 'return true' in xfrm_policy_mark_match(),
      and policy [2] was matched due to the 2nd 'return true' in there. It
      caused WARN_ON() in xfrm_policy_insert_list().
      
      This patch is to fix it by only (the same value and priority) as the
      same policy in xfrm_policy_mark_match().
      
      Thanks to Yuehaibing, we could make this fix better.
      
      v1->v2:
        - check policy->mark.v == pol->mark.v only without mask.
      
      Fixes: 7cb8a939 ("xfrm: Allow inserting policies with matching mark and different priorities")
      Reported-by: default avatarXiumei Mu <xmu@redhat.com>
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6215d490
    • Xin Long's avatar
      xfrm: allow to accept packets with ipv6 NEXTHDR_HOP in xfrm_input · 918e01ba
      Xin Long authored
      commit afcaf61b upstream.
      
      For beet mode, when it's ipv6 inner address with nexthdrs set,
      the packet format might be:
      
          ----------------------------------------------------
          | outer  |     | dest |     |      |  ESP    | ESP |
          | IP hdr | ESP | opts.| TCP | Data | Trailer | ICV |
          ----------------------------------------------------
      
      The nexthdr from ESP could be NEXTHDR_HOP(0), so it should
      continue processing the packet when nexthdr returns 0 in
      xfrm_input(). Otherwise, when ipv6 nexthdr is set, the
      packet will be dropped.
      
      I don't see any error cases that nexthdr may return 0. So
      fix it by removing the check for nexthdr == 0.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      918e01ba
    • Alexander Dahl's avatar
      x86/dma: Fix max PFN arithmetic overflow on 32 bit systems · 724fb3b3
      Alexander Dahl authored
      commit 88743470 upstream.
      
      The intermediate result of the old term (4UL * 1024 * 1024 * 1024) is
      4 294 967 296 or 0x100000000 which is no problem on 64 bit systems.
      The patch does not change the later overall result of 0x100000 for
      MAX_DMA32_PFN (after it has been shifted by PAGE_SHIFT). The new
      calculation yields the same result, but does not require 64 bit
      arithmetic.
      
      On 32 bit systems the old calculation suffers from an arithmetic
      overflow in that intermediate term in braces: 4UL aka unsigned long int
      is 4 byte wide and an arithmetic overflow happens (the 0x100000000 does
      not fit in 4 bytes), the in braces result is truncated to zero, the
      following right shift does not alter that, so MAX_DMA32_PFN evaluates to
      0 on 32 bit systems.
      
      That wrong value is a problem in a comparision against MAX_DMA32_PFN in
      the init code for swiotlb in pci_swiotlb_detect_4gb() to decide if
      swiotlb should be active.  That comparison yields the opposite result,
      when compiling on 32 bit systems.
      
      This was not possible before
      
        1b7e03ef ("x86, NUMA: Enable emulation on 32bit too")
      
      when that MAX_DMA32_PFN was first made visible to x86_32 (and which
      landed in v3.0).
      
      In practice this wasn't a problem, unless CONFIG_SWIOTLB is active on
      x86-32.
      
      However if one has set CONFIG_IOMMU_INTEL, since
      
        c5a5dc4c ("iommu/vt-d: Don't switch off swiotlb if bounce page is used")
      
      there's a dependency on CONFIG_SWIOTLB, which was not necessarily
      active before. That landed in v5.4, where we noticed it in the fli4l
      Linux distribution. We have CONFIG_IOMMU_INTEL active on both 32 and 64
      bit kernel configs there (I could not find out why, so let's just say
      historical reasons).
      
      The effect is at boot time 64 MiB (default size) were allocated for
      bounce buffers now, which is a noticeable amount of memory on small
      systems like pcengines ALIX 2D3 with 256 MiB memory, which are still
      frequently used as home routers.
      
      We noticed this effect when migrating from kernel v4.19 (LTS) to v5.4
      (LTS) in fli4l and got that kernel messages for example:
      
        Linux version 5.4.22 (buildroot@buildroot) (gcc version 7.3.0 (Buildroot 2018.02.8)) #1 SMP Mon Nov 26 23:40:00 CET 2018
        …
        Memory: 183484K/261756K available (4594K kernel code, 393K rwdata, 1660K rodata, 536K init, 456K bss , 78272K reserved, 0K cma-reserved, 0K highmem)
        …
        PCI-DMA: Using software bounce buffering for IO (SWIOTLB)
        software IO TLB: mapped [mem 0x0bb78000-0x0fb78000] (64MB)
      
      The initial analysis and the suggested fix was done by user 'sourcejedi'
      at stackoverflow and explicitly marked as GPLv2 for inclusion in the
      Linux kernel:
      
        https://unix.stackexchange.com/a/520525/50007
      
      The new calculation, which does not suffer from that overflow, is the
      same as for arch/mips now as suggested by Robin Murphy.
      
      The fix was tested by fli4l users on round about two dozen different
      systems, including both 32 and 64 bit archs, bare metal and virtualized
      machines.
      
       [ bp: Massage commit message. ]
      
      Fixes: 1b7e03ef ("x86, NUMA: Enable emulation on 32bit too")
      Reported-by: default avatarAlan Jenkins <alan.christopher.jenkins@gmail.com>
      Suggested-by: default avatarRobin Murphy <robin.murphy@arm.com>
      Signed-off-by: default avatarAlexander Dahl <post@lespocky.de>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: stable@vger.kernel.org
      Link: https://unix.stackexchange.com/q/520065/50007
      Link: https://web.nettworks.org/bugs/browse/FFL-2560
      Link: https://lkml.kernel.org/r/20200526175749.20742-1-post@lespocky.deSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      724fb3b3
    • Linus Lüssing's avatar
      mac80211: mesh: fix discovery timer re-arming issue / crash · a3e73388
      Linus Lüssing authored
      commit e2d4a80f upstream.
      
      On a non-forwarding 802.11s link between two fairly busy
      neighboring nodes (iperf with -P 16 at ~850MBit/s TCP;
      1733.3 MBit/s VHT-MCS 9 80MHz short GI VHT-NSS 4), so with
      frequent PREQ retries, usually after around 30-40 seconds the
      following crash would occur:
      
      [ 1110.822428] Unable to handle kernel read from unreadable memory at virtual address 00000000
      [ 1110.830786] Mem abort info:
      [ 1110.833573]   Exception class = IABT (current EL), IL = 32 bits
      [ 1110.839494]   SET = 0, FnV = 0
      [ 1110.842546]   EA = 0, S1PTW = 0
      [ 1110.845678] user pgtable: 4k pages, 48-bit VAs, pgd = ffff800076386000
      [ 1110.852204] [0000000000000000] *pgd=00000000f6322003, *pud=00000000f62de003, *pmd=0000000000000000
      [ 1110.861167] Internal error: Oops: 86000004 [#1] PREEMPT SMP
      [ 1110.866730] Modules linked in: pppoe ppp_async batman_adv ath10k_pci ath10k_core ath pppox ppp_generic nf_conntrack_ipv6 mac80211 iptable_nat ipt_REJECT ipt_MASQUERADE cfg80211 xt_time xt_tcpudp xt_state xt_nat xt_multiport xt_mark xt_mac xt_limit xt_conntrack xt_comment xt_TCPMSS xt_REDIRECT xt_LOG xt_FLOWOFFLOAD slhc nf_reject_ipv4 nf_nat_redirect nf_nat_masquerade_ipv4 nf_conntrack_ipv4 nf_nat_ipv4 nf_nat nf_log_ipv4 nf_flow_table_hw nf_flow_table nf_defrag_ipv6 nf_defrag_ipv4 nf_conntrack_rtcache nf_conntrack iptable_mangle iptable_filter ip_tables crc_ccitt compat nf_log_ipv6 nf_log_common ip6table_mangle ip6table_filter ip6_tables ip6t_REJECT x_tables nf_reject_ipv6 usb_storage xhci_plat_hcd xhci_pci xhci_hcd dwc3 usbcore usb_common
      [ 1110.932190] Process swapper/3 (pid: 0, stack limit = 0xffff0000090c8000)
      [ 1110.938884] CPU: 3 PID: 0 Comm: swapper/3 Not tainted 4.14.162 #0
      [ 1110.944965] Hardware name: LS1043A RGW Board (DT)
      [ 1110.949658] task: ffff8000787a81c0 task.stack: ffff0000090c8000
      [ 1110.955568] PC is at 0x0
      [ 1110.958097] LR is at call_timer_fn.isra.27+0x24/0x78
      [ 1110.963055] pc : [<0000000000000000>] lr : [<ffff0000080ff29c>] pstate: 00400145
      [ 1110.970440] sp : ffff00000801be10
      [ 1110.973744] x29: ffff00000801be10 x28: ffff000008bf7018
      [ 1110.979047] x27: ffff000008bf87c8 x26: ffff000008c160c0
      [ 1110.984352] x25: 0000000000000000 x24: 0000000000000000
      [ 1110.989657] x23: dead000000000200 x22: 0000000000000000
      [ 1110.994959] x21: 0000000000000000 x20: 0000000000000101
      [ 1111.000262] x19: ffff8000787a81c0 x18: 0000000000000000
      [ 1111.005565] x17: ffff0000089167b0 x16: 0000000000000058
      [ 1111.010868] x15: ffff0000089167b0 x14: 0000000000000000
      [ 1111.016172] x13: ffff000008916788 x12: 0000000000000040
      [ 1111.021475] x11: ffff80007fda9af0 x10: 0000000000000001
      [ 1111.026777] x9 : ffff00000801bea0 x8 : 0000000000000004
      [ 1111.032080] x7 : 0000000000000000 x6 : ffff80007fda9aa8
      [ 1111.037383] x5 : ffff00000801bea0 x4 : 0000000000000010
      [ 1111.042685] x3 : ffff00000801be98 x2 : 0000000000000614
      [ 1111.047988] x1 : 0000000000000000 x0 : 0000000000000000
      [ 1111.053290] Call trace:
      [ 1111.055728] Exception stack(0xffff00000801bcd0 to 0xffff00000801be10)
      [ 1111.062158] bcc0:                                   0000000000000000 0000000000000000
      [ 1111.069978] bce0: 0000000000000614 ffff00000801be98 0000000000000010 ffff00000801bea0
      [ 1111.077798] bd00: ffff80007fda9aa8 0000000000000000 0000000000000004 ffff00000801bea0
      [ 1111.085618] bd20: 0000000000000001 ffff80007fda9af0 0000000000000040 ffff000008916788
      [ 1111.093437] bd40: 0000000000000000 ffff0000089167b0 0000000000000058 ffff0000089167b0
      [ 1111.101256] bd60: 0000000000000000 ffff8000787a81c0 0000000000000101 0000000000000000
      [ 1111.109075] bd80: 0000000000000000 dead000000000200 0000000000000000 0000000000000000
      [ 1111.116895] bda0: ffff000008c160c0 ffff000008bf87c8 ffff000008bf7018 ffff00000801be10
      [ 1111.124715] bdc0: ffff0000080ff29c ffff00000801be10 0000000000000000 0000000000400145
      [ 1111.132534] bde0: ffff8000787a81c0 ffff00000801bde8 0000ffffffffffff 000001029eb19be8
      [ 1111.140353] be00: ffff00000801be10 0000000000000000
      [ 1111.145220] [<          (null)>]           (null)
      [ 1111.149917] [<ffff0000080ff77c>] run_timer_softirq+0x184/0x398
      [ 1111.155741] [<ffff000008081938>] __do_softirq+0x100/0x1fc
      [ 1111.161130] [<ffff0000080a2e28>] irq_exit+0x80/0xd8
      [ 1111.166002] [<ffff0000080ea708>] __handle_domain_irq+0x88/0xb0
      [ 1111.171825] [<ffff000008081678>] gic_handle_irq+0x68/0xb0
      [ 1111.177213] Exception stack(0xffff0000090cbe30 to 0xffff0000090cbf70)
      [ 1111.183642] be20:                                   0000000000000020 0000000000000000
      [ 1111.191461] be40: 0000000000000001 0000000000000000 00008000771af000 0000000000000000
      [ 1111.199281] be60: ffff000008c95180 0000000000000000 ffff000008c19360 ffff0000090cbef0
      [ 1111.207101] be80: 0000000000000810 0000000000000400 0000000000000098 ffff000000000000
      [ 1111.214920] bea0: 0000000000000001 ffff0000089167b0 0000000000000000 ffff0000089167b0
      [ 1111.222740] bec0: 0000000000000000 ffff000008c198e8 ffff000008bf7018 ffff000008c19000
      [ 1111.230559] bee0: 0000000000000000 0000000000000000 ffff8000787a81c0 ffff000008018000
      [ 1111.238380] bf00: ffff00000801c000 ffff00000913ba34 ffff8000787a81c0 ffff0000090cbf70
      [ 1111.246199] bf20: ffff0000080857cc ffff0000090cbf70 ffff0000080857d0 0000000000400145
      [ 1111.254020] bf40: ffff000008018000 ffff00000801c000 ffffffffffffffff ffff0000080fa574
      [ 1111.261838] bf60: ffff0000090cbf70 ffff0000080857d0
      [ 1111.266706] [<ffff0000080832e8>] el1_irq+0xe8/0x18c
      [ 1111.271576] [<ffff0000080857d0>] arch_cpu_idle+0x10/0x18
      [ 1111.276880] [<ffff0000080d7de4>] do_idle+0xec/0x1b8
      [ 1111.281748] [<ffff0000080d8020>] cpu_startup_entry+0x20/0x28
      [ 1111.287399] [<ffff00000808f81c>] secondary_start_kernel+0x104/0x110
      [ 1111.293662] Code: bad PC value
      [ 1111.296710] ---[ end trace 555b6ca4363c3edd ]---
      [ 1111.301318] Kernel panic - not syncing: Fatal exception in interrupt
      [ 1111.307661] SMP: stopping secondary CPUs
      [ 1111.311574] Kernel Offset: disabled
      [ 1111.315053] CPU features: 0x0002000
      [ 1111.318530] Memory Limit: none
      [ 1111.321575] Rebooting in 3 seconds..
      
      With some added debug output / delays we were able to push the crash from
      the timer callback runner into the callback function and by that shedding
      some light on which object holding the timer gets corrupted:
      
      [  401.720899] Unable to handle kernel read from unreadable memory at virtual address 00000868
      [...]
      [  402.335836] [<ffff0000088fafa4>] _raw_spin_lock_bh+0x14/0x48
      [  402.341548] [<ffff000000dbe684>] mesh_path_timer+0x10c/0x248 [mac80211]
      [  402.348154] [<ffff0000080ff29c>] call_timer_fn.isra.27+0x24/0x78
      [  402.354150] [<ffff0000080ff77c>] run_timer_softirq+0x184/0x398
      [  402.359974] [<ffff000008081938>] __do_softirq+0x100/0x1fc
      [  402.365362] [<ffff0000080a2e28>] irq_exit+0x80/0xd8
      [  402.370231] [<ffff0000080ea708>] __handle_domain_irq+0x88/0xb0
      [  402.376053] [<ffff000008081678>] gic_handle_irq+0x68/0xb0
      
      The issue happens due to the following sequence of events:
      
      1) mesh_path_start_discovery():
      -> spin_unlock_bh(&mpath->state_lock) before mesh_path_sel_frame_tx()
      
      2) mesh_path_free_rcu()
      -> del_timer_sync(&mpath->timer)
         [...]
      -> kfree_rcu(mpath)
      
      3) mesh_path_start_discovery():
      -> mod_timer(&mpath->timer, ...)
         [...]
      -> rcu_read_unlock()
      
      4) mesh_path_free_rcu()'s kfree_rcu():
      -> kfree(mpath)
      
      5) mesh_path_timer() starts after timeout, using freed mpath object
      
      So a use-after-free issue due to a timer re-arming bug caused by an
      early spin-unlocking.
      
      This patch fixes this issue by re-checking if mpath is about to be
      free'd and if so bails out of re-arming the timer.
      
      Cc: stable@vger.kernel.org
      Fixes: 050ac52c ("mac80211: code for on-demand Hybrid Wireless Mesh Protocol")
      Cc: Simon Wunderlich <sw@simonwunderlich.de>
      Signed-off-by: default avatarLinus Lüssing <ll@simonwunderlich.de>
      Link: https://lore.kernel.org/r/20200522170413.14973-1-linus.luessing@c0d3.blueSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a3e73388
    • Helge Deller's avatar
      parisc: Fix kernel panic in mem_init() · ce7b3d05
      Helge Deller authored
      commit bf71bc16 upstream.
      
      The Debian kernel v5.6 triggers this kernel panic:
      
       Kernel panic - not syncing: Bad Address (null pointer deref?)
       Bad Address (null pointer deref?): Code=26 (Data memory access rights trap) at addr 0000000000000000
       CPU: 0 PID: 0 Comm: swapper Not tainted 5.6.0-2-parisc64 #1 Debian 5.6.14-1
        IAOQ[0]: mem_init+0xb0/0x150
        IAOQ[1]: mem_init+0xb4/0x150
        RP(r2): start_kernel+0x6c8/0x1190
       Backtrace:
        [<0000000040101ab4>] start_kernel+0x6c8/0x1190
        [<0000000040108574>] start_parisc+0x158/0x1b8
      
      on a HP-PARISC rp3440 machine with this memory layout:
       Memory Ranges:
        0) Start 0x0000000000000000 End 0x000000003fffffff Size   1024 MB
        1) Start 0x0000004040000000 End 0x00000040ffdfffff Size   3070 MB
      
      Fix the crash by avoiding virt_to_page() and similar functions in
      mem_init() until the memory zones have been fully set up.
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Cc: stable@vger.kernel.org # v5.0+
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      
      ce7b3d05
    • Qiushi Wu's avatar
      iommu: Fix reference count leak in iommu_group_alloc. · 44ac6bec
      Qiushi Wu authored
      [ Upstream commit 7cc31613 ]
      
      kobject_init_and_add() takes reference even when it fails.
      Thus, when kobject_init_and_add() returns an error,
      kobject_put() must be called to properly clean up the kobject.
      
      Fixes: d72e31c9 ("iommu: IOMMU Groups")
      Signed-off-by: default avatarQiushi Wu <wu000273@umn.edu>
      Link: https://lore.kernel.org/r/20200527210020.6522-1-wu000273@umn.eduSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      44ac6bec
    • Arnd Bergmann's avatar
      include/asm-generic/topology.h: guard cpumask_of_node() macro argument · 4f4a4bc9
      Arnd Bergmann authored
      [ Upstream commit 4377748c ]
      
      drivers/hwmon/amd_energy.c:195:15: error: invalid operands to binary expression ('void' and 'int')
                                              (channel - data->nr_cpus));
                                              ~~~~~~~~~^~~~~~~~~~~~~~~~~
      include/asm-generic/topology.h:51:42: note: expanded from macro 'cpumask_of_node'
          #define cpumask_of_node(node)       ((void)node, cpu_online_mask)
                                                     ^~~~
      include/linux/cpumask.h:618:72: note: expanded from macro 'cpumask_first_and'
       #define cpumask_first_and(src1p, src2p) cpumask_next_and(-1, (src1p), (src2p))
                                                                             ^~~~~
      
      Fixes: f0b848ce ("cpumask: Introduce cpumask_of_{node,pcibus} to replace {node,pcibus}_to_cpumask")
      Fixes: 8abee956 ("hwmon: Add amd_energy driver to report energy counters")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Acked-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Link: http://lkml.kernel.org/r/20200527134623.930247-1-arnd@arndb.deSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4f4a4bc9
    • Alexander Potapenko's avatar
      fs/binfmt_elf.c: allocate initialized memory in fill_thread_core_info() · d228bc4b
      Alexander Potapenko authored
      [ Upstream commit 1d605416 ]
      
      KMSAN reported uninitialized data being written to disk when dumping
      core.  As a result, several kilobytes of kmalloc memory may be written
      to the core file and then read by a non-privileged user.
      Reported-by: default avatarsam <sunhaoyl@outlook.com>
      Signed-off-by: default avatarAlexander Potapenko <glider@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Cc: <stable@vger.kernel.org>
      Link: http://lkml.kernel.org/r/20200419100848.63472-1-glider@google.com
      Link: https://github.com/google/kmsan/issues/76Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d228bc4b
    • Konstantin Khlebnikov's avatar
      mm: remove VM_BUG_ON(PageSlab()) from page_mapcount() · 584da13a
      Konstantin Khlebnikov authored
      [ Upstream commit 6988f31d ]
      
      Replace superfluous VM_BUG_ON() with comment about correct usage.
      
      Technically reverts commit 1d148e21 ("mm: add VM_BUG_ON_PAGE() to
      page_mapcount()"), but context lines have changed.
      
      Function isolate_migratepages_block() runs some checks out of lru_lock
      when choose pages for migration.  After checking PageLRU() it checks
      extra page references by comparing page_count() and page_mapcount().
      Between these two checks page could be removed from lru, freed and taken
      by slab.
      
      As a result this race triggers VM_BUG_ON(PageSlab()) in page_mapcount().
      Race window is tiny.  For certain workload this happens around once a
      year.
      
          page:ffffea0105ca9380 count:1 mapcount:0 mapping:ffff88ff7712c180 index:0x0 compound_mapcount: 0
          flags: 0x500000000008100(slab|head)
          raw: 0500000000008100 dead000000000100 dead000000000200 ffff88ff7712c180
          raw: 0000000000000000 0000000080200020 00000001ffffffff 0000000000000000
          page dumped because: VM_BUG_ON_PAGE(PageSlab(page))
          ------------[ cut here ]------------
          kernel BUG at ./include/linux/mm.h:628!
          invalid opcode: 0000 [#1] SMP NOPTI
          CPU: 77 PID: 504 Comm: kcompactd1 Tainted: G        W         4.19.109-27 #1
          Hardware name: Yandex T175-N41-Y3N/MY81-EX0-Y3N, BIOS R05 06/20/2019
          RIP: 0010:isolate_migratepages_block+0x986/0x9b0
      
      The code in isolate_migratepages_block() was added in commit
      119d6d59 ("mm, compaction: avoid isolating pinned pages") before
      adding VM_BUG_ON into page_mapcount().
      
      This race has been predicted in 2015 by Vlastimil Babka (see link
      below).
      
      [akpm@linux-foundation.org: comment tweaks, per Hugh]
      Fixes: 1d148e21 ("mm: add VM_BUG_ON_PAGE() to page_mapcount()")
      Signed-off-by: default avatarKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Acked-by: default avatarHugh Dickins <hughd@google.com>
      Acked-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Acked-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Cc: David Rientjes <rientjes@google.com>
      Cc: <stable@vger.kernel.org>
      Link: http://lkml.kernel.org/r/159032779896.957378.7852761411265662220.stgit@buzz
      Link: https://lore.kernel.org/lkml/557710E1.6060103@suse.cz/
      Link: https://lore.kernel.org/linux-mm/158937872515.474360.5066096871639561424.stgit@buzz/T/ (v1)
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      584da13a
    • Jerry Lee's avatar
      libceph: ignore pool overlay and cache logic on redirects · aa8b1687
      Jerry Lee authored
      [ Upstream commit 890bd0f8 ]
      
      OSD client should ignore cache/overlay flag if got redirect reply.
      Otherwise, the client hangs when the cache tier is in forward mode.
      
      [ idryomov: Redirects are effectively deprecated and no longer
        used or tested.  The original tiering modes based on redirects
        are inherently flawed because redirects can race and reorder,
        potentially resulting in data corruption.  The new proxy and
        readproxy tiering modes should be used instead of forward and
        readforward.  Still marking for stable as obviously correct,
        though. ]
      
      Cc: stable@vger.kernel.org
      URL: https://tracker.ceph.com/issues/23296
      URL: https://tracker.ceph.com/issues/36406Signed-off-by: default avatarJerry Lee <leisurelysw24@gmail.com>
      Reviewed-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      aa8b1687
    • Eric W. Biederman's avatar
      exec: Always set cap_ambient in cap_bprm_set_creds · 8a093d42
      Eric W. Biederman authored
      [ Upstream commit a4ae32c7 ]
      
      An invariant of cap_bprm_set_creds is that every field in the new cred
      structure that cap_bprm_set_creds might set, needs to be set every
      time to ensure the fields does not get a stale value.
      
      The field cap_ambient is not set every time cap_bprm_set_creds is
      called, which means that if there is a suid or sgid script with an
      interpreter that has neither the suid nor the sgid bits set the
      interpreter should be able to accept ambient credentials.
      Unfortuantely because cap_ambient is not reset to it's original value
      the interpreter can not accept ambient credentials.
      
      Given that the ambient capability set is expected to be controlled by
      the caller, I don't think this is particularly serious.  But it is
      definitely worth fixing so the code works correctly.
      
      I have tested to verify my reading of the code is correct and the
      interpreter of a sgid can receive ambient capabilities with this
      change and cannot receive ambient capabilities without this change.
      
      Cc: stable@vger.kernel.org
      Cc: Andy Lutomirski <luto@kernel.org>
      Fixes: 58319057 ("capabilities: ambient capabilities")
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8a093d42