Skip to content
  1. Jun 30, 2021
    • Thomas Gleixner's avatar
      x86/fpu: Make init_fpstate correct with optimized XSAVE · 130a1d76
      Thomas Gleixner authored
      commit f9dfb5e3 upstream.
      
      The XSAVE init code initializes all enabled and supported components with
      XRSTOR(S) to init state. Then it XSAVEs the state of the components back
      into init_fpstate which is used in several places to fill in the init state
      of components.
      
      This works correctly with XSAVE, but not with XSAVEOPT and XSAVES because
      those use the init optimization and skip writing state of components which
      are in init state. So init_fpstate.xsave still contains all zeroes after
      this operation.
      
      There are two ways to solve that:
      
         1) Use XSAVE unconditionally, but that requires to reshuffle the buffer when
            XSAVES is enabled because XSAVES uses compacted format.
      
         2) Save the components which are known to have a non-zero init state by other
            means.
      
      Looking deeper, #2 is the right thing to do because all components the
      kernel supports have all-zeroes init state except the legacy features (FP,
      SSE). Those cannot be hard coded because the states are not identical on all
      CPUs, but they can be saved with FXSAVE which avoids all conditionals.
      
      Use FXSAVE to save the legacy FP/SSE components in init_fpstate along with
      a BUILD_BUG_ON() which reminds developers to validate that a newly added
      component has all zeroes init state. As a bonus remove the now unused
      copy_xregs_to_kernel_booting() crutch.
      
      The XSAVE and reshuffle method can still be implemented in the unlikely
      case that components are added which have a non-zero init state and no
      other means to save them. For now, FXSAVE is just simple and good enough.
      
        [ bp: Fix a typo or two in the text. ]
      
      Fixes: 6bad06b7
      
       ("x86, xsave: Use xsaveopt in context-switch path when supported")
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Reviewed-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/20210618143444.587311343@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      130a1d76
    • Thomas Gleixner's avatar
      x86/fpu: Preserve supervisor states in sanitize_restored_user_xstate() · 51d80117
      Thomas Gleixner authored
      commit 9301982c upstream.
      
      sanitize_restored_user_xstate() preserves the supervisor states only
      when the fx_only argument is zero, which allows unprivileged user space
      to put supervisor states back into init state.
      
      Preserve them unconditionally.
      
       [ bp: Fix a typo or two in the text. ]
      
      Fixes: 5d6b6a6f
      
       ("x86/fpu/xstate: Update sanitize_restored_xstate() for supervisor xstates")
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/20210618143444.438635017@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      51d80117
    • Petr Mladek's avatar
      kthread: prevent deadlock when kthread_mod_delayed_work() races with... · 2b35a4ea
      Petr Mladek authored
      kthread: prevent deadlock when kthread_mod_delayed_work() races with kthread_cancel_delayed_work_sync()
      
      commit 5fa54346 upstream.
      
      The system might hang with the following backtrace:
      
      	schedule+0x80/0x100
      	schedule_timeout+0x48/0x138
      	wait_for_common+0xa4/0x134
      	wait_for_completion+0x1c/0x2c
      	kthread_flush_work+0x114/0x1cc
      	kthread_cancel_work_sync.llvm.16514401384283632983+0xe8/0x144
      	kthread_cancel_delayed_work_sync+0x18/0x2c
      	xxxx_pm_notify+0xb0/0xd8
      	blocking_notifier_call_chain_robust+0x80/0x194
      	pm_notifier_call_chain_robust+0x28/0x4c
      	suspend_prepare+0x40/0x260
      	enter_state+0x80/0x3f4
      	pm_suspend+0x60/0xdc
      	state_store+0x108/0x144
      	kobj_attr_store+0x38/0x88
      	sysfs_kf_write+0x64/0xc0
      	kernfs_fop_write_iter+0x108/0x1d0
      	vfs_write+0x2f4/0x368
      	ksys_write+0x7c/0xec
      
      It is caused by the following race between kthread_mod_delayed_work()
      and kthread_cancel_delayed_work_sync():
      
      CPU0				CPU1
      
      Context: Thread A		Context: Thread B
      
      kthread_mod_delayed_work()
        spin_lock()
        __kthread_cancel_work()
           spin_unlock()
           del_timer_sync()
      				kthread_cancel_delayed_work_sync()
      				  spin_lock()
      				  __kthread_cancel_work()
      				    spin_unlock()
      				    del_timer_sync()
      				    spin_lock()
      
      				  work->canceling++
      				  spin_unlock
           spin_lock()
         queue_delayed_work()
           // dwork is put into the worker->delayed_work_list
      
         spin_unlock()
      
      				  kthread_flush_work()
           // flush_work is put at the tail of the dwork
      
      				    wait_for_completion()
      
      Context: IRQ
      
        kthread_delayed_work_timer_fn()
          spin_lock()
          list_del_init(&work->node);
          spin_unlock()
      
      BANG: flush_work is not longer linked and will never get proceed.
      
      The problem is that kthread_mod_delayed_work() checks work->canceling
      flag before canceling the timer.
      
      A simple solution is to (re)check work->canceling after
      __kthread_cancel_work().  But then it is not clear what should be
      returned when __kthread_cancel_work() removed the work from the queue
      (list) and it can't queue it again with the new @delay.
      
      The return value might be used for reference counting.  The caller has
      to know whether a new work has been queued or an existing one was
      replaced.
      
      The proper solution is that kthread_mod_delayed_work() will remove the
      work from the queue (list) _only_ when work->canceling is not set.  The
      flag must be checked after the timer is stopped and the remaining
      operations can be done under worker->lock.
      
      Note that kthread_mod_delayed_work() could remove the timer and then
      bail out.  It is fine.  The other canceling caller needs to cancel the
      timer as well.  The important thing is that the queue (list)
      manipulation is done atomically under worker->lock.
      
      Link: https://lkml.kernel.org/r/20210610133051.15337-3-pmladek@suse.com
      Fixes: 9a6b06c8
      
       ("kthread: allow to modify delayed kthread work")
      Signed-off-by: default avatarPetr Mladek <pmladek@suse.com>
      Reported-by: default avatarMartin Liu <liumartin@google.com>
      Cc: <jenhaochen@google.com>
      Cc: Minchan Kim <minchan@google.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2b35a4ea
    • Petr Mladek's avatar
      kthread_worker: split code for canceling the delayed work timer · bfe28af7
      Petr Mladek authored
      commit 34b3d534
      
       upstream.
      
      Patch series "kthread_worker: Fix race between kthread_mod_delayed_work()
      and kthread_cancel_delayed_work_sync()".
      
      This patchset fixes the race between kthread_mod_delayed_work() and
      kthread_cancel_delayed_work_sync() including proper return value
      handling.
      
      This patch (of 2):
      
      Simple code refactoring as a preparation step for fixing a race between
      kthread_mod_delayed_work() and kthread_cancel_delayed_work_sync().
      
      It does not modify the existing behavior.
      
      Link: https://lkml.kernel.org/r/20210610133051.15337-2-pmladek@suse.com
      Signed-off-by: default avatarPetr Mladek <pmladek@suse.com>
      Cc: <jenhaochen@google.com>
      Cc: Martin Liu <liumartin@google.com>
      Cc: Minchan Kim <minchan@google.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bfe28af7
    • Jeff Layton's avatar
      ceph: must hold snap_rwsem when filling inode for async create · 02c303f3
      Jeff Layton authored
      commit 27171ae6 upstream.
      
      ...and add a lockdep assertion for it to ceph_fill_inode().
      
      Cc: stable@vger.kernel.org # v5.7+
      Fixes: 9a8d03ca
      
       ("ceph: attempt to do async create when possible")
      Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
      Reviewed-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      02c303f3
    • Johan Hovold's avatar
      i2c: robotfuzz-osif: fix control-request directions · de0af265
      Johan Hovold authored
      commit 4ca070ef
      
       upstream.
      
      The direction of the pipe argument must match the request-type direction
      bit or control requests may fail depending on the host-controller-driver
      implementation.
      
      Control transfers without a data stage are treated as OUT requests by
      the USB stack and should be using usb_sndctrlpipe(). Failing to do so
      will now trigger a warning.
      
      Fix the OSIFI2C_SET_BIT_RATE and OSIFI2C_STOP requests which erroneously
      used the osif_usb_read() helper and set the IN direction bit.
      
      Reported-by: default avatar <syzbot+9d7dadd15b8819d73f41@syzkaller.appspotmail.com>
      Fixes: 83e53a8f
      
       ("i2c: Add bus driver for for OSIF USB i2c device.")
      Cc: stable@vger.kernel.org      # 3.14
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      de0af265
    • Nicholas Piggin's avatar
      KVM: do not allow mapping valid but non-reference-counted pages · dd8ed6c9
      Nicholas Piggin authored
      commit f8be156b
      
       upstream.
      
      It's possible to create a region which maps valid but non-refcounted
      pages (e.g., tail pages of non-compound higher order allocations). These
      host pages can then be returned by gfn_to_page, gfn_to_pfn, etc., family
      of APIs, which take a reference to the page, which takes it from 0 to 1.
      When the reference is dropped, this will free the page incorrectly.
      
      Fix this by only taking a reference on valid pages if it was non-zero,
      which indicates it is participating in normal refcounting (and can be
      released with put_page).
      
      This addresses CVE-2021-22543.
      
      Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
      Tested-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dd8ed6c9
    • Heiko Carstens's avatar
      s390/stack: fix possible register corruption with stack switch helper · 5fd0c2cf
      Heiko Carstens authored
      commit 67147e96 upstream.
      
      The CALL_ON_STACK macro is used to call a C function from inline
      assembly, and therefore must consider the C ABI, which says that only
      registers 6-13, and 15 are non-volatile (restored by the called
      function).
      
      The inline assembly incorrectly marks all registers used to pass
      parameters to the called function as read-only input operands, instead
      of operands that are read and written to. This might result in
      register corruption depending on usage, compiler, and compile options.
      
      Fix this by marking all operands used to pass parameters as read/write
      operands. To keep the code simple even register 6, if used, is marked
      as read-write operand.
      
      Fixes: ff340d24
      
       ("s390: add stack switch helper")
      Cc: <stable@kernel.org> # 4.20
      Reviewed-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5fd0c2cf
    • Pavel Skripkin's avatar
      nilfs2: fix memory leak in nilfs_sysfs_delete_device_group · ab5bef97
      Pavel Skripkin authored
      [ Upstream commit 8fd0c1b0 ]
      
      My local syzbot instance hit memory leak in nilfs2.  The problem was in
      missing kobject_put() in nilfs_sysfs_delete_device_group().
      
      kobject_del() does not call kobject_cleanup() for passed kobject and it
      leads to leaking duped kobject name if kobject_put() was not called.
      
      Fail log:
      
        BUG: memory leak
        unreferenced object 0xffff8880596171e0 (size 8):
        comm "syz-executor379", pid 8381, jiffies 4294980258 (age 21.100s)
        hex dump (first 8 bytes):
          6c 6f 6f 70 30 00 00 00                          loop0...
        backtrace:
           kstrdup+0x36/0x70 mm/util.c:60
           kstrdup_const+0x53/0x80 mm/util.c:83
           kvasprintf_const+0x108/0x190 lib/kasprintf.c:48
           kobject_set_name_vargs+0x56/0x150 lib/kobject.c:289
           kobject_add_varg lib/kobject.c:384 [inline]
           kobject_init_and_add+0xc9/0x160 lib/kobject.c:473
           nilfs_sysfs_create_device_group+0x150/0x800 fs/nilfs2/sysfs.c:999
           init_nilfs+0xe26/0x12b0 fs/nilfs2/the_nilfs.c:637
      
      Link: https://lkml.kernel.org/r/20210612140559.20022-1-paskripkin@gmail.com
      Fixes: da7141fb
      
       ("nilfs2: add /sys/fs/nilfs2/<device> group")
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Acked-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Cc: Michael L. Semon <mlsemon35@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ab5bef97
    • Christoph Hellwig's avatar
      scsi: sd: Call sd_revalidate_disk() for ioctl(BLKRRPART) · ace31c91
      Christoph Hellwig authored
      [ Upstream commit d1b7f920 ]
      
      While the disk state has nothing to do with partitions, BLKRRPART is used
      to force a full revalidate after things like a disk format for historical
      reasons. Restore that behavior.
      
      Link: https://lore.kernel.org/r/20210617115504.1732350-1-hch@lst.de
      Fixes: 471bd0af
      
       ("sd: use bdev_check_media_change")
      Reported-by: default avatarXiang Chen <chenxiang66@hisilicon.com>
      Tested-by: default avatarXiang Chen <chenxiang66@hisilicon.com>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ace31c91
    • Gabriel Knezek's avatar
      gpiolib: cdev: zero padding during conversion to gpioline_info_changed · b9e6c20d
      Gabriel Knezek authored
      [ Upstream commit cb8f63b8 ]
      
      When userspace requests a GPIO v1 line info changed event,
      lineinfo_watch_read() populates and returns the gpioline_info_changed
      structure. It contains 5 words of padding at the end which are not
      initialized before being returned to userspace.
      
      Zero the structure in gpio_v2_line_info_change_to_v1() before populating
      its contents.
      
      Fixes: aad95584
      
       ("gpiolib: cdev: support GPIO_V2_GET_LINEINFO_IOCTL and GPIO_V2_GET_LINEINFO_WATCH_IOCTL")
      Signed-off-by: default avatarGabriel Knezek <gabeknez@linux.microsoft.com>
      Reviewed-by: default avatarKent Gibson <warthog618@gmail.com>
      Signed-off-by: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b9e6c20d
    • Heiner Kallweit's avatar
      i2c: i801: Ensure that SMBHSTSTS_INUSE_STS is cleared when leaving i801_access · 0221a5a4
      Heiner Kallweit authored
      [ Upstream commit 065b6211 ]
      
      As explained in [0] currently we may leave SMBHSTSTS_INUSE_STS set,
      thus potentially breaking ACPI/BIOS usage of the SMBUS device.
      
      Seems patch [0] needs a little bit more of review effort, therefore
      I'd suggest to apply a part of it as quick win. Just clearing
      SMBHSTSTS_INUSE_STS when leaving i801_access() should fix the
      referenced issue and leaves more time for discussing a more
      sophisticated locking handling.
      
      [0] https://www.spinics.net/lists/linux-i2c/msg51558.html
      
      Fixes: 01590f36
      
       ("i2c: i801: Instantiate SPD EEPROMs automatically")
      Suggested-by: default avatarHector Martin <marcan@marcan.st>
      Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
      Reviewed-by: default avatarHector Martin <marcan@marcan.st>
      Reviewed-by: default avatarJean Delvare <jdelvare@suse.de>
      Tested-by: default avatarJean Delvare <jdelvare@suse.de>
      Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0221a5a4
    • Fabien Dessenne's avatar
      pinctrl: stm32: fix the reported number of GPIO lines per bank · 018d03fc
      Fabien Dessenne authored
      [ Upstream commit 67e2996f ]
      
      Each GPIO bank supports a variable number of lines which is usually 16, but
      is less in some cases : this is specified by the last argument of the
      "gpio-ranges" bank node property.
      Report to the framework, the actual number of lines, so the libgpiod
      gpioinfo command lists the actually existing GPIO lines.
      
      Fixes: 1dc9d289
      
       ("pinctrl: stm32: add possibility to use gpio-ranges to declare bank range")
      Signed-off-by: default avatarFabien Dessenne <fabien.dessenne@foss.st.com>
      Link: https://lore.kernel.org/r/20210617144629.2557693-1-fabien.dessenne@foss.st.com
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      018d03fc
    • Kan Liang's avatar
      perf/x86: Track pmu in per-CPU cpu_hw_events · df654cd3
      Kan Liang authored
      [ Upstream commit 61e76d53
      
       ]
      
      Some platforms, e.g. Alder Lake, have hybrid architecture. In the same
      package, there may be more than one type of CPU. The PMU capabilities
      are different among different types of CPU. Perf will register a
      dedicated PMU for each type of CPU.
      
      Add a 'pmu' variable in the struct cpu_hw_events to track the dedicated
      PMU of the current CPU.
      
      Current x86_get_pmu() use the global 'pmu', which will be broken on a
      hybrid platform. Modify it to apply the 'pmu' of the specific CPU.
      
      Initialize the per-CPU 'pmu' variable with the global 'pmu'. There is
      nothing changed for the non-hybrid platforms.
      
      The is_x86_event() will be updated in the later patch ("perf/x86:
      Register hybrid PMUs") for hybrid platforms. For the non-hybrid
      platforms, nothing is changed here.
      
      Suggested-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/1618237865-33448-4-git-send-email-kan.liang@linux.intel.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      df654cd3
    • Esben Haabendal's avatar
      net: ll_temac: Avoid ndo_start_xmit returning NETDEV_TX_BUSY · f9e73b29
      Esben Haabendal authored
      [ Upstream commit f6396341
      
       ]
      
      As documented in Documentation/networking/driver.rst, the ndo_start_xmit
      method must not return NETDEV_TX_BUSY under any normal circumstances, and
      as recommended, we simply stop the tx queue in advance, when there is a
      risk that the next xmit would cause a NETDEV_TX_BUSY return.
      
      Signed-off-by: default avatarEsben Haabendal <esben@geanix.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f9e73b29
    • Esben Haabendal's avatar
      net: ll_temac: Add memory-barriers for TX BD access · 1c9cf96f
      Esben Haabendal authored
      [ Upstream commit 28d9fab4
      
       ]
      
      Add a couple of memory-barriers to ensure correct ordering of read/write
      access to TX BDs.
      
      In xmit_done, we should ensure that reading the additional BD fields are
      only done after STS_CTRL_APP0_CMPLT bit is set.
      
      When xmit_done marks the BD as free by setting APP0=0, we need to ensure
      that the other BD fields are reset first, so we avoid racing with the xmit
      path, which writes to the same fields.
      
      Finally, making sure to read APP0 of next BD after the current BD, ensures
      that we see all available buffers.
      
      Signed-off-by: default avatarEsben Haabendal <esben@geanix.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1c9cf96f
    • Mikel Rychliski's avatar
      PCI: Add AMD RS690 quirk to enable 64-bit DMA · bafb6cdd
      Mikel Rychliski authored
      [ Upstream commit cacf994a
      
       ]
      
      Although the AMD RS690 chipset has 64-bit DMA support, BIOS implementations
      sometimes fail to configure the memory limit registers correctly.
      
      The Acer F690GVM mainboard uses this chipset and a Marvell 88E8056 NIC. The
      sky2 driver programs the NIC to use 64-bit DMA, which will not work:
      
        sky2 0000:02:00.0: error interrupt status=0x8
        sky2 0000:02:00.0 eth0: tx timeout
        sky2 0000:02:00.0 eth0: transmit ring 0 .. 22 report=0 done=0
      
      Other drivers required by this mainboard either don't support 64-bit DMA,
      or have it disabled using driver specific quirks. For example, the ahci
      driver has quirks to enable or disable 64-bit DMA depending on the BIOS
      version (see ahci_sb600_enable_64bit() in ahci.c). This ahci quirk matches
      against the SB600 SATA controller, but the real issue is almost certainly
      with the RS690 PCI host that it was commonly attached to.
      
      To avoid this issue in all drivers with 64-bit DMA support, fix the
      configuration of the PCI host. If the kernel is aware of physical memory
      above 4GB, but the BIOS never configured the PCI host with this
      information, update the registers with our values.
      
      [bhelgaas: drop PCI_DEVICE_ID_ATI_RS690 definition]
      Link: https://lore.kernel.org/r/20210611214823.4898-1-mikel@mikelr.com
      Signed-off-by: default avatarMikel Rychliski <mikel@mikelr.com>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bafb6cdd
    • Peter Zijlstra's avatar
      recordmcount: Correct st_shndx handling · d91c50e6
      Peter Zijlstra authored
      [ Upstream commit fb780761
      
       ]
      
      One should only use st_shndx when >SHN_UNDEF and <SHN_LORESERVE. When
      SHN_XINDEX, then use .symtab_shndx. Otherwise use 0.
      
      This handles the case: st_shndx >= SHN_LORESERVE && st_shndx != SHN_XINDEX.
      
      Link: https://lore.kernel.org/lkml/20210607023839.26387-1-mark-pk.tsai@mediatek.com/
      Link: https://lkml.kernel.org/r/20210616154126.2794-1-mark-pk.tsai@mediatek.com
      
      Reported-by: default avatarMark-PK Tsai <mark-pk.tsai@mediatek.com>
      Tested-by: default avatarMark-PK Tsai <mark-pk.tsai@mediatek.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      [handle endianness of sym->st_shndx]
      Signed-off-by: default avatarMark-PK Tsai <mark-pk.tsai@mediatek.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d91c50e6
    • Johannes Berg's avatar
      mac80211: handle various extensible elements correctly · fb71d81c
      Johannes Berg authored
      [ Upstream commit 652e8363
      
       ]
      
      Various elements are parsed with a requirement to have an
      exact size, when really we should only check that they have
      the minimum size that we need. Check only that and therefore
      ignore any additional data that they might carry.
      
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
      Link: https://lore.kernel.org/r/iwlwifi.20210618133832.cd101f8040a4.Iadf0e9b37b100c6c6e79c7b298cc657c2be9151a@changeid
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fb71d81c
    • Johannes Berg's avatar
      mac80211: reset profile_periodicity/ema_ap · 676a7cb1
      Johannes Berg authored
      [ Upstream commit bbc6f03f
      
       ]
      
      Apparently we never clear these values, so they'll remain set
      since the setting of them is conditional. Clear the values in
      the relevant other cases.
      
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
      Link: https://lore.kernel.org/r/iwlwifi.20210618133832.316e32d136a9.I2a12e51814258e1e1b526103894f4b9f19a91c8d@changeid
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      676a7cb1
    • Kees Cook's avatar
      net: qed: Fix memcpy() overflow of qed_dcbx_params() · ca0e1fef
      Kees Cook authored
      [ Upstream commit 1c200f83
      
       ]
      
      The source (&dcbx_info->operational.params) and dest
      (&p_hwfn->p_dcbx_info->set.config.params) are both struct qed_dcbx_params
      (560 bytes), not struct qed_dcbx_admin_params (564 bytes), which is used
      as the memcpy() size.
      
      However it seems that struct qed_dcbx_operational_params
      (dcbx_info->operational)'s layout matches struct qed_dcbx_admin_params
      (p_hwfn->p_dcbx_info->set.config)'s 4 byte difference (3 padding, 1 byte
      for "valid").
      
      On the assumption that the size is wrong (rather than the source structure
      type), adjust the memcpy() size argument to be 4 bytes smaller and add
      a BUILD_BUG_ON() to validate any changes to the structure sizes.
      
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ca0e1fef
    • Fuad Tabba's avatar
      KVM: selftests: Fix kvm_check_cap() assertion · 4658a8d3
      Fuad Tabba authored
      [ Upstream commit d8ac05ea
      
       ]
      
      KVM_CHECK_EXTENSION ioctl can return any negative value on error,
      and not necessarily -1. Change the assertion to reflect that.
      
      Signed-off-by: default avatarFuad Tabba <tabba@google.com>
      Message-Id: <20210615150443.1183365-1-tabba@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4658a8d3
    • Kees Cook's avatar
      r8169: Avoid memcpy() over-reading of ETH_SS_STATS · e83e3c5d
      Kees Cook authored
      [ Upstream commit da5ac772
      
       ]
      
      In preparation for FORTIFY_SOURCE performing compile-time and run-time
      field bounds checking for memcpy(), memmove(), and memset(), avoid
      intentionally reading across neighboring array fields.
      
      The memcpy() is copying the entire structure, not just the first array.
      Adjust the source argument so the compiler can do appropriate bounds
      checking.
      
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e83e3c5d
    • Kees Cook's avatar
      sh_eth: Avoid memcpy() over-reading of ETH_SS_STATS · 992b105a
      Kees Cook authored
      [ Upstream commit 224004fb
      
       ]
      
      In preparation for FORTIFY_SOURCE performing compile-time and run-time
      field bounds checking for memcpy(), memmove(), and memset(), avoid
      intentionally reading across neighboring array fields.
      
      The memcpy() is copying the entire structure, not just the first array.
      Adjust the source argument so the compiler can do appropriate bounds
      checking.
      
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      992b105a
    • Kees Cook's avatar
      r8152: Avoid memcpy() over-reading of ETH_SS_STATS · a10856ea
      Kees Cook authored
      [ Upstream commit 99718abd
      
       ]
      
      In preparation for FORTIFY_SOURCE performing compile-time and run-time
      field bounds checking for memcpy(), memmove(), and memset(), avoid
      intentionally reading across neighboring array fields.
      
      The memcpy() is copying the entire structure, not just the first array.
      Adjust the source argument so the compiler can do appropriate bounds
      checking.
      
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a10856ea
    • Eric Dumazet's avatar
      net/packet: annotate accesses to po->ifindex · 196b22ef
      Eric Dumazet authored
      [ Upstream commit e032f7c9
      
       ]
      
      Like prior patch, we need to annotate lockless accesses to po->ifindex
      For instance, packet_getname() is reading po->ifindex (twice) while
      another thread is able to change po->ifindex.
      
      KCSAN reported:
      
      BUG: KCSAN: data-race in packet_do_bind / packet_getname
      
      write to 0xffff888143ce3cbc of 4 bytes by task 25573 on cpu 1:
       packet_do_bind+0x420/0x7e0 net/packet/af_packet.c:3191
       packet_bind+0xc3/0xd0 net/packet/af_packet.c:3255
       __sys_bind+0x200/0x290 net/socket.c:1637
       __do_sys_bind net/socket.c:1648 [inline]
       __se_sys_bind net/socket.c:1646 [inline]
       __x64_sys_bind+0x3d/0x50 net/socket.c:1646
       do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      read to 0xffff888143ce3cbc of 4 bytes by task 25578 on cpu 0:
       packet_getname+0x5b/0x1a0 net/packet/af_packet.c:3525
       __sys_getsockname+0x10e/0x1a0 net/socket.c:1887
       __do_sys_getsockname net/socket.c:1902 [inline]
       __se_sys_getsockname net/socket.c:1899 [inline]
       __x64_sys_getsockname+0x3e/0x50 net/socket.c:1899
       do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      value changed: 0x00000000 -> 0x00000001
      
      Reported by Kernel Concurrency Sanitizer on:
      CPU: 0 PID: 25578 Comm: syz-executor.5 Not tainted 5.13.0-rc6-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      196b22ef
    • Eric Dumazet's avatar
      net/packet: annotate accesses to po->bind · da8b3aef
      Eric Dumazet authored
      [ Upstream commit c7d2ef5d
      
       ]
      
      tpacket_snd(), packet_snd(), packet_getname() and packet_seq_show()
      can read po->num without holding a lock. This means other threads
      can change po->num at the same time.
      
      KCSAN complained about this known fact [1]
      Add READ_ONCE()/WRITE_ONCE() to address the issue.
      
      [1] BUG: KCSAN: data-race in packet_do_bind / packet_sendmsg
      
      write to 0xffff888131a0dcc0 of 2 bytes by task 24714 on cpu 0:
       packet_do_bind+0x3ab/0x7e0 net/packet/af_packet.c:3181
       packet_bind+0xc3/0xd0 net/packet/af_packet.c:3255
       __sys_bind+0x200/0x290 net/socket.c:1637
       __do_sys_bind net/socket.c:1648 [inline]
       __se_sys_bind net/socket.c:1646 [inline]
       __x64_sys_bind+0x3d/0x50 net/socket.c:1646
       do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      read to 0xffff888131a0dcc0 of 2 bytes by task 24719 on cpu 1:
       packet_snd net/packet/af_packet.c:2899 [inline]
       packet_sendmsg+0x317/0x3570 net/packet/af_packet.c:3040
       sock_sendmsg_nosec net/socket.c:654 [inline]
       sock_sendmsg net/socket.c:674 [inline]
       ____sys_sendmsg+0x360/0x4d0 net/socket.c:2350
       ___sys_sendmsg net/socket.c:2404 [inline]
       __sys_sendmsg+0x1ed/0x270 net/socket.c:2433
       __do_sys_sendmsg net/socket.c:2442 [inline]
       __se_sys_sendmsg net/socket.c:2440 [inline]
       __x64_sys_sendmsg+0x42/0x50 net/socket.c:2440
       do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      value changed: 0x0000 -> 0x1200
      
      Reported by Kernel Concurrency Sanitizer on:
      CPU: 1 PID: 24719 Comm: syz-executor.5 Not tainted 5.13.0-rc4-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      da8b3aef
    • Pavel Skripkin's avatar
      net: caif: fix memory leak in ldisc_open · 18ed1789
      Pavel Skripkin authored
      [ Upstream commit 58af3d3d
      
       ]
      
      Syzbot reported memory leak in tty_init_dev().
      The problem was in unputted tty in ldisc_open()
      
      static int ldisc_open(struct tty_struct *tty)
      {
      ...
      	ser->tty = tty_kref_get(tty);
      ...
      	result = register_netdevice(dev);
      	if (result) {
      		rtnl_unlock();
      		free_netdev(dev);
      		return -ENODEV;
      	}
      ...
      }
      
      Ser pointer is netdev private_data, so after free_netdev()
      this pointer goes away with unputted tty reference. So, fix
      it by adding tty_kref_put() before freeing netdev.
      
      Reported-and-tested-by: default avatar <syzbot+f303e045423e617d2cad@syzkaller.appspotmail.com>
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      18ed1789
    • Khem Raj's avatar
      riscv32: Use medany C model for modules · edcd7594
      Khem Raj authored
      [ Upstream commit 5d2388db
      
       ]
      
      When CONFIG_CMODEL_MEDLOW is used it ends up generating riscv_hi20_rela
      relocations in modules which are not resolved during runtime and
      following errors would be seen
      
      [    4.802714] virtio_input: target 00000000c1539090 can not be addressed by the 32-bit offset from PC = 39148b7b
      [    4.854800] virtio_input: target 00000000c1539090 can not be addressed by the 32-bit offset from PC = 9774456d
      
      Signed-off-by: default avatarKhem Raj <raj.khem@gmail.com>
      Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      edcd7594
    • Praneeth Bajjuri's avatar
      net: phy: dp83867: perform soft reset and retain established link · 47c07f91
      Praneeth Bajjuri authored
      [ Upstream commit da9ef50f
      
       ]
      
      Current logic is performing hard reset and causing the programmed
      registers to be wiped out.
      
      as per datasheet: https://www.ti.com/lit/ds/symlink/dp83867cr.pdf
      8.6.26 Control Register (CTRL)
      
      do SW_RESTART to perform a reset not including the registers,
      If performed when link is already present,
      it will drop the link and trigger re-auto negotiation.
      
      Signed-off-by: default avatarPraneeth Bajjuri <praneeth@ti.com>
      Signed-off-by: default avatarGeet Modi <geet.modi@ti.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      47c07f91
    • Eric Dumazet's avatar
      net/packet: annotate data race in packet_sendmsg() · f57132a8
      Eric Dumazet authored
      [ Upstream commit d1b5bee4 ]
      
      There is a known race in packet_sendmsg(), addressed
      in commit 32d3182c
      
       ("net/packet: fix race in tpacket_snd()")
      
      Now we have data_race(), we can use it to avoid a future KCSAN warning,
      as syzbot loves stressing af_packet sockets :)
      
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f57132a8
    • Eric Dumazet's avatar
      inet: annotate date races around sk->sk_txhash · 9707960e
      Eric Dumazet authored
      [ Upstream commit b71eaed8
      
       ]
      
      UDP sendmsg() path can be lockless, it is possible for another
      thread to re-connect an change sk->sk_txhash under us.
      
      There is no serious impact, but we can use READ_ONCE()/WRITE_ONCE()
      pair to document the race.
      
      BUG: KCSAN: data-race in __ip4_datagram_connect / skb_set_owner_w
      
      write to 0xffff88813397920c of 4 bytes by task 30997 on cpu 1:
       sk_set_txhash include/net/sock.h:1937 [inline]
       __ip4_datagram_connect+0x69e/0x710 net/ipv4/datagram.c:75
       __ip6_datagram_connect+0x551/0x840 net/ipv6/datagram.c:189
       ip6_datagram_connect+0x2a/0x40 net/ipv6/datagram.c:272
       inet_dgram_connect+0xfd/0x180 net/ipv4/af_inet.c:580
       __sys_connect_file net/socket.c:1837 [inline]
       __sys_connect+0x245/0x280 net/socket.c:1854
       __do_sys_connect net/socket.c:1864 [inline]
       __se_sys_connect net/socket.c:1861 [inline]
       __x64_sys_connect+0x3d/0x50 net/socket.c:1861
       do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      read to 0xffff88813397920c of 4 bytes by task 31039 on cpu 0:
       skb_set_hash_from_sk include/net/sock.h:2211 [inline]
       skb_set_owner_w+0x118/0x220 net/core/sock.c:2101
       sock_alloc_send_pskb+0x452/0x4e0 net/core/sock.c:2359
       sock_alloc_send_skb+0x2d/0x40 net/core/sock.c:2373
       __ip6_append_data+0x1743/0x21a0 net/ipv6/ip6_output.c:1621
       ip6_make_skb+0x258/0x420 net/ipv6/ip6_output.c:1983
       udpv6_sendmsg+0x160a/0x16b0 net/ipv6/udp.c:1527
       inet6_sendmsg+0x5f/0x80 net/ipv6/af_inet6.c:642
       sock_sendmsg_nosec net/socket.c:654 [inline]
       sock_sendmsg net/socket.c:674 [inline]
       ____sys_sendmsg+0x360/0x4d0 net/socket.c:2350
       ___sys_sendmsg net/socket.c:2404 [inline]
       __sys_sendmmsg+0x315/0x4b0 net/socket.c:2490
       __do_sys_sendmmsg net/socket.c:2519 [inline]
       __se_sys_sendmmsg net/socket.c:2516 [inline]
       __x64_sys_sendmmsg+0x53/0x60 net/socket.c:2516
       do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      value changed: 0xbca3c43d -> 0xfdb309e0
      
      Reported by Kernel Concurrency Sanitizer on:
      CPU: 0 PID: 31039 Comm: syz-executor.2 Not tainted 5.13.0-rc3-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9707960e
    • Eric Dumazet's avatar
      net: annotate data race in sock_error() · 7293f63b
      Eric Dumazet authored
      [ Upstream commit f13ef100
      
       ]
      
      sock_error() is known to be racy. The code avoids
      an atomic operation is sk_err is zero, and this field
      could be changed under us, this is fine.
      
      Sysbot reported:
      
      BUG: KCSAN: data-race in sock_alloc_send_pskb / unix_release_sock
      
      write to 0xffff888131855630 of 4 bytes by task 9365 on cpu 1:
       unix_release_sock+0x2e9/0x6e0 net/unix/af_unix.c:550
       unix_release+0x2f/0x50 net/unix/af_unix.c:859
       __sock_release net/socket.c:599 [inline]
       sock_close+0x6c/0x150 net/socket.c:1258
       __fput+0x25b/0x4e0 fs/file_table.c:280
       ____fput+0x11/0x20 fs/file_table.c:313
       task_work_run+0xae/0x130 kernel/task_work.c:164
       tracehook_notify_resume include/linux/tracehook.h:189 [inline]
       exit_to_user_mode_loop kernel/entry/common.c:174 [inline]
       exit_to_user_mode_prepare+0x156/0x190 kernel/entry/common.c:208
       __syscall_exit_to_user_mode_work kernel/entry/common.c:290 [inline]
       syscall_exit_to_user_mode+0x20/0x40 kernel/entry/common.c:301
       do_syscall_64+0x56/0x90 arch/x86/entry/common.c:57
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      read to 0xffff888131855630 of 4 bytes by task 9385 on cpu 0:
       sock_error include/net/sock.h:2269 [inline]
       sock_alloc_send_pskb+0xe4/0x4e0 net/core/sock.c:2336
       unix_dgram_sendmsg+0x478/0x1610 net/unix/af_unix.c:1671
       unix_seqpacket_sendmsg+0xc2/0x100 net/unix/af_unix.c:2055
       sock_sendmsg_nosec net/socket.c:654 [inline]
       sock_sendmsg net/socket.c:674 [inline]
       ____sys_sendmsg+0x360/0x4d0 net/socket.c:2350
       __sys_sendmsg_sock+0x25/0x30 net/socket.c:2416
       io_sendmsg fs/io_uring.c:4367 [inline]
       io_issue_sqe+0x231a/0x6750 fs/io_uring.c:6135
       __io_queue_sqe+0xe9/0x360 fs/io_uring.c:6414
       __io_req_task_submit fs/io_uring.c:2039 [inline]
       io_async_task_func+0x312/0x590 fs/io_uring.c:5074
       __tctx_task_work fs/io_uring.c:1910 [inline]
       tctx_task_work+0x1d4/0x3d0 fs/io_uring.c:1924
       task_work_run+0xae/0x130 kernel/task_work.c:164
       tracehook_notify_signal include/linux/tracehook.h:212 [inline]
       handle_signal_work kernel/entry/common.c:145 [inline]
       exit_to_user_mode_loop kernel/entry/common.c:171 [inline]
       exit_to_user_mode_prepare+0xf8/0x190 kernel/entry/common.c:208
       __syscall_exit_to_user_mode_work kernel/entry/common.c:290 [inline]
       syscall_exit_to_user_mode+0x20/0x40 kernel/entry/common.c:301
       do_syscall_64+0x56/0x90 arch/x86/entry/common.c:57
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      value changed: 0x00000000 -> 0x00000068
      
      Reported by Kernel Concurrency Sanitizer on:
      CPU: 0 PID: 9385 Comm: syz-executor.3 Not tainted 5.13.0-rc4-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7293f63b
    • Zheng Yongjun's avatar
      ping: Check return value of function 'ping_queue_rcv_skb' · 61b132f6
      Zheng Yongjun authored
      [ Upstream commit 9d44fa3e
      
       ]
      
      Function 'ping_queue_rcv_skb' not always return success, which will
      also return fail. If not check the wrong return value of it, lead to function
      `ping_rcv` return success.
      
      Signed-off-by: default avatarZheng Yongjun <zhengyongjun3@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      61b132f6
    • Eric Dumazet's avatar
      inet: annotate data race in inet_send_prepare() and inet_dgram_connect() · 08c389de
      Eric Dumazet authored
      [ Upstream commit dcd01eea
      
       ]
      
      Both functions are known to be racy when reading inet_num
      as we do not want to grab locks for the common case the socket
      has been bound already. The race is resolved in inet_autobind()
      by reading again inet_num under the socket lock.
      
      syzbot reported:
      BUG: KCSAN: data-race in inet_send_prepare / udp_lib_get_port
      
      write to 0xffff88812cba150e of 2 bytes by task 24135 on cpu 0:
       udp_lib_get_port+0x4b2/0xe20 net/ipv4/udp.c:308
       udp_v6_get_port+0x5e/0x70 net/ipv6/udp.c:89
       inet_autobind net/ipv4/af_inet.c:183 [inline]
       inet_send_prepare+0xd0/0x210 net/ipv4/af_inet.c:807
       inet6_sendmsg+0x29/0x80 net/ipv6/af_inet6.c:639
       sock_sendmsg_nosec net/socket.c:654 [inline]
       sock_sendmsg net/socket.c:674 [inline]
       ____sys_sendmsg+0x360/0x4d0 net/socket.c:2350
       ___sys_sendmsg net/socket.c:2404 [inline]
       __sys_sendmmsg+0x315/0x4b0 net/socket.c:2490
       __do_sys_sendmmsg net/socket.c:2519 [inline]
       __se_sys_sendmmsg net/socket.c:2516 [inline]
       __x64_sys_sendmmsg+0x53/0x60 net/socket.c:2516
       do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      read to 0xffff88812cba150e of 2 bytes by task 24132 on cpu 1:
       inet_send_prepare+0x21/0x210 net/ipv4/af_inet.c:806
       inet6_sendmsg+0x29/0x80 net/ipv6/af_inet6.c:639
       sock_sendmsg_nosec net/socket.c:654 [inline]
       sock_sendmsg net/socket.c:674 [inline]
       ____sys_sendmsg+0x360/0x4d0 net/socket.c:2350
       ___sys_sendmsg net/socket.c:2404 [inline]
       __sys_sendmmsg+0x315/0x4b0 net/socket.c:2490
       __do_sys_sendmmsg net/socket.c:2519 [inline]
       __se_sys_sendmmsg net/socket.c:2516 [inline]
       __x64_sys_sendmmsg+0x53/0x60 net/socket.c:2516
       do_syscall_64+0x4a/0x90 arch/x86/entry/common.c:47
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      value changed: 0x0000 -> 0x9db4
      
      Reported by Kernel Concurrency Sanitizer on:
      CPU: 1 PID: 24132 Comm: syz-executor.2 Not tainted 5.13.0-rc4-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      08c389de
    • Austin Kim's avatar
      net: ethtool: clear heap allocations for ethtool function · c2311fd6
      Austin Kim authored
      [ Upstream commit 80ec82e3
      
       ]
      
      Several ethtool functions leave heap uncleared (potentially) by
      drivers. This will leave the unused portion of heap unchanged and
      might copy the full contents back to userspace.
      
      Signed-off-by: default avatarAustin Kim <austindh.kim@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c2311fd6
    • Johannes Berg's avatar
      mac80211: drop multicast fragments · c2813d19
      Johannes Berg authored
      [ Upstream commit a9799541
      
       ]
      
      These are not permitted by the spec, just drop them.
      
      Link: https://lore.kernel.org/r/20210609161305.23def022b750.Ibd6dd3cdce573dae262fcdc47f8ac52b883a9c50@changeid
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c2813d19
    • Zheng Yongjun's avatar
      net: ipv4: Remove unneed BUG() function · fedc4d4f
      Zheng Yongjun authored
      [ Upstream commit 5ac6b198
      
       ]
      
      When 'nla_parse_nested_deprecated' failed, it's no need to
      BUG() here, return -EINVAL is ok.
      
      Signed-off-by: default avatarZheng Yongjun <zhengyongjun3@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fedc4d4f
    • Guillaume Ranquet's avatar
      dmaengine: mediatek: use GFP_NOWAIT instead of GFP_ATOMIC in prep_dma · 93c2aac1
      Guillaume Ranquet authored
      [ Upstream commit 90415753
      
       ]
      
      As recommended by the doc in:
      Documentation/drivers-api/dmaengine/provider.rst
      
      Use GFP_NOWAIT to not deplete the emergency pool.
      
      Signed-off-by: default avatarGuillaume Ranquet <granquet@baylibre.com>
      
      Link: https://lore.kernel.org/r/20210513192642.29446-4-granquet@baylibre.com
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      93c2aac1
    • Guillaume Ranquet's avatar
      dmaengine: mediatek: do not issue a new desc if one is still current · 0f48f927
      Guillaume Ranquet authored
      [ Upstream commit 2537b40b
      
       ]
      
      Avoid issuing a new desc if one is still being processed as this can
      lead to some desc never being marked as completed.
      
      Signed-off-by: default avatarGuillaume Ranquet <granquet@baylibre.com>
      
      Link: https://lore.kernel.org/r/20210513192642.29446-3-granquet@baylibre.com
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0f48f927