1. 29 Apr, 2020 40 commits
    • Longpeng's avatar
      mm/hugetlb: fix a addressing exception caused by huge_pte_offset · dcca7d2f
      Longpeng authored
      commit 3c1d7e6c upstream.
      
      Our machine encountered a panic(addressing exception) after run for a
      long time and the calltrace is:
      
          RIP: hugetlb_fault+0x307/0xbe0
          RSP: 0018:ffff9567fc27f808  EFLAGS: 00010286
          RAX: e800c03ff1258d48 RBX: ffffd3bb003b69c0 RCX: e800c03ff1258d48
          RDX: 17ff3fc00eda72b7 RSI: 00003ffffffff000 RDI: e800c03ff1258d48
          RBP: ffff9567fc27f8c8 R08: e800c03ff1258d48 R09: 0000000000000080
          R10: ffffaba0704c22a8 R11: 0000000000000001 R12: ffff95c87b4b60d8
          R13: 00005fff00000000 R14: 0000000000000000 R15: ffff9567face8074
          FS:  00007fe2d9ffb700(0000) GS:ffff956900e40000(0000) knlGS:0000000000000000
          CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
          CR2: ffffd3bb003b69c0 CR3: 000000be67374000 CR4: 00000000003627e0
          DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
          DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
          Call Trace:
            follow_hugetlb_page+0x175/0x540
            __get_user_pages+0x2a0/0x7e0
            __get_user_pages_unlocked+0x15d/0x210
            __gfn_to_pfn_memslot+0x3c5/0x460 [kvm]
            try_async_pf+0x6e/0x2a0 [kvm]
            tdp_page_fault+0x151/0x2d0 [kvm]
           ...
            kvm_arch_vcpu_ioctl_run+0x330/0x490 [kvm]
            kvm_vcpu_ioctl+0x309/0x6d0 [kvm]
            do_vfs_ioctl+0x3f0/0x540
            SyS_ioctl+0xa1/0xc0
            system_call_fastpath+0x22/0x27
      
      For 1G hugepages, huge_pte_offset() wants to return NULL or pudp, but it
      may return a wrong 'pmdp' if there is a race.  Please look at the
      following code snippet:
      
          ...
          pud = pud_offset(p4d, addr);
          if (sz != PUD_SIZE && pud_none(*pud))
              return NULL;
          /* hugepage or swap? */
          if (pud_huge(*pud) || !pud_present(*pud))
              return (pte_t *)pud;
      
          pmd = pmd_offset(pud, addr);
          if (sz != PMD_SIZE && pmd_none(*pmd))
              return NULL;
          /* hugepage or swap? */
          if (pmd_huge(*pmd) || !pmd_present(*pmd))
              return (pte_t *)pmd;
          ...
      
      The following sequence would trigger this bug:
      
       - CPU0: sz = PUD_SIZE and *pud = 0 , continue
       - CPU0: "pud_huge(*pud)" is false
       - CPU1: calling hugetlb_no_page and set *pud to xxxx8e7(PRESENT)
       - CPU0: "!pud_present(*pud)" is false, continue
       - CPU0: pmd = pmd_offset(pud, addr) and maybe return a wrong pmdp
      
      However, we want CPU0 to return NULL or pudp in this case.
      
      We must make sure there is exactly one dereference of pud and pmd.
      Signed-off-by: default avatarLongpeng <longpeng2@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
      Reviewed-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Sean Christopherson <sean.j.christopherson@intel.com>
      Cc: <stable@vger.kernel.org>
      Link: http://lkml.kernel.org/r/20200413010342.771-1-longpeng2@huawei.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dcca7d2f
    • Jann Horn's avatar
      vmalloc: fix remap_vmalloc_range() bounds checks · d8da38ea
      Jann Horn authored
      commit bdebd6a2 upstream.
      
      remap_vmalloc_range() has had various issues with the bounds checks it
      promises to perform ("This function checks that addr is a valid
      vmalloc'ed area, and that it is big enough to cover the vma") over time,
      e.g.:
      
       - not detecting pgoff<<PAGE_SHIFT overflow
      
       - not detecting (pgoff<<PAGE_SHIFT)+usize overflow
      
       - not checking whether addr and addr+(pgoff<<PAGE_SHIFT) are the same
         vmalloc allocation
      
       - comparing a potentially wildly out-of-bounds pointer with the end of
         the vmalloc region
      
      In particular, since commit fc970227 ("bpf: Add mmap() support for
      BPF_MAP_TYPE_ARRAY"), unprivileged users can cause kernel null pointer
      dereferences by calling mmap() on a BPF map with a size that is bigger
      than the distance from the start of the BPF map to the end of the
      address space.
      
      This could theoretically be used as a kernel ASLR bypass, by using
      whether mmap() with a given offset oopses or returns an error code to
      perform a binary search over the possible address range.
      
      To allow remap_vmalloc_range_partial() to verify that addr and
      addr+(pgoff<<PAGE_SHIFT) are in the same vmalloc region, pass the offset
      to remap_vmalloc_range_partial() instead of adding it to the pointer in
      remap_vmalloc_range().
      
      In remap_vmalloc_range_partial(), fix the check against
      get_vm_area_size() by using size comparisons instead of pointer
      comparisons, and add checks for pgoff.
      
      Fixes: 83342314 ("[PATCH] mm: introduce remap_vmalloc_range()")
      Signed-off-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: stable@vger.kernel.org
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: KP Singh <kpsingh@chromium.org>
      Link: http://lkml.kernel.org/r/20200415222312.236431-1-jannh@google.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d8da38ea
    • Alan Stern's avatar
      USB: hub: Fix handling of connect changes during sleep · e6755e71
      Alan Stern authored
      commit 9f952e26 upstream.
      
      Commit 8099f58f ("USB: hub: Don't record a connect-change event
      during reset-resume") wasn't very well conceived.  The problem it
      tried to fix was that if a connect-change event occurred while the
      system was asleep (such as a device disconnecting itself from the bus
      when it is suspended and then reconnecting when it resumes)
      requiring a reset-resume during the system wakeup transition, the hub
      port's change_bit entry would remain set afterward.  This would cause
      the hub driver to believe another connect-change event had occurred
      after the reset-resume, which was wrong and would lead the driver to
      send unnecessary requests to the device (which could interfere with a
      firmware update).
      
      The commit tried to fix this by not setting the change_bit during the
      wakeup.  But this was the wrong thing to do; it means that when a
      device is unplugged while the system is asleep, the hub driver doesn't
      realize anything has happened: The change_bit flag which would tell it
      to handle the disconnect event is clear.
      
      The commit needs to be reverted and the problem fixed in a different
      way.  Fortunately an alternative solution was noted in the commit's
      Changelog: We can continue to set the change_bit entry in
      hub_activate() but then clear it when a reset-resume occurs.  That way
      the the hub driver will see the change_bit when a device is
      disconnected but won't see it when the device is still present.
      
      That's what this patch does.
      Reported-and-tested-by: default avatarPeter Chen <peter.chen@nxp.com>
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Fixes: 8099f58f ("USB: hub: Don't record a connect-change event during reset-resume")
      Tested-by: default avatarPaul Zimmerman <pauldzim@gmail.com>
      CC: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/Pine.LNX.4.44L0.2004221602480.11262-100000@iolanthe.rowland.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e6755e71
    • Alan Stern's avatar
      USB: core: Fix free-while-in-use bug in the USB S-Glibrary · 45ea77b7
      Alan Stern authored
      commit 056ad39e upstream.
      
      FuzzUSB (a variant of syzkaller) found a free-while-still-in-use bug
      in the USB scatter-gather library:
      
      BUG: KASAN: use-after-free in atomic_read
      include/asm-generic/atomic-instrumented.h:26 [inline]
      BUG: KASAN: use-after-free in usb_hcd_unlink_urb+0x5f/0x170
      drivers/usb/core/hcd.c:1607
      Read of size 4 at addr ffff888065379610 by task kworker/u4:1/27
      
      CPU: 1 PID: 27 Comm: kworker/u4:1 Not tainted 5.5.11 #2
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
      1.10.2-1ubuntu1 04/01/2014
      Workqueue: scsi_tmf_2 scmd_eh_abort_handler
      Call Trace:
       __dump_stack lib/dump_stack.c:77 [inline]
       dump_stack+0xce/0x128 lib/dump_stack.c:118
       print_address_description.constprop.4+0x21/0x3c0 mm/kasan/report.c:374
       __kasan_report+0x153/0x1cb mm/kasan/report.c:506
       kasan_report+0x12/0x20 mm/kasan/common.c:639
       check_memory_region_inline mm/kasan/generic.c:185 [inline]
       check_memory_region+0x152/0x1b0 mm/kasan/generic.c:192
       __kasan_check_read+0x11/0x20 mm/kasan/common.c:95
       atomic_read include/asm-generic/atomic-instrumented.h:26 [inline]
       usb_hcd_unlink_urb+0x5f/0x170 drivers/usb/core/hcd.c:1607
       usb_unlink_urb+0x72/0xb0 drivers/usb/core/urb.c:657
       usb_sg_cancel+0x14e/0x290 drivers/usb/core/message.c:602
       usb_stor_stop_transport+0x5e/0xa0 drivers/usb/storage/transport.c:937
      
      This bug occurs when cancellation of the S-G transfer races with
      transfer completion.  When that happens, usb_sg_cancel() may continue
      to access the transfer's URBs after usb_sg_wait() has freed them.
      
      The bug is caused by the fact that usb_sg_cancel() does not take any
      sort of reference to the transfer, and so there is nothing to prevent
      the URBs from being deallocated while the routine is trying to use
      them.  The fix is to take such a reference by incrementing the
      transfer's io->count field while the cancellation is in progres and
      decrementing it afterward.  The transfer's URBs are not deallocated
      until io->complete is triggered, which happens when io->count reaches
      zero.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Reported-and-tested-by: default avatarKyungtae Kim <kt0755@gmail.com>
      CC: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/Pine.LNX.4.44L0.2003281615140.14837-100000@netrider.rowland.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      45ea77b7
    • Jann Horn's avatar
      USB: early: Handle AMD's spec-compliant identifiers, too · d932c9f1
      Jann Horn authored
      commit 7dbdb53d upstream.
      
      This fixes a bug that causes the USB3 early console to freeze after
      printing a single line on AMD machines because it can't parse the
      Transfer TRB properly.
      
      The spec at
      https://www.intel.com/content/dam/www/public/us/en/documents/technical-specifications/extensible-host-controler-interface-usb-xhci.pdf
      says in section "4.5.1 Device Context Index" that the Context Index,
      also known as Endpoint ID according to
      section "1.6 Terms and Abbreviations", is normally computed as
      `DCI = (Endpoint Number * 2) + Direction`, which matches the current
      definitions of XDBC_EPID_OUT and XDBC_EPID_IN.
      
      However, the numbering in a Debug Capability Context data structure is
      supposed to be different:
      Section "7.6.3.2 Endpoint Contexts and Transfer Rings" explains that a
      Debug Capability Context data structure has the endpoints mapped to indices
      0 and 1.
      
      Change XDBC_EPID_OUT/XDBC_EPID_IN to the spec-compliant values, add
      XDBC_EPID_OUT_INTEL/XDBC_EPID_IN_INTEL with Intel's incorrect values, and
      let xdbc_handle_tx_event() handle both.
      
      I have verified that with this patch applied, the USB3 early console works
      on both an Intel and an AMD machine.
      
      Fixes: aeb9dd1d ("usb/early: Add driver for xhci debug capability")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJann Horn <jannh@google.com>
      Link: https://lore.kernel.org/r/20200401074619.8024-1-jannh@google.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d932c9f1
    • Jonathan Cox's avatar
      USB: Add USB_QUIRK_DELAY_CTRL_MSG and USB_QUIRK_DELAY_INIT for Corsair K70 RGB RAPIDFIRE · 188551e1
      Jonathan Cox authored
      commit be34a585 upstream.
      
      The Corsair K70 RGB RAPIDFIRE needs the USB_QUIRK_DELAY_INIT and
      USB_QUIRK_DELAY_CTRL_MSG to function or it will randomly not
      respond on boot, just like other Corsair keyboards
      Signed-off-by: default avatarJonathan Cox <jonathan@jdcox.net>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200410212427.2886-1-jonathan@jdcox.netSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      188551e1
    • Changming Liu's avatar
      USB: sisusbvga: Change port variable from signed to unsigned · e129228a
      Changming Liu authored
      commit 2df7405f upstream.
      
      Change a bunch of arguments of wrapper functions which pass signed
      integer to an unsigned integer which might cause undefined behaviors
      when sign integer overflow.
      Signed-off-by: default avatarChangming Liu <liu.changm@northeastern.edu>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/BL0PR06MB45482D71EA822D75A0E60A2EE5D50@BL0PR06MB4548.namprd06.prod.outlook.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e129228a
    • Piotr Krysiuk's avatar
      fs/namespace.c: fix mountpoint reference counter race · f511dc75
      Piotr Krysiuk authored
      A race condition between threads updating mountpoint reference counter
      affects longterm releases 4.4.220, 4.9.220, 4.14.177 and 4.19.118.
      
      The mountpoint reference counter corruption may occur when:
      * one thread increments m_count member of struct mountpoint
        [under namespace_sem, but not holding mount_lock]
          pivot_root()
      * another thread simultaneously decrements the same m_count
        [under mount_lock, but not holding namespace_sem]
          put_mountpoint()
            unhash_mnt()
              umount_mnt()
                mntput_no_expire()
      
      To fix this race condition, grab mount_lock before updating m_count in
      pivot_root().
      
      Reference: CVE-2020-12114
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarPiotr Krysiuk <piotras@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f511dc75
    • Lars-Peter Clausen's avatar
      iio: xilinx-xadc: Make sure not exceed maximum samplerate · 5d42466b
      Lars-Peter Clausen authored
      commit 3b7f9dbb upstream.
      
      The XADC supports a samplerate of up to 1MSPS. Unfortunately the hardware
      does not have a FIFO, which means it generates an interrupt for each
      conversion sequence. At one 1MSPS this creates an interrupt storm that
      causes the system to soft-lock.
      
      For this reason the driver limits the maximum samplerate to 150kSPS.
      Currently this check is only done when setting a new samplerate. But it is
      also possible that the initial samplerate configured in the FPGA bitstream
      exceeds the limit.
      
      In this case when starting to capture data without first changing the
      samplerate the system can overload.
      
      To prevent this check the currently configured samplerate in the probe
      function and reduce it to the maximum if necessary.
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Fixes: bdc8cda1 ("iio:adc: Add Xilinx XADC driver")
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5d42466b
    • Lars-Peter Clausen's avatar
      iio: xilinx-xadc: Fix sequencer configuration for aux channels in simultaneous mode · 9bb4af36
      Lars-Peter Clausen authored
      commit 8bef455c upstream.
      
      The XADC has two internal ADCs. Depending on the mode it is operating in
      either one or both of them are used. The device manual calls this
      continuous (one ADC) and simultaneous (both ADCs) mode.
      
      The meaning of the sequencing register for the aux channels changes
      depending on the mode.
      
      In continuous mode each bit corresponds to one of the 16 aux channels. And
      the single ADC will convert them one by one in order.
      
      In simultaneous mode the aux channels are split into two groups the first 8
      channels are assigned to the first ADC and the other 8 channels to the
      second ADC. The upper 8 bits of the sequencing register are unused and the
      lower 8 bits control both ADCs. This means a bit needs to be set if either
      the corresponding channel from the first group or the second group (or
      both) are set.
      
      Currently the driver does not have the special handling required for
      simultaneous mode. Add it.
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Fixes: bdc8cda1 ("iio:adc: Add Xilinx XADC driver")
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9bb4af36
    • Lars-Peter Clausen's avatar
      iio: xilinx-xadc: Fix clearing interrupt when enabling trigger · 96a0dc7e
      Lars-Peter Clausen authored
      commit f954b098 upstream.
      
      When enabling the trigger and unmasking the end-of-sequence (EOS) interrupt
      the EOS interrupt should be cleared from the status register. Otherwise it
      is possible that it was still set from a previous capture. If that is the
      case the interrupt would fire immediately even though no conversion has
      been done yet and stale data is being read from the device.
      
      The old code only clears the interrupt if the interrupt was previously
      unmasked. Which does not make much sense since the interrupt is always
      masked at this point and in addition masking the interrupt does not clear
      the interrupt from the status register. So the clearing needs to be done
      unconditionally.
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Fixes: bdc8cda1 ("iio:adc: Add Xilinx XADC driver")
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      96a0dc7e
    • Lars-Peter Clausen's avatar
      iio: xilinx-xadc: Fix ADC-B powerdown · 66961103
      Lars-Peter Clausen authored
      commit e44ec779 upstream.
      
      The check for shutting down the second ADC is inverted. This causes it to
      be powered down when it should be enabled. As a result channels that are
      supposed to be handled by the second ADC return invalid conversion results.
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Fixes: bdc8cda1 ("iio:adc: Add Xilinx XADC driver")
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      66961103
    • Olivier Moysan's avatar
      iio: adc: stm32-adc: fix sleep in atomic context · 7363ec62
      Olivier Moysan authored
      commit e2042d29 upstream.
      
      This commit fixes the following error:
      "BUG: sleeping function called from invalid context at kernel/irq/chip.c"
      
      In DMA mode suppress the trigger irq handler, and make the buffer
      transfers directly in DMA callback, instead.
      
      Fixes: 2763ea05 ("iio: adc: stm32: add optional dma support")
      Signed-off-by: default avatarOlivier Moysan <olivier.moysan@st.com>
      Acked-by: default avatarFabrice Gasnier <fabrice.gasnier@st.com>
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7363ec62
    • Lary Gibaud's avatar
      iio: st_sensors: rely on odr mask to know if odr can be set · 5ea5de62
      Lary Gibaud authored
      commit e450e07c upstream.
      
      Indeed, relying on addr being not 0 cannot work because some device have
      their register to set odr at address 0. As a matter of fact, if the odr
      can be set, then there is a mask.
      
      Sensors with ODR register at address 0 are: lsm303dlh, lsm303dlhc, lsm303dlm
      
      Fixes: 7d245172 ("iio: common: st_sensors: check odr address value in st_sensors_set_odr()")
      Signed-off-by: default avatarLary Gibaud <yarl-baudig@mailoo.org>
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5ea5de62
    • Lars Engebretsen's avatar
      iio: core: remove extra semi-colon from devm_iio_device_register() macro · ee7ab211
      Lars Engebretsen authored
      commit a0747914 upstream.
      
      This change removes the semi-colon from the devm_iio_device_register()
      macro which seems to have been added by accident.
      
      Fixes: 63b19547 ("iio: Use macro magic to avoid manual assign of driver_module")
      Signed-off-by: default avatarLars Engebretsen <lars@engebretsen.ch>
      Cc: <Stable@vger.kernel.org>
      Reviewed-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ee7ab211
    • Takashi Iwai's avatar
      ALSA: usb-audio: Add connector notifier delegation · 3189c4ab
      Takashi Iwai authored
      [ Upstream commit fef66ae7 ]
      
      It turned out that ALC1220-VB USB-audio device gives the interrupt
      event to some PCM terminals while those don't allow the connector
      state request but only the actual I/O terminals return the request.
      The recent commit 7dc3c5a0 ("ALSA: usb-audio: Don't create jack
      controls for PCM terminals") excluded those phantom terminals, so
      those events are ignored, too.
      
      My first thought was that this could be easily deduced from the
      associated terminals, but some of them have even no associate terminal
      ID, hence it's not too trivial to figure out.
      
      Since the number of such terminals are small and limited, this patch
      implements another quirk table for the simple mapping of the
      connectors.  It's not really scalable, but let's hope that there will
      be not many such funky devices in future.
      
      Fixes: 7dc3c5a0 ("ALSA: usb-audio: Don't create jack controls for PCM terminals")
      BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=206873
      Link: https://lore.kernel.org/r/20200422113320.26664-1-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3189c4ab
    • Takashi Iwai's avatar
      ALSA: usb-audio: Add static mapping table for ALC1220-VB-based mobos · cd6bc48f
      Takashi Iwai authored
      [ Upstream commit a43c1c41 ]
      
      TRX40 mobos from MSI and others with ALC1220-VB USB-audio device need
      yet more quirks for the proper control names.
      
      This patch provides the mapping table for those boards, correcting the
      FU names for volume and mute controls as well as the terminal names
      for jack controls.  It also improves build_connector_control() not to
      add the directional suffix blindly if the string is given from the
      mapping table.
      
      With this patch applied, the new UCM profiles will be effective.
      
      BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=206873
      Link: https://lore.kernel.org/r/20200420062036.28567-1-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cd6bc48f
    • Takashi Iwai's avatar
      ALSA: hda: Remove ASUS ROG Zenith from the blacklist · 4f3dab13
      Takashi Iwai authored
      [ Upstream commit a8cf44f0 ]
      
      The commit 3c6fd1f0 ("ALSA: hda: Add driver blacklist") added a
      new blacklist for the devices that are known to have empty codecs, and
      one of the entries was ASUS ROG Zenith II (PCI SSID 1043:874f).
      However, it turned out that the very same PCI SSID is used for the
      previous model that does have the valid HD-audio codecs and the change
      broke the sound on it.
      
      This patch reverts the corresponding entry as a temporary solution.
      Although Zenith II and co will see get the empty HD-audio bus again,
      it'd be merely resource wastes and won't affect the functionality,
      so it's no end of the world.  We'll need to address this later,
      e.g. by either switching to DMI string matching or using PCI ID &
      SSID pairs.
      
      Fixes: 3c6fd1f0 ("ALSA: hda: Add driver blacklist")
      Reported-by: default avatarJohnathan Smithinovic <johnathan.smithinovic@gmx.at>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200419071926.22683-1-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4f3dab13
    • Waiman Long's avatar
      KEYS: Avoid false positive ENOMEM error on key read · e4a281c7
      Waiman Long authored
      [ Upstream commit 4f088249 ]
      
      By allocating a kernel buffer with a user-supplied buffer length, it
      is possible that a false positive ENOMEM error may be returned because
      the user-supplied length is just too large even if the system do have
      enough memory to hold the actual key data.
      
      Moreover, if the buffer length is larger than the maximum amount of
      memory that can be returned by kmalloc() (2^(MAX_ORDER-1) number of
      pages), a warning message will also be printed.
      
      To reduce this possibility, we set a threshold (PAGE_SIZE) over which we
      do check the actual key length first before allocating a buffer of the
      right size to hold it. The threshold is arbitrary, it is just used to
      trigger a buffer length check. It does not limit the actual key length
      as long as there is enough memory to satisfy the memory request.
      
      To further avoid large buffer allocation failure due to page
      fragmentation, kvmalloc() is used to allocate the buffer so that vmapped
      pages can be used when there is not a large enough contiguous set of
      pages available for allocation.
      
      In the extremely unlikely scenario that the key keeps on being changed
      and made longer (still <= buflen) in between 2 __keyctl_read_key()
      calls, the __keyctl_read_key() calling loop in keyctl_read_key() may
      have to be iterated a large number of times, but definitely not infinite.
      Signed-off-by: default avatarWaiman Long <longman@redhat.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e4a281c7
    • Dan Carpenter's avatar
      mlxsw: Fix some IS_ERR() vs NULL bugs · b9d1ba5d
      Dan Carpenter authored
      [ Upstream commit c391eb83 ]
      
      The mlxsw_sp_acl_rulei_create() function is supposed to return an error
      pointer from mlxsw_afa_block_create().  The problem is that these
      functions both return NULL instead of error pointers.  Half the callers
      expect NULL and half expect error pointers so it could lead to a NULL
      dereference on failure.
      
      This patch changes both of them to return error pointers and changes all
      the callers which checked for NULL to check for IS_ERR() instead.
      
      Fixes: 4cda7d8d ("mlxsw: core: Introduce flexible actions support")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Reviewed-by: default avatarIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b9d1ba5d
    • David Ahern's avatar
      vrf: Check skb for XFRM_TRANSFORMED flag · c39723cc
      David Ahern authored
      [ Upstream commit 16b9db1c ]
      
      To avoid a loop with qdiscs and xfrms, check if the skb has already gone
      through the qdisc attached to the VRF device and then to the xfrm layer.
      If so, no need for a second redirect.
      
      Fixes: 193125db ("net: Introduce VRF device driver")
      Reported-by: default avatarTrev Larock <trev@larock.ca>
      Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c39723cc
    • David Ahern's avatar
      xfrm: Always set XFRM_TRANSFORMED in xfrm{4,6}_output_finish · 995908dc
      David Ahern authored
      [ Upstream commit 0c922a48 ]
      
      IPSKB_XFRM_TRANSFORMED and IP6SKB_XFRM_TRANSFORMED are skb flags set by
      xfrm code to tell other skb handlers that the packet has been passed
      through the xfrm output functions. Simplify the code and just always
      set them rather than conditionally based on netfilter enabled thus
      making the flag available for other users.
      Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      995908dc
    • Florian Fainelli's avatar
      net: dsa: b53: b53_arl_rw_op() needs to select IVL or SVL · 4dbc9916
      Florian Fainelli authored
      [ Upstream commit 64fec949 ]
      
      Flip the IVL_SVL_SELECT bit correctly based on the VLAN enable status,
      the default is to perform Shared VLAN learning instead of Individual
      learning.
      
      Fixes: 1da6df85 ("net: dsa: b53: Implement ARL add/del/dump operations")
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4dbc9916
    • Florian Fainelli's avatar
      net: dsa: b53: Rework ARL bin logic · 5e14d2ae
      Florian Fainelli authored
      [ Upstream commit 6344dbde ]
      
      When asking the ARL to read a MAC address, we will get a number of bins
      returned in a single read. Out of those bins, there can essentially be 3
      states:
      
      - all bins are full, we have no space left, and we can either replace an
        existing address or return that full condition
      
      - the MAC address was found, then we need to return its bin index and
        modify that one, and only that one
      
      - the MAC address was not found and we have a least one bin free, we use
        that bin index location then
      
      The code would unfortunately fail on all counts.
      
      Fixes: 1da6df85 ("net: dsa: b53: Implement ARL add/del/dump operations")
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5e14d2ae
    • Florian Fainelli's avatar
      net: dsa: b53: Fix ARL register definitions · 5f1653ee
      Florian Fainelli authored
      [ Upstream commit c2e77a18 ]
      
      The ARL {MAC,VID} tuple and the forward entry were off by 0x10 bytes,
      which means that when we read/wrote from/to ARL bin index 0, we were
      actually accessing the ARLA_RWCTRL register.
      
      Fixes: 1da6df85 ("net: dsa: b53: Implement ARL add/del/dump operations")
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5f1653ee
    • Florian Fainelli's avatar
      net: dsa: b53: Lookup VID in ARL searches when VLAN is enabled · a224e376
      Florian Fainelli authored
      [ Upstream commit 2e97b0cd ]
      
      When VLAN is enabled, and an ARL search is issued, we also need to
      compare the full {MAC,VID} tuple before returning a successful search
      result.
      
      Fixes: 1da6df85 ("net: dsa: b53: Implement ARL add/del/dump operations")
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a224e376
    • David Ahern's avatar
      vrf: Fix IPv6 with qdisc and xfrm · abc103cd
      David Ahern authored
      [ Upstream commit a53c1028 ]
      
      When a qdisc is attached to the VRF device, the packet goes down the ndo
      xmit function which is setup to send the packet back to the VRF driver
      which does a lookup to send the packet out. The lookup in the VRF driver
      is not considering xfrm policies. Change it to use ip6_dst_lookup_flow
      rather than ip6_route_output.
      
      Fixes: 35402e31 ("net: Add IPv6 support to VRF device")
      Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      abc103cd
    • Taehee Yoo's avatar
      team: fix hang in team_mode_get() · efa7382a
      Taehee Yoo authored
      [ Upstream commit 1c30fbc7 ]
      
      When team mode is changed or set, the team_mode_get() is called to check
      whether the mode module is inserted or not. If the mode module is not
      inserted, it calls the request_module().
      In the request_module(), it creates a child process, which is
      the "modprobe" process and waits for the done of the child process.
      At this point, the following locks were used.
      down_read(&cb_lock()); by genl_rcv()
          genl_lock(); by genl_rcv_msc()
              rtnl_lock(); by team_nl_cmd_options_set()
                  mutex_lock(&team->lock); by team_nl_team_get()
      
      Concurrently, the team module could be removed by rmmod or "modprobe -r"
      The __exit function of team module is team_module_exit(), which calls
      team_nl_fini() and it tries to acquire following locks.
      down_write(&cb_lock);
          genl_lock();
      Because of the genl_lock() and cb_lock, this process can't be finished
      earlier than request_module() routine.
      
      The problem secenario.
      CPU0                                     CPU1
      team_mode_get
          request_module()
                                               modprobe -r team_mode_roundrobin
                                                           team <--(B)
              modprobe team <--(A)
                  team_mode_roundrobin
      
      By request_module(), the "modprobe team_mode_roundrobin" command
      will be executed. At this point, the modprobe process will decide
      that the team module should be inserted before team_mode_roundrobin.
      Because the team module is being removed.
      
      By the module infrastructure, the same module insert/remove operations
      can't be executed concurrently.
      So, (A) waits for (B) but (B) also waits for (A) because of locks.
      So that the hang occurs at this point.
      
      Test commands:
          while :
          do
              teamd -d &
      	killall teamd &
      	modprobe -rv team_mode_roundrobin &
          done
      
      The approach of this patch is to hold the reference count of the team
      module if the team module is compiled as a module. If the reference count
      of the team module is not zero while request_module() is being called,
      the team module will not be removed at that moment.
      So that the above scenario could not occur.
      
      Fixes: 3d249d4c ("net: introduce ethernet teaming device")
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Reviewed-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      efa7382a
    • Eric Dumazet's avatar
      tcp: cache line align MAX_TCP_HEADER · 3405bf51
      Eric Dumazet authored
      [ Upstream commit 9bacd256 ]
      
      TCP stack is dumb in how it cooks its output packets.
      
      Depending on MAX_HEADER value, we might chose a bad ending point
      for the headers.
      
      If we align the end of TCP headers to cache line boundary, we
      make sure to always use the smallest number of cache lines,
      which always help.
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Soheil Hassas Yeganeh <soheil@google.com>
      Acked-by: default avatarSoheil Hassas Yeganeh <soheil@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3405bf51
    • Eric Dumazet's avatar
      sched: etf: do not assume all sockets are full blown · 1ee7ced6
      Eric Dumazet authored
      [ Upstream commit a1211bf9 ]
      
      skb->sk does not always point to a full blown socket,
      we need to use sk_fullsock() before accessing fields which
      only make sense on full socket.
      
      BUG: KASAN: use-after-free in report_sock_error+0x286/0x300 net/sched/sch_etf.c:141
      Read of size 1 at addr ffff88805eb9b245 by task syz-executor.5/9630
      
      CPU: 1 PID: 9630 Comm: syz-executor.5 Not tainted 5.7.0-rc2-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       <IRQ>
       __dump_stack lib/dump_stack.c:77 [inline]
       dump_stack+0x188/0x20d lib/dump_stack.c:118
       print_address_description.constprop.0.cold+0xd3/0x315 mm/kasan/report.c:382
       __kasan_report.cold+0x35/0x4d mm/kasan/report.c:511
       kasan_report+0x33/0x50 mm/kasan/common.c:625
       report_sock_error+0x286/0x300 net/sched/sch_etf.c:141
       etf_enqueue_timesortedlist+0x389/0x740 net/sched/sch_etf.c:170
       __dev_xmit_skb net/core/dev.c:3710 [inline]
       __dev_queue_xmit+0x154a/0x30a0 net/core/dev.c:4021
       neigh_hh_output include/net/neighbour.h:499 [inline]
       neigh_output include/net/neighbour.h:508 [inline]
       ip6_finish_output2+0xfb5/0x25b0 net/ipv6/ip6_output.c:117
       __ip6_finish_output+0x442/0xab0 net/ipv6/ip6_output.c:143
       ip6_finish_output+0x34/0x1f0 net/ipv6/ip6_output.c:153
       NF_HOOK_COND include/linux/netfilter.h:296 [inline]
       ip6_output+0x239/0x810 net/ipv6/ip6_output.c:176
       dst_output include/net/dst.h:435 [inline]
       NF_HOOK include/linux/netfilter.h:307 [inline]
       NF_HOOK include/linux/netfilter.h:301 [inline]
       ip6_xmit+0xe1a/0x2090 net/ipv6/ip6_output.c:280
       tcp_v6_send_synack+0x4e7/0x960 net/ipv6/tcp_ipv6.c:521
       tcp_rtx_synack+0x10d/0x1a0 net/ipv4/tcp_output.c:3916
       inet_rtx_syn_ack net/ipv4/inet_connection_sock.c:669 [inline]
       reqsk_timer_handler+0x4c2/0xb40 net/ipv4/inet_connection_sock.c:763
       call_timer_fn+0x1ac/0x780 kernel/time/timer.c:1405
       expire_timers kernel/time/timer.c:1450 [inline]
       __run_timers kernel/time/timer.c:1774 [inline]
       __run_timers kernel/time/timer.c:1741 [inline]
       run_timer_softirq+0x623/0x1600 kernel/time/timer.c:1787
       __do_softirq+0x26c/0x9f7 kernel/softirq.c:292
       invoke_softirq kernel/softirq.c:373 [inline]
       irq_exit+0x192/0x1d0 kernel/softirq.c:413
       exiting_irq arch/x86/include/asm/apic.h:546 [inline]
       smp_apic_timer_interrupt+0x19e/0x600 arch/x86/kernel/apic/apic.c:1140
       apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:829
       </IRQ>
      RIP: 0010:des_encrypt+0x157/0x9c0 lib/crypto/des.c:792
      Code: 85 22 06 00 00 41 31 dc 41 8b 4d 04 44 89 e2 41 83 e4 3f 4a 8d 3c a5 60 72 72 88 81 e2 3f 3f 3f 3f 48 89 f8 48 c1 e8 03 31 d9 <0f> b6 34 28 48 89 f8 c1 c9 04 83 e0 07 83 c0 03 40 38 f0 7c 09 40
      RSP: 0018:ffffc90003b5f6c0 EFLAGS: 00000282 ORIG_RAX: ffffffffffffff13
      RAX: 1ffffffff10e4e55 RBX: 00000000d2f846d0 RCX: 00000000d2f846d0
      RDX: 0000000012380612 RSI: ffffffff839863ca RDI: ffffffff887272a8
      RBP: dffffc0000000000 R08: ffff888091d0a380 R09: 0000000000800081
      R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000012
      R13: ffff8880a8ae8078 R14: 00000000c545c93e R15: 0000000000000006
       cipher_crypt_one crypto/cipher.c:75 [inline]
       crypto_cipher_encrypt_one+0x124/0x210 crypto/cipher.c:82
       crypto_cbcmac_digest_update+0x1b5/0x250 crypto/ccm.c:830
       crypto_shash_update+0xc4/0x120 crypto/shash.c:119
       shash_ahash_update+0xa3/0x110 crypto/shash.c:246
       crypto_ahash_update include/crypto/hash.h:547 [inline]
       hash_sendmsg+0x518/0xad0 crypto/algif_hash.c:102
       sock_sendmsg_nosec net/socket.c:652 [inline]
       sock_sendmsg+0xcf/0x120 net/socket.c:672
       ____sys_sendmsg+0x308/0x7e0 net/socket.c:2362
       ___sys_sendmsg+0x100/0x170 net/socket.c:2416
       __sys_sendmmsg+0x195/0x480 net/socket.c:2506
       __do_sys_sendmmsg net/socket.c:2535 [inline]
       __se_sys_sendmmsg net/socket.c:2532 [inline]
       __x64_sys_sendmmsg+0x99/0x100 net/socket.c:2532
       do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
       entry_SYSCALL_64_after_hwframe+0x49/0xb3
      RIP: 0033:0x45c829
      Code: 0d b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 db b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00
      RSP: 002b:00007f6d9528ec78 EFLAGS: 00000246 ORIG_RAX: 0000000000000133
      RAX: ffffffffffffffda RBX: 00000000004fc080 RCX: 000000000045c829
      RDX: 0000000000000001 RSI: 0000000020002640 RDI: 0000000000000004
      RBP: 000000000078bf00 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
      R13: 00000000000008d7 R14: 00000000004cb7aa R15: 00007f6d9528f6d4
      
      Fixes: 4b15c707 ("net/sched: Make etf report drops on error_queue")
      Fixes: 25db26a9 ("net/sched: Introduce the ETF Qdisc")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Cc: Vinicius Costa Gomes <vinicius.gomes@intel.com>
      Reviewed-by: default avatarVinicius Costa Gomes <vinicius.gomes@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1ee7ced6
    • Xiyu Yang's avatar
      net/x25: Fix x25_neigh refcnt leak when receiving frame · d9ef1c55
      Xiyu Yang authored
      [ Upstream commit f35d1297 ]
      
      x25_lapb_receive_frame() invokes x25_get_neigh(), which returns a
      reference of the specified x25_neigh object to "nb" with increased
      refcnt.
      
      When x25_lapb_receive_frame() returns, local variable "nb" becomes
      invalid, so the refcount should be decreased to keep refcount balanced.
      
      The reference counting issue happens in one path of
      x25_lapb_receive_frame(). When pskb_may_pull() returns false, the
      function forgets to decrease the refcnt increased by x25_get_neigh(),
      causing a refcnt leak.
      
      Fix this issue by calling x25_neigh_put() when pskb_may_pull() returns
      false.
      
      Fixes: cb101ed2 ("x25: Handle undersized/fragmented skbs")
      Signed-off-by: default avatarXiyu Yang <xiyuyang19@fudan.edu.cn>
      Signed-off-by: default avatarXin Tan <tanxin.ctf@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d9ef1c55
    • Marc Zyngier's avatar
      net: stmmac: dwmac-meson8b: Add missing boundary to RGMII TX clock array · 134831fa
      Marc Zyngier authored
      [ Upstream commit f0212a5e ]
      
      Running with KASAN on a VIM3L systems leads to the following splat
      when probing the Ethernet device:
      
      ==================================================================
      BUG: KASAN: global-out-of-bounds in _get_maxdiv+0x74/0xd8
      Read of size 4 at addr ffffa000090615f4 by task systemd-udevd/139
      CPU: 1 PID: 139 Comm: systemd-udevd Tainted: G            E     5.7.0-rc1-00101-g8624b7577b9c #781
      Hardware name: amlogic w400/w400, BIOS 2020.01-rc5 03/12/2020
      Call trace:
       dump_backtrace+0x0/0x2a0
       show_stack+0x20/0x30
       dump_stack+0xec/0x148
       print_address_description.isra.12+0x70/0x35c
       __kasan_report+0xfc/0x1d4
       kasan_report+0x4c/0x68
       __asan_load4+0x9c/0xd8
       _get_maxdiv+0x74/0xd8
       clk_divider_bestdiv+0x74/0x5e0
       clk_divider_round_rate+0x80/0x1a8
       clk_core_determine_round_nolock.part.9+0x9c/0xd0
       clk_core_round_rate_nolock+0xf0/0x108
       clk_hw_round_rate+0xac/0xf0
       clk_factor_round_rate+0xb8/0xd0
       clk_core_determine_round_nolock.part.9+0x9c/0xd0
       clk_core_round_rate_nolock+0xf0/0x108
       clk_core_round_rate_nolock+0xbc/0x108
       clk_core_set_rate_nolock+0xc4/0x2e8
       clk_set_rate+0x58/0xe0
       meson8b_dwmac_probe+0x588/0x72c [dwmac_meson8b]
       platform_drv_probe+0x78/0xd8
       really_probe+0x158/0x610
       driver_probe_device+0x140/0x1b0
       device_driver_attach+0xa4/0xb0
       __driver_attach+0xcc/0x1c8
       bus_for_each_dev+0xf4/0x168
       driver_attach+0x3c/0x50
       bus_add_driver+0x238/0x2e8
       driver_register+0xc8/0x1e8
       __platform_driver_register+0x88/0x98
       meson8b_dwmac_driver_init+0x28/0x1000 [dwmac_meson8b]
       do_one_initcall+0xa8/0x328
       do_init_module+0xe8/0x368
       load_module+0x3300/0x36b0
       __do_sys_finit_module+0x120/0x1a8
       __arm64_sys_finit_module+0x4c/0x60
       el0_svc_common.constprop.2+0xe4/0x268
       do_el0_svc+0x98/0xa8
       el0_svc+0x24/0x68
       el0_sync_handler+0x12c/0x318
       el0_sync+0x158/0x180
      
      The buggy address belongs to the variable:
       div_table.63646+0x34/0xfffffffffffffa40 [dwmac_meson8b]
      
      Memory state around the buggy address:
       ffffa00009061480: fa fa fa fa 00 00 00 01 fa fa fa fa 00 00 00 00
       ffffa00009061500: 05 fa fa fa fa fa fa fa 00 04 fa fa fa fa fa fa
      >ffffa00009061580: 00 03 fa fa fa fa fa fa 00 00 00 00 00 00 fa fa
                                                                   ^
       ffffa00009061600: fa fa fa fa 00 01 fa fa fa fa fa fa 01 fa fa fa
       ffffa00009061680: fa fa fa fa 00 01 fa fa fa fa fa fa 04 fa fa fa
      ==================================================================
      
      Digging into this indeed shows that the clock divider array is
      lacking a final fence, and that the clock subsystems goes in the
      weeds. Oh well.
      
      Let's add the empty structure that indicates the end of the array.
      
      Fixes: bd6f4854 ("net: stmmac: dwmac-meson8b: Fix the RGMII TX delay on Meson8b/8m2 SoCs")
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
      Reviewed-by: default avatarMartin Blumenstingl <martin.blumenstingl@googlemail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      134831fa
    • Xiyu Yang's avatar
      net: netrom: Fix potential nr_neigh refcnt leak in nr_add_node · 275828d4
      Xiyu Yang authored
      [ Upstream commit d03f2284 ]
      
      nr_add_node() invokes nr_neigh_get_dev(), which returns a local
      reference of the nr_neigh object to "nr_neigh" with increased refcnt.
      
      When nr_add_node() returns, "nr_neigh" becomes invalid, so the refcount
      should be decreased to keep refcount balanced.
      
      The issue happens in one normal path of nr_add_node(), which forgets to
      decrease the refcnt increased by nr_neigh_get_dev() and causes a refcnt
      leak. It should decrease the refcnt before the function returns like
      other normal paths do.
      
      Fix this issue by calling nr_neigh_put() before the nr_add_node()
      returns.
      Signed-off-by: default avatarXiyu Yang <xiyuyang19@fudan.edu.cn>
      Signed-off-by: default avatarXin Tan <tanxin.ctf@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      275828d4
    • Doug Berger's avatar
      net: bcmgenet: correct per TX/RX ring statistics · f7100319
      Doug Berger authored
      [ Upstream commit a6d0b83f ]
      
      The change to track net_device_stats per ring to better support SMP
      missed updating the rx_dropped member.
      
      The ndo_get_stats method is also needed to combine the results for
      ethtool statistics (-S) before filling in the ethtool structure.
      
      Fixes: 37a30b43 ("net: bcmgenet: Track per TX/RX rings statistics")
      Signed-off-by: default avatarDoug Berger <opendmb@gmail.com>
      Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f7100319
    • Taehee Yoo's avatar
      macvlan: fix null dereference in macvlan_device_event() · 9d7ea567
      Taehee Yoo authored
      [ Upstream commit 4dee15b4 ]
      
      In the macvlan_device_event(), the list_first_entry_or_null() is used.
      This function could return null pointer if there is no node.
      But, the macvlan module doesn't check the null pointer.
      So, null-ptr-deref would occur.
      
            bond0
              |
         +----+-----+
         |          |
      macvlan0   macvlan1
         |          |
       dummy0     dummy1
      
      The problem scenario.
      If dummy1 is removed,
      1. ->dellink() of dummy1 is called.
      2. NETDEV_UNREGISTER of dummy1 notification is sent to macvlan module.
      3. ->dellink() of macvlan1 is called.
      4. NETDEV_UNREGISTER of macvlan1 notification is sent to bond module.
      5. __bond_release_one() is called and it internally calls
         dev_set_mac_address().
      6. dev_set_mac_address() calls the ->ndo_set_mac_address() of macvlan1,
         which is macvlan_set_mac_address().
      7. macvlan_set_mac_address() calls the dev_set_mac_address() with dummy1.
      8. NETDEV_CHANGEADDR of dummy1 is sent to macvlan module.
      9. In the macvlan_device_event(), it calls list_first_entry_or_null().
      At this point, dummy1 and macvlan1 were removed.
      So, list_first_entry_or_null() will return NULL.
      
      Test commands:
          ip netns add nst
          ip netns exec nst ip link add bond0 type bond
          for i in {0..10}
          do
              ip netns exec nst ip link add dummy$i type dummy
      	ip netns exec nst ip link add macvlan$i link dummy$i \
      		type macvlan mode passthru
      	ip netns exec nst ip link set macvlan$i master bond0
          done
          ip netns del nst
      
      Splat looks like:
      [   40.585687][  T146] general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] SMP DEI
      [   40.587249][  T146] KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
      [   40.588342][  T146] CPU: 1 PID: 146 Comm: kworker/u8:2 Not tainted 5.7.0-rc1+ #532
      [   40.589299][  T146] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
      [   40.590469][  T146] Workqueue: netns cleanup_net
      [   40.591045][  T146] RIP: 0010:macvlan_device_event+0x4e2/0x900 [macvlan]
      [   40.591905][  T146] Code: 00 00 00 00 00 fc ff df 80 3c 06 00 0f 85 45 02 00 00 48 89 da 48 b8 00 00 00 00 00 fc ff d2
      [   40.594126][  T146] RSP: 0018:ffff88806116f4a0 EFLAGS: 00010246
      [   40.594783][  T146] RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000000
      [   40.595653][  T146] RDX: 0000000000000000 RSI: ffff88806547ddd8 RDI: ffff8880540f1360
      [   40.596495][  T146] RBP: ffff88804011a808 R08: fffffbfff4fb8421 R09: fffffbfff4fb8421
      [   40.597377][  T146] R10: ffffffffa7dc2107 R11: 0000000000000000 R12: 0000000000000008
      [   40.598186][  T146] R13: ffff88804011a000 R14: ffff8880540f1000 R15: 1ffff1100c22de9a
      [   40.599012][  T146] FS:  0000000000000000(0000) GS:ffff888067800000(0000) knlGS:0000000000000000
      [   40.600004][  T146] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   40.600665][  T146] CR2: 00005572d3a807b8 CR3: 000000005fcf4003 CR4: 00000000000606e0
      [   40.601485][  T146] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [   40.602461][  T146] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [   40.603443][  T146] Call Trace:
      [   40.603871][  T146]  ? nf_tables_dump_setelem+0xa0/0xa0 [nf_tables]
      [   40.604587][  T146]  ? macvlan_uninit+0x100/0x100 [macvlan]
      [   40.605212][  T146]  ? __module_text_address+0x13/0x140
      [   40.605842][  T146]  notifier_call_chain+0x90/0x160
      [   40.606477][  T146]  dev_set_mac_address+0x28e/0x3f0
      [   40.607117][  T146]  ? netdev_notify_peers+0xc0/0xc0
      [   40.607762][  T146]  ? __module_text_address+0x13/0x140
      [   40.608440][  T146]  ? notifier_call_chain+0x90/0x160
      [   40.609097][  T146]  ? dev_set_mac_address+0x1f0/0x3f0
      [   40.609758][  T146]  dev_set_mac_address+0x1f0/0x3f0
      [   40.610402][  T146]  ? __local_bh_enable_ip+0xe9/0x1b0
      [   40.611071][  T146]  ? bond_hw_addr_flush+0x77/0x100 [bonding]
      [   40.611823][  T146]  ? netdev_notify_peers+0xc0/0xc0
      [   40.612461][  T146]  ? bond_hw_addr_flush+0x77/0x100 [bonding]
      [   40.613213][  T146]  ? bond_hw_addr_flush+0x77/0x100 [bonding]
      [   40.613963][  T146]  ? __local_bh_enable_ip+0xe9/0x1b0
      [   40.614631][  T146]  ? bond_time_in_interval.isra.31+0x90/0x90 [bonding]
      [   40.615484][  T146]  ? __bond_release_one+0x9f0/0x12c0 [bonding]
      [   40.616230][  T146]  __bond_release_one+0x9f0/0x12c0 [bonding]
      [   40.616949][  T146]  ? bond_enslave+0x47c0/0x47c0 [bonding]
      [   40.617642][  T146]  ? lock_downgrade+0x730/0x730
      [   40.618218][  T146]  ? check_flags.part.42+0x450/0x450
      [   40.618850][  T146]  ? __mutex_unlock_slowpath+0xd0/0x670
      [   40.619519][  T146]  ? trace_hardirqs_on+0x30/0x180
      [   40.620117][  T146]  ? wait_for_completion+0x250/0x250
      [   40.620754][  T146]  bond_netdev_event+0x822/0x970 [bonding]
      [   40.621460][  T146]  ? __module_text_address+0x13/0x140
      [   40.622097][  T146]  notifier_call_chain+0x90/0x160
      [   40.622806][  T146]  rollback_registered_many+0x660/0xcf0
      [   40.623522][  T146]  ? netif_set_real_num_tx_queues+0x780/0x780
      [   40.624290][  T146]  ? notifier_call_chain+0x90/0x160
      [   40.624957][  T146]  ? netdev_upper_dev_unlink+0x114/0x180
      [   40.625686][  T146]  ? __netdev_adjacent_dev_unlink_neighbour+0x30/0x30
      [   40.626421][  T146]  ? mutex_is_locked+0x13/0x50
      [   40.627016][  T146]  ? unregister_netdevice_queue+0xf2/0x240
      [   40.627663][  T146]  unregister_netdevice_many.part.134+0x13/0x1b0
      [   40.628362][  T146]  default_device_exit_batch+0x2d9/0x390
      [   40.628987][  T146]  ? unregister_netdevice_many+0x40/0x40
      [   40.629615][  T146]  ? dev_change_net_namespace+0xcb0/0xcb0
      [   40.630279][  T146]  ? prepare_to_wait_exclusive+0x2e0/0x2e0
      [   40.630943][  T146]  ? ops_exit_list.isra.9+0x97/0x140
      [   40.631554][  T146]  cleanup_net+0x441/0x890
      [ ... ]
      
      Fixes: e289fd28 ("macvlan: fix the problem when mac address changes for passthru mode")
      Reported-by: syzbot+5035b1f9dc7ea4558d5a@syzkaller.appspotmail.com
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9d7ea567
    • Taehee Yoo's avatar
      macsec: avoid to set wrong mtu · 468f8f8e
      Taehee Yoo authored
      [ Upstream commit 7f327080 ]
      
      When a macsec interface is created, the mtu is calculated with the lower
      interface's mtu value.
      If the mtu of lower interface is lower than the length, which is needed
      by macsec interface, macsec's mtu value will be overflowed.
      So, if the lower interface's mtu is too low, macsec interface's mtu
      should be set to 0.
      
      Test commands:
          ip link add dummy0 mtu 10 type dummy
          ip link add macsec0 link dummy0 type macsec
          ip link show macsec0
      
      Before:
          11: macsec0@dummy0: <BROADCAST,MULTICAST,M-DOWN> mtu 4294967274
      After:
          11: macsec0@dummy0: <BROADCAST,MULTICAST,M-DOWN> mtu 0
      
      Fixes: c09440f7 ("macsec: introduce IEEE 802.1AE driver")
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      468f8f8e
    • John Haxby's avatar
      ipv6: fix restrict IPV6_ADDRFORM operation · 387e8797
      John Haxby authored
      [ Upstream commit 82c9ae44 ]
      
      Commit b6f61189 ("ipv6: restrict IPV6_ADDRFORM operation") fixed a
      problem found by syzbot an unfortunate logic error meant that it
      also broke IPV6_ADDRFORM.
      
      Rearrange the checks so that the earlier test is just one of the series
      of checks made before moving the socket from IPv6 to IPv4.
      
      Fixes: b6f61189 ("ipv6: restrict IPV6_ADDRFORM operation")
      Signed-off-by: default avatarJohn Haxby <john.haxby@oracle.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      387e8797
    • Rahul Lakkireddy's avatar
      cxgb4: fix large delays in PTP synchronization · 77dc1af0
      Rahul Lakkireddy authored
      [ Upstream commit bd019427 ]
      
      Fetching PTP sync information from mailbox is slow and can take
      up to 10 milliseconds. Reduce this unnecessary delay by directly
      reading the information from the corresponding registers.
      
      Fixes: 9c33e420 ("cxgb4: Add PTP Hardware Clock (PHC) support")
      Signed-off-by: default avatarManoj Malviya <manojmalviya@chelsio.com>
      Signed-off-by: default avatarRahul Lakkireddy <rahul.lakkireddy@chelsio.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      77dc1af0
    • Vishal Kulkarni's avatar
      cxgb4: fix adapter crash due to wrong MC size · 953236ee
      Vishal Kulkarni authored
      [ Upstream commit ce222748 ]
      
      In the absence of MC1, the size calculation function
      cudbg_mem_region_size() was returing wrong MC size and
      resulted in adapter crash. This patch adds new argument
      to cudbg_mem_region_size() which will have actual size
      and returns error to caller in the absence of MC1.
      
      Fixes: a1c69520 ("cxgb4: collect MC memory dump")
      Signed-off-by: Vishal Kulkarni <vishal@chelsio.com>"
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      953236ee
    • Boris Ostrovsky's avatar
      x86/KVM: Clean up host's steal time structure · c434092e
      Boris Ostrovsky authored
      commit a6bd811f upstream.
      
      Now that we are mapping kvm_steal_time from the guest directly we
      don't need keep a copy of it in kvm_vcpu_arch.st. The same is true
      for the stime field.
      
      This is part of CVE-2019-3016.
      Signed-off-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Reviewed-by: default avatarJoao Martins <joao.m.martins@oracle.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c434092e