Skip to content
  1. Aug 08, 2021
    • Pravin B Shelar's avatar
      net: Fix zero-copy head len calculation. · e8b287e7
      Pravin B Shelar authored
      [ Upstream commit a17ad096
      
       ]
      
      In some cases skb head could be locked and entire header
      data is pulled from skb. When skb_zerocopy() called in such cases,
      following BUG is triggered. This patch fixes it by copying entire
      skb in such cases.
      This could be optimized incase this is performance bottleneck.
      
      ---8<---
      kernel BUG at net/core/skbuff.c:2961!
      invalid opcode: 0000 [#1] SMP PTI
      CPU: 2 PID: 0 Comm: swapper/2 Tainted: G           OE     5.4.0-77-generic #86-Ubuntu
      Hardware name: OpenStack Foundation OpenStack Nova, BIOS 1.13.0-1ubuntu1.1 04/01/2014
      RIP: 0010:skb_zerocopy+0x37a/0x3a0
      RSP: 0018:ffffbcc70013ca38 EFLAGS: 00010246
      Call Trace:
       <IRQ>
       queue_userspace_packet+0x2af/0x5e0 [openvswitch]
       ovs_dp_upcall+0x3d/0x60 [openvswitch]
       ovs_dp_process_packet+0x125/0x150 [openvswitch]
       ovs_vport_receive+0x77/0xd0 [openvswitch]
       netdev_port_receive+0x87/0x130 [openvswitch]
       netdev_frame_hook+0x4b/0x60 [openvswitch]
       __netif_receive_skb_core+0x2b4/0xc90
       __netif_receive_skb_one_core+0x3f/0xa0
       __netif_receive_skb+0x18/0x60
       process_backlog+0xa9/0x160
       net_rx_action+0x142/0x390
       __do_softirq+0xe1/0x2d6
       irq_exit+0xae/0xb0
       do_IRQ+0x5a/0xf0
       common_interrupt+0xf/0xf
      
      Code that triggered BUG:
      int
      skb_zerocopy(struct sk_buff *to, struct sk_buff *from, int len, int hlen)
      {
              int i, j = 0;
              int plen = 0; /* length of skb->head fragment */
              int ret;
              struct page *page;
              unsigned int offset;
      
              BUG_ON(!from->head_frag && !hlen);
      
      Signed-off-by: default avatarPravin B Shelar <pshelar@ovn.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e8b287e7
    • Oder Chiou's avatar
      ASoC: rt5682: Fix the issue of garbled recording after powerd_dbus_suspend · c6bdf7d9
      Oder Chiou authored
      [ Upstream commit 6a503e1c
      
       ]
      
      While using the DMIC recording, the garbled data will be captured by the
      DMIC. It is caused by the critical power of PLL closed in the jack detect
      function.
      
      Signed-off-by: default avatarOder Chiou <oder_chiou@realtek.com>
      Link: https://lore.kernel.org/r/20210716085853.20170-1-oder_chiou@realtek.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c6bdf7d9
    • Jia He's avatar
      qed: fix possible unpaired spin_{un}lock_bh in _qed_mcp_cmd_and_union() · 74b53ee4
      Jia He authored
      [ Upstream commit 6206b798
      
       ]
      
      Liajian reported a bug_on hit on a ThunderX2 arm64 server with FastLinQ
      QL41000 ethernet controller:
       BUG: scheduling while atomic: kworker/0:4/531/0x00000200
        [qed_probe:488()]hw prepare failed
        kernel BUG at mm/vmalloc.c:2355!
        Internal error: Oops - BUG: 0 [#1] SMP
        CPU: 0 PID: 531 Comm: kworker/0:4 Tainted: G W 5.4.0-77-generic #86-Ubuntu
        pstate: 00400009 (nzcv daif +PAN -UAO)
       Call trace:
        vunmap+0x4c/0x50
        iounmap+0x48/0x58
        qed_free_pci+0x60/0x80 [qed]
        qed_probe+0x35c/0x688 [qed]
        __qede_probe+0x88/0x5c8 [qede]
        qede_probe+0x60/0xe0 [qede]
        local_pci_probe+0x48/0xa0
        work_for_cpu_fn+0x24/0x38
        process_one_work+0x1d0/0x468
        worker_thread+0x238/0x4e0
        kthread+0xf0/0x118
        ret_from_fork+0x10/0x18
      
      In this case, qed_hw_prepare() returns error due to hw/fw error, but in
      theory work queue should be in process context instead of interrupt.
      
      The root cause might be the unpaired spin_{un}lock_bh() in
      _qed_mcp_cmd_and_union(), which causes botton half is disabled incorrectly.
      
      Reported-by: default avatarLijian Zhang <Lijian.Zhang@arm.com>
      Signed-off-by: default avatarJia He <justin.he@arm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      74b53ee4
    • Takashi Iwai's avatar
      r8152: Fix potential PM refcount imbalance · f6a2ff04
      Takashi Iwai authored
      [ Upstream commit 9c23aa51
      
       ]
      
      rtl8152_close() takes the refcount via usb_autopm_get_interface() but
      it doesn't release when RTL8152_UNPLUG test hits.  This may lead to
      the imbalance of PM refcount.  This patch addresses it.
      
      Link: https://bugzilla.suse.com/show_bug.cgi?id=1186194
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f6a2ff04
    • Kyle Russell's avatar
      ASoC: tlv320aic31xx: fix reversed bclk/wclk master bits · c98a7916
      Kyle Russell authored
      [ Upstream commit 9cf76a72 ]
      
      These are backwards from Table 7-71 of the TLV320AIC3100 spec [1].
      
      This was broken in 12eb4d66
      
       when BCLK_MASTER and WCLK_MASTER
      were converted from 0x08 and 0x04 to BIT(2) and BIT(3), respectively.
      
      -#define AIC31XX_BCLK_MASTER		0x08
      -#define AIC31XX_WCLK_MASTER		0x04
      +#define AIC31XX_BCLK_MASTER		BIT(2)
      +#define AIC31XX_WCLK_MASTER		BIT(3)
      
      Probably just a typo since the defines were not listed in bit order.
      
      [1] https://www.ti.com/lit/gpn/tlv320aic3100
      
      Signed-off-by: default avatarKyle Russell <bkylerussell@gmail.com>
      Link: https://lore.kernel.org/r/20210622010941.241386-1-bkylerussell@gmail.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c98a7916
    • Alain Volmat's avatar
      spi: stm32h7: fix full duplex irq handler handling · 03258515
      Alain Volmat authored
      [ Upstream commit e4a5c198
      
       ]
      
      In case of Full-Duplex mode, DXP flag is set when RXP and TXP flags are
      set. But to avoid 2 different handlings, just add TXP and RXP flag in
      the mask instead of DXP, and then keep the initial handling of TXP and
      RXP events.
      Also rephrase comment about EOTIE which is one of the interrupt enable
      bits. It is not triggered by any event.
      
      Signed-off-by: default avatarAmelie Delaunay <amelie.delaunay@foss.st.com>
      Signed-off-by: default avatarAlain Volmat <alain.volmat@foss.st.com>
      Reviewed-by: default avatarAmelie Delaunay <amelie.delaunay@foss.st.com>
      Link: https://lore.kernel.org/r/1625042723-661-3-git-send-email-alain.volmat@foss.st.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      03258515
    • Axel Lin's avatar
      regulator: rt5033: Fix n_voltages settings for BUCK and LDO · cfb8173a
      Axel Lin authored
      [ Upstream commit 6549c46a
      
       ]
      
      For linear regulators, the n_voltages should be (max - min) / step + 1.
      
      Buck voltage from 1v to 3V, per step 100mV, and vout mask is 0x1f.
      If value is from 20 to 31, the voltage will all be fixed to 3V.
      And LDO also, just vout range is different from 1.2v to 3v, step is the
      same. If value is from 18 to 31, the voltage will also be fixed to 3v.
      
      Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
      Reviewed-by: default avatarChiYuan Huang <cy_huang@richtek.com>
      Link: https://lore.kernel.org/r/20210627080418.1718127-1-axel.lin@ingics.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cfb8173a
    • ChiYuan Huang's avatar
      regulator: rtmv20: Fix wrong mask for strobe-polarity-high · 81dc9a48
      ChiYuan Huang authored
      [ Upstream commit 2b6a761b
      
       ]
      
      Fix wrong mask for strobe-polarity-high.
      
      Signed-off-by: default avatarChiYuan Huang <cy_huang@richtek.com>
      In-reply-to: <CAFRkauB=0KwrJW19nJTTagdHhBR=V2R8YFWG3R3oVXt=rBRsqw@mail.gmail.com>
      Reviewed-by: default avatarAxel Lin <axel.lin@ingics.com>
      Link: https://lore.kernel.org/r/1624723112-26653-1-git-send-email-u0084500@gmail.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      81dc9a48
    • Filipe Manana's avatar
      btrfs: fix lost inode on log replay after mix of fsync, rename and inode eviction · 9e55b927
      Filipe Manana authored
      [ Upstream commit ecc64fab
      
       ]
      
      When checking if we need to log the new name of a renamed inode, we are
      checking if the inode and its parent inode have been logged before, and if
      not we don't log the new name. The check however is buggy, as it directly
      compares the logged_trans field of the inodes versus the ID of the current
      transaction. The problem is that logged_trans is a transient field, only
      stored in memory and never persisted in the inode item, so if an inode
      was logged before, evicted and reloaded, its logged_trans field is set to
      a value of 0, meaning the check will return false and the new name of the
      renamed inode is not logged. If the old parent directory was previously
      fsynced and we deleted the logged directory entries corresponding to the
      old name, we end up with a log that when replayed will delete the renamed
      inode.
      
      The following example triggers the problem:
      
        $ mkfs.btrfs -f /dev/sdc
        $ mount /dev/sdc /mnt
      
        $ mkdir /mnt/A
        $ mkdir /mnt/B
        $ echo -n "hello world" > /mnt/A/foo
      
        $ sync
      
        # Add some new file to A and fsync directory A.
        $ touch /mnt/A/bar
        $ xfs_io -c "fsync" /mnt/A
      
        # Now trigger inode eviction. We are only interested in triggering
        # eviction for the inode of directory A.
        $ echo 2 > /proc/sys/vm/drop_caches
      
        # Move foo from directory A to directory B.
        # This deletes the directory entries for foo in A from the log, and
        # does not add the new name for foo in directory B to the log, because
        # logged_trans of A is 0, which is less than the current transaction ID.
        $ mv /mnt/A/foo /mnt/B/foo
      
        # Now make an fsync to anything except A, B or any file inside them,
        # like for example create a file at the root directory and fsync this
        # new file. This syncs the log that contains all the changes done by
        # previous rename operation.
        $ touch /mnt/baz
        $ xfs_io -c "fsync" /mnt/baz
      
        <power fail>
      
        # Mount the filesystem and replay the log.
        $ mount /dev/sdc /mnt
      
        # Check the filesystem content.
        $ ls -1R /mnt
        /mnt/:
        A
        B
        baz
      
        /mnt/A:
        bar
      
        /mnt/B:
        $
      
        # File foo is gone, it's neither in A/ nor in B/.
      
      Fix this by using the inode_logged() helper at btrfs_log_new_name(), which
      safely checks if an inode was logged before in the current transaction.
      
      A test case for fstests will follow soon.
      
      CC: stable@vger.kernel.org # 4.14+
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9e55b927
    • Filipe Manana's avatar
      btrfs: fix race causing unnecessary inode logging during link and rename · e2419c57
      Filipe Manana authored
      [ Upstream commit de53d892
      
       ]
      
      When we are doing a rename or a link operation for an inode that was logged
      in the previous transaction and that transaction is still committing, we
      have a time window where we incorrectly consider that the inode was logged
      previously in the current transaction and therefore decide to log it to
      update it in the log. The following steps give an example on how this
      happens during a link operation:
      
      1) Inode X is logged in transaction 1000, so its logged_trans field is set
         to 1000;
      
      2) Task A starts to commit transaction 1000;
      
      3) The state of transaction 1000 is changed to TRANS_STATE_UNBLOCKED;
      
      4) Task B starts a link operation for inode X, and as a consequence it
         starts transaction 1001;
      
      5) Task A is still committing transaction 1000, therefore the value stored
         at fs_info->last_trans_committed is still 999;
      
      6) Task B calls btrfs_log_new_name(), it reads a value of 999 from
         fs_info->last_trans_committed and because the logged_trans field of
         inode X has a value of 1000, the function does not return immediately,
         instead it proceeds to logging the inode, which should not happen
         because the inode was logged in the previous transaction (1000) and
         not in the current one (1001).
      
      This is not a functional problem, just wasted time and space logging an
      inode that does not need to be logged, contributing to higher latency
      for link and rename operations.
      
      So fix this by comparing the inodes' logged_trans field with the
      generation of the current transaction instead of comparing with the value
      stored in fs_info->last_trans_committed.
      
      This case is often hit when running dbench for a long enough duration, as
      it does lots of rename operations.
      
      This patch belongs to a patch set that is comprised of the following
      patches:
      
        btrfs: fix race causing unnecessary inode logging during link and rename
        btrfs: fix race that results in logging old extents during a fast fsync
        btrfs: fix race that causes unnecessary logging of ancestor inodes
        btrfs: fix race that makes inode logging fallback to transaction commit
        btrfs: fix race leading to unnecessary transaction commit when logging inode
        btrfs: do not block inode logging for so long during transaction commit
      
      Performance results are mentioned in the change log of the last patch.
      
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e2419c57
    • Faith Ekstrand's avatar
      Revert "drm/i915: Propagate errors on awaiting already signaled fences" · 118b070b
      Faith Ekstrand authored
      commit 3761baae upstream.
      
      This reverts commit 9e31c1fe
      
      .  Ever
      since that commit, we've been having issues where a hang in one client
      can propagate to another.  In particular, a hang in an app can propagate
      to the X server which causes the whole desktop to lock up.
      
      Error propagation along fences sound like a good idea, but as your bug
      shows, surprising consequences, since propagating errors across security
      boundaries is not a good thing.
      
      What we do have is track the hangs on the ctx, and report information to
      userspace using RESET_STATS. That's how arb_robustness works. Also, if my
      understanding is still correct, the EIO from execbuf is when your context
      is banned (because not recoverable or too many hangs). And in all these
      cases it's up to userspace to figure out what is all impacted and should
      be reported to the application, that's not on the kernel to guess and
      automatically propagate.
      
      What's more, we're also building more features on top of ctx error
      reporting with RESET_STATS ioctl: Encrypted buffers use the same, and the
      userspace fence wait also relies on that mechanism. So it is the path
      going forward for reporting gpu hangs and resets to userspace.
      
      So all together that's why I think we should just bury this idea again as
      not quite the direction we want to go to, hence why I think the revert is
      the right option here.
      
      For backporters: Please note that you _must_ have a backport of
      https://lore.kernel.org/dri-devel/20210602164149.391653-2-jason@jlekstrand.net/
      for otherwise backporting just this patch opens up a security bug.
      
      v2: Augment commit message. Also restore Jason's sob that I
      accidentally lost.
      
      v3: Add a note for backporters
      
      Signed-off-by: default avatarJason Ekstrand <jason@jlekstrand.net>
      Reported-by: default avatarMarcin Slusarz <marcin.slusarz@intel.com>
      Cc: <stable@vger.kernel.org> # v5.6+
      Cc: Jason Ekstrand <jason.ekstrand@intel.com>
      Cc: Marcin Slusarz <marcin.slusarz@intel.com>
      Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/3080
      Fixes: 9e31c1fe
      
       ("drm/i915: Propagate errors on awaiting already signaled fences")
      Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Reviewed-by: default avatarJon Bloomfield <jon.bloomfield@intel.com>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/20210714193419.1459723-3-jason@jlekstrand.net
      (cherry picked from commit 93a2711c
      
      )
      Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      118b070b
    • Faith Ekstrand's avatar
      drm/i915: Revert "drm/i915/gem: Asynchronous cmdparser" · 6976f3cf
      Faith Ekstrand authored
      commit c9d9fdbc upstream.
      
      This reverts 686c7c35 ("drm/i915/gem: Asynchronous cmdparser").  The
      justification for this commit in the git history was a vague comment
      about getting it out from under the struct_mutex.  While this may
      improve perf for some workloads on Gen7 platforms where we rely on the
      command parser for features such as indirect rendering, no numbers were
      provided to prove such an improvement.  It claims to closed two
      gitlab/bugzilla issues but with no explanation whatsoever as to why or
      what bug it's fixing.
      
      Meanwhile, by moving command parsing off to an async callback, it leaves
      us with a problem of what to do on error.  When things were synchronous,
      EXECBUFFER2 would fail with an error code if parsing failed.  When
      moving it to async, we needed another way to handle that error and the
      solution employed was to set an error on the dma_fence and then trust
      that said error gets propagated to the client eventually.  Moving back
      to synchronous will help us untangle the fence error propagation mess.
      
      This also reverts most of 0edbb9ba
      
       ("drm/i915: Move cmd parser
      pinning to execbuffer") which is a refactor of some of our allocation
      paths for asynchronous parsing.  Now that everything is synchronous, we
      don't need it.
      
      v2 (Daniel Vetter):
       - Add stabel Cc and Fixes tag
      
      Signed-off-by: default avatarJason Ekstrand <jason@jlekstrand.net>
      Cc: <stable@vger.kernel.org> # v5.6+
      Fixes: 9e31c1fe
      
       ("drm/i915: Propagate errors on awaiting already signaled fences")
      Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Reviewed-by: default avatarJon Bloomfield <jon.bloomfield@intel.com>
      Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/20210714193419.1459723-2-jason@jlekstrand.net
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6976f3cf
  2. Aug 04, 2021
    • Greg Kroah-Hartman's avatar
      Linux 5.10.56 · 9746c253
      Greg Kroah-Hartman authored
      
      
      Link: https://lore.kernel.org/r/20210802134339.023067817@linuxfoundation.org
      Tested-by: default avatarFox Chen <foxhlchen@gmail.com>
      Tested-by: default avatarPavel Machek (CIP) <pavel@denx.de>
      Tested-by: default avatarLinux Kernel Functional Testing <lkft@linaro.org>
      Tested-by: default avatarSudip Mukherjee <sudip.mukherjee@codethink.co.uk>
      Tested-by: default avatarRudi Heitbaum <rudi@heitbaum.com>
      Tested-by: default avatarJon Hunter <jonathanh@nvidia.com>
      Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Tested-by: default avatarHulk Robot <hulkrobot@huawei.com>
      Tested-by: default avatarSalvatore Bonaccorso <carnil@debian.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      v5.10.56
      9746c253
    • Oleksij Rempel's avatar
      can: j1939: j1939_session_deactivate(): clarify lifetime of session object · 55dd22c5
      Oleksij Rempel authored
      commit 0c71437d upstream.
      
      The j1939_session_deactivate() is decrementing the session ref-count and
      potentially can free() the session. This would cause use-after-free
      situation.
      
      However, the code calling j1939_session_deactivate() does always hold
      another reference to the session, so that it would not be free()ed in
      this code path.
      
      This patch adds a comment to make this clear and a WARN_ON, to ensure
      that future changes will not violate this requirement. Further this
      patch avoids dereferencing the session pointer as a precaution to avoid
      use-after-free if the session is actually free()ed.
      
      Fixes: 9d71dd0c
      
       ("can: add support of SAE J1939 protocol")
      Link: https://lore.kernel.org/r/20210714111602.24021-1-o.rempel@pengutronix.de
      Reported-by: default avatarXiaochen Zou <xzou017@ucr.edu>
      Signed-off-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      55dd22c5
    • Lukasz Cieplicki's avatar
      i40e: Add additional info to PHY type error · 75ebe1d3
      Lukasz Cieplicki authored
      commit dc614c46 upstream.
      
      In case of PHY type error occurs, the message was too generic.
      Add additional info to PHY type error indicating that it can be
      wrong cable connected.
      
      Fixes: 124ed15b
      
       ("i40e: Add dual speed module support")
      Signed-off-by: default avatarLukasz Cieplicki <lukaszx.cieplicki@intel.com>
      Signed-off-by: default avatarMichal Maloszewski <michal.maloszewski@intel.com>
      Tested-by: default avatarTony Brelinski <tonyx.brelinski@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      75ebe1d3
    • Arnaldo Carvalho de Melo's avatar
      Revert "perf map: Fix dso->nsinfo refcounting" · 2ca5ec18
      Arnaldo Carvalho de Melo authored
      commit 9bac1bd6 upstream.
      
      This makes 'perf top' abort in some cases, and the right fix will
      involve surgery that is too much to do at this stage, so revert for now
      and fix it in the next merge window.
      
      This reverts commit 2d6b74ba
      
      .
      
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Krister Johansen <kjlx@templeofstupid.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2ca5ec18
    • Srikar Dronamraju's avatar
      powerpc/pseries: Fix regression while building external modules · c14cee5b
      Srikar Dronamraju authored
      commit 333cf507 upstream.
      
      With commit c9f34013 ("powerpc: Always enable queued spinlocks for
      64s, disable for others") CONFIG_PPC_QUEUED_SPINLOCKS is always
      enabled on ppc64le, external modules that use spinlock APIs are
      failing.
      
        ERROR: modpost: GPL-incompatible module XXX.ko uses GPL-only symbol 'shared_processor'
      
      Before the above commit, modules were able to build without any
      issues. Also this problem is not seen on other architectures. This
      problem can be workaround if CONFIG_UNINLINE_SPIN_UNLOCK is enabled in
      the config. However CONFIG_UNINLINE_SPIN_UNLOCK is not enabled by
      default and only enabled in certain conditions like
      CONFIG_DEBUG_SPINLOCKS is set in the kernel config.
      
        #include <linux/module.h>
        spinlock_t spLock;
      
        static int __init spinlock_test_init(void)
        {
                spin_lock_init(&spLock);
                spin_lock(&spLock);
                spin_unlock(&spLock);
                return 0;
        }
      
        static void __exit spinlock_test_exit(void)
        {
        	printk("spinlock_test unloaded\n");
        }
        module_init(spinlock_test_init);
        module_exit(spinlock_test_exit);
      
        MODULE_DESCRIPTION ("spinlock_test");
        MODULE_LICENSE ("non-GPL");
        MODULE_AUTHOR ("Srikar Dronamraju");
      
      Given that spin locks are one of the basic facilities for module code,
      this effectively makes it impossible to build/load almost any non GPL
      modules on ppc64le.
      
      This was first reported at https://github.com/openzfs/zfs/issues/11172
      
      Currently shared_processor is exported as GPL only symbol.
      Fix this for parity with other architectures by exposing
      shared_processor to non-GPL modules too.
      
      Fixes: 14c73bd3
      
       ("powerpc/vcpu: Assume dedicated processors as non-preempt")
      Cc: stable@vger.kernel.org # v5.5+
      Reported-by: default avatar <marc.c.dionne@gmail.com>
      Signed-off-by: default avatarSrikar Dronamraju <srikar@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20210729060449.292780-1-srikar@linux.vnet.ibm.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c14cee5b
    • Steve French's avatar
      SMB3: fix readpage for large swap cache · bfc8e67c
      Steve French authored
      commit f2a26a3c
      
       upstream.
      
      readpage was calculating the offset of the page incorrectly
      for the case of large swapcaches.
      
          loff_t offset = (loff_t)page->index << PAGE_SHIFT;
      
      As pointed out by Matthew Wilcox, this needs to use
      page_file_offset() to calculate the offset instead.
      Pages coming from the swap cache have page->index set
      to their index within the swapcache, not within the backing
      file.  For a sufficiently large swapcache, we could have
      overlapping values of page->index within the same backing file.
      
      Suggested by: Matthew Wilcox (Oracle) <willy@infradead.org>
      Cc: <stable@vger.kernel.org> # v5.7+
      Reviewed-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bfc8e67c
    • Daniel Borkmann's avatar
      bpf: Fix pointer arithmetic mask tightening under state pruning · be561c01
      Daniel Borkmann authored
      commit e042aa53 upstream.
      
      In 7fedb63a ("bpf: Tighten speculative pointer arithmetic mask") we
      narrowed the offset mask for unprivileged pointer arithmetic in order to
      mitigate a corner case where in the speculative domain it is possible to
      advance, for example, the map value pointer by up to value_size-1 out-of-
      bounds in order to leak kernel memory via side-channel to user space.
      
      The verifier's state pruning for scalars leaves one corner case open
      where in the first verification path R_x holds an unknown scalar with an
      aux->alu_limit of e.g. 7, and in a second verification path that same
      register R_x, here denoted as R_x', holds an unknown scalar which has
      tighter bounds and would thus satisfy range_within(R_x, R_x') as well as
      tnum_in(R_x, R_x') for state pruning, yielding an aux->alu_limit of 3:
      Given the second path fits the register constraints for pruning, the final
      generated mask from aux->alu_limit will remain at 7. While technically
      not wrong for the non-speculative domain, it would however be possible
      to craft similar cases where the mask would be too wide as in 7fedb63a
      
      .
      
      One way to fix it is to detect the presence of unknown scalar map pointer
      arithmetic and force a deeper search on unknown scalars to ensure that
      we do not run into a masking mismatch.
      
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      be561c01
    • Lorenz Bauer's avatar
      bpf: verifier: Allocate idmap scratch in verifier env · ffb9d5c4
      Lorenz Bauer authored
      commit c9e73e3d
      
       upstream.
      
      func_states_equal makes a very short lived allocation for idmap,
      probably because it's too large to fit on the stack. However the
      function is called quite often, leading to a lot of alloc / free
      churn. Replace the temporary allocation with dedicated scratch
      space in struct bpf_verifier_env.
      
      Signed-off-by: default avatarLorenz Bauer <lmb@cloudflare.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarEdward Cree <ecree.xilinx@gmail.com>
      Link: https://lore.kernel.org/bpf/20210429134656.122225-4-lmb@cloudflare.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ffb9d5c4
    • Daniel Borkmann's avatar
      bpf: Remove superfluous aux sanitation on subprog rejection · a11ca29c
      Daniel Borkmann authored
      commit 59089a18 upstream.
      
      Follow-up to fe9a5ca7
      
       ("bpf: Do not mark insn as seen under speculative
      path verification"). The sanitize_insn_aux_data() helper does not serve a
      particular purpose in today's code. The original intention for the helper
      was that if function-by-function verification fails, a given program would
      be cleared from temporary insn_aux_data[], and then its verification would
      be re-attempted in the context of the main program a second time.
      
      However, a failure in do_check_subprogs() will skip do_check_main() and
      propagate the error to the user instead, thus such situation can never occur.
      Given its interaction is not compatible to the Spectre v1 mitigation (due to
      comparing aux->seen with env->pass_cnt), just remove sanitize_insn_aux_data()
      to avoid future bugs in this area.
      
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a11ca29c
    • Daniel Borkmann's avatar
      bpf: Fix leakage due to insufficient speculative store bypass mitigation · 0e928065
      Daniel Borkmann authored
      [ Upstream commit 2039f26f ]
      
      Spectre v4 gadgets make use of memory disambiguation, which is a set of
      techniques that execute memory access instructions, that is, loads and
      stores, out of program order; Intel's optimization manual, section 2.4.4.5:
      
        A load instruction micro-op may depend on a preceding store. Many
        microarchitectures block loads until all preceding store addresses are
        known. The memory disambiguator predicts which loads will not depend on
        any previous stores. When the disambiguator predicts that a load does
        not have such a dependency, the load takes its data from the L1 data
        cache. Eventually, the prediction is verified. If an actual conflict is
        detected, the load and all succeeding instructions are re-executed.
      
      af86ca4e ("bpf: Prevent memory disambiguation attack") tried to mitigate
      this attack by sanitizing the memory locations through preemptive "fast"
      (low latency) stores of zero prior to the actual "slow" (high latency) store
      of a pointer value such that upon dependency misprediction the CPU then
      speculatively executes the load of the pointer value and retrieves the zero
      value instead of the attacker controlled scalar value previously stored at
      that location, meaning, subsequent access in the speculative domain is then
      redirected to the "zero page".
      
      The sanitized preemptive store of zero prior to the actual "slow" store is
      done through a simple ST instruction based on r10 (frame pointer) with
      relative offset to the stack location that the verifier has been tracking
      on the original used register for STX, which does not have to be r10. Thus,
      there are no memory dependencies for this store, since it's only using r10
      and immediate constant of zero; hence af86ca4e /assumed/ a low latency
      operation.
      
      However, a recent attack demonstrated that this mitigation is not sufficient
      since the preemptive store of zero could also be turned into a "slow" store
      and is thus bypassed as well:
      
        [...]
        // r2 = oob address (e.g. scalar)
        // r7 = pointer to map value
        31: (7b) *(u64 *)(r10 -16) = r2
        // r9 will remain "fast" register, r10 will become "slow" register below
        32: (bf) r9 = r10
        // JIT maps BPF reg to x86 reg:
        //  r9  -> r15 (callee saved)
        //  r10 -> rbp
        // train store forward prediction to break dependency link between both r9
        // and r10 by evicting them from the predictor's LRU table.
        33: (61) r0 = *(u32 *)(r7 +24576)
        34: (63) *(u32 *)(r7 +29696) = r0
        35: (61) r0 = *(u32 *)(r7 +24580)
        36: (63) *(u32 *)(r7 +29700) = r0
        37: (61) r0 = *(u32 *)(r7 +24584)
        38: (63) *(u32 *)(r7 +29704) = r0
        39: (61) r0 = *(u32 *)(r7 +24588)
        40: (63) *(u32 *)(r7 +29708) = r0
        [...]
        543: (61) r0 = *(u32 *)(r7 +25596)
        544: (63) *(u32 *)(r7 +30716) = r0
        // prepare call to bpf_ringbuf_output() helper. the latter will cause rbp
        // to spill to stack memory while r13/r14/r15 (all callee saved regs) remain
        // in hardware registers. rbp becomes slow due to push/pop latency. below is
        // disasm of bpf_ringbuf_output() helper for better visual context:
        //
        // ffffffff8117ee20: 41 54                 push   r12
        // ffffffff8117ee22: 55                    push   rbp
        // ffffffff8117ee23: 53                    push   rbx
        // ffffffff8117ee24: 48 f7 c1 fc ff ff ff  test   rcx,0xfffffffffffffffc
        // ffffffff8117ee2b: 0f 85 af 00 00 00     jne    ffffffff8117eee0 <-- jump taken
        // [...]
        // ffffffff8117eee0: 49 c7 c4 ea ff ff ff  mov    r12,0xffffffffffffffea
        // ffffffff8117eee7: 5b                    pop    rbx
        // ffffffff8117eee8: 5d                    pop    rbp
        // ffffffff8117eee9: 4c 89 e0              mov    rax,r12
        // ffffffff8117eeec: 41 5c                 pop    r12
        // ffffffff8117eeee: c3                    ret
        545: (18) r1 = map[id:4]
        547: (bf) r2 = r7
        548: (b7) r3 = 0
        549: (b7) r4 = 4
        550: (85) call bpf_ringbuf_output#194288
        // instruction 551 inserted by verifier    \
        551: (7a) *(u64 *)(r10 -16) = 0            | /both/ are now slow stores here
        // storing map value pointer r7 at fp-16   | since value of r10 is "slow".
        552: (7b) *(u64 *)(r10 -16) = r7           /
        // following "fast" read to the same memory location, but due to dependency
        // misprediction it will speculatively execute before insn 551/552 completes.
        553: (79) r2 = *(u64 *)(r9 -16)
        // in speculative domain contains attacker controlled r2. in non-speculative
        // domain this contains r7, and thus accesses r7 +0 below.
        554: (71) r3 = *(u8 *)(r2 +0)
        // leak r3
      
      As can be seen, the current speculative store bypass mitigation which the
      verifier inserts at line 551 is insufficient since /both/, the write of
      the zero sanitation as well as the map value pointer are a high latency
      instruction due to prior memory access via push/pop of r10 (rbp) in contrast
      to the low latency read in line 553 as r9 (r15) which stays in hardware
      registers. Thus, architecturally, fp-16 is r7, however, microarchitecturally,
      fp-16 can still be r2.
      
      Initial thoughts to address this issue was to track spilled pointer loads
      from stack and enforce their load via LDX through r10 as well so that /both/
      the preemptive store of zero /as well as/ the load use the /same/ register
      such that a dependency is created between the store and load. However, this
      option is not sufficient either since it can be bypassed as well under
      speculation. An updated attack with pointer spill/fills now _all_ based on
      r10 would look as follows:
      
        [...]
        // r2 = oob address (e.g. scalar)
        // r7 = pointer to map value
        [...]
        // longer store forward prediction training sequence than before.
        2062: (61) r0 = *(u32 *)(r7 +25588)
        2063: (63) *(u32 *)(r7 +30708) = r0
        2064: (61) r0 = *(u32 *)(r7 +25592)
        2065: (63) *(u32 *)(r7 +30712) = r0
        2066: (61) r0 = *(u32 *)(r7 +25596)
        2067: (63) *(u32 *)(r7 +30716) = r0
        // store the speculative load address (scalar) this time after the store
        // forward prediction training.
        2068: (7b) *(u64 *)(r10 -16) = r2
        // preoccupy the CPU store port by running sequence of dummy stores.
        2069: (63) *(u32 *)(r7 +29696) = r0
        2070: (63) *(u32 *)(r7 +29700) = r0
        2071: (63) *(u32 *)(r7 +29704) = r0
        2072: (63) *(u32 *)(r7 +29708) = r0
        2073: (63) *(u32 *)(r7 +29712) = r0
        2074: (63) *(u32 *)(r7 +29716) = r0
        2075: (63) *(u32 *)(r7 +29720) = r0
        2076: (63) *(u32 *)(r7 +29724) = r0
        2077: (63) *(u32 *)(r7 +29728) = r0
        2078: (63) *(u32 *)(r7 +29732) = r0
        2079: (63) *(u32 *)(r7 +29736) = r0
        2080: (63) *(u32 *)(r7 +29740) = r0
        2081: (63) *(u32 *)(r7 +29744) = r0
        2082: (63) *(u32 *)(r7 +29748) = r0
        2083: (63) *(u32 *)(r7 +29752) = r0
        2084: (63) *(u32 *)(r7 +29756) = r0
        2085: (63) *(u32 *)(r7 +29760) = r0
        2086: (63) *(u32 *)(r7 +29764) = r0
        2087: (63) *(u32 *)(r7 +29768) = r0
        2088: (63) *(u32 *)(r7 +29772) = r0
        2089: (63) *(u32 *)(r7 +29776) = r0
        2090: (63) *(u32 *)(r7 +29780) = r0
        2091: (63) *(u32 *)(r7 +29784) = r0
        2092: (63) *(u32 *)(r7 +29788) = r0
        2093: (63) *(u32 *)(r7 +29792) = r0
        2094: (63) *(u32 *)(r7 +29796) = r0
        2095: (63) *(u32 *)(r7 +29800) = r0
        2096: (63) *(u32 *)(r7 +29804) = r0
        2097: (63) *(u32 *)(r7 +29808) = r0
        2098: (63) *(u32 *)(r7 +29812) = r0
        // overwrite scalar with dummy pointer; same as before, also including the
        // sanitation store with 0 from the current mitigation by the verifier.
        2099: (7a) *(u64 *)(r10 -16) = 0         | /both/ are now slow stores here
        2100: (7b) *(u64 *)(r10 -16) = r7        | since store unit is still busy.
        // load from stack intended to bypass stores.
        2101: (79) r2 = *(u64 *)(r10 -16)
        2102: (71) r3 = *(u8 *)(r2 +0)
        // leak r3
        [...]
      
      Looking at the CPU microarchitecture, the scheduler might issue loads (such
      as seen in line 2101) before stores (line 2099,2100) because the load execution
      units become available while the store execution unit is still busy with the
      sequence of dummy stores (line 2069-2098). And so the load may use the prior
      stored scalar from r2 at address r10 -16 for speculation. The updated attack
      may work less reliable on CPU microarchitectures where loads and stores share
      execution resources.
      
      This concludes that the sanitizing with zero stores from af86ca4e ("bpf:
      Prevent memory disambiguation attack") is insufficient. Moreover, the detection
      of stack reuse from af86ca4e where previously data (STACK_MISC) has been
      written to a given stack slot where a pointer value is now to be stored does
      not have sufficient coverage as precondition for the mitigation either; for
      several reasons outlined as follows:
      
       1) Stack content from prior program runs could still be preserved and is
          therefore not "random", best example is to split a speculative store
          bypass attack between tail calls, program A would prepare and store the
          oob address at a given stack slot and then tail call into program B which
          does the "slow" store of a pointer to the stack with subsequent "fast"
          read. From program B PoV such stack slot type is STACK_INVALID, and
          therefore also must be subject to mitigation.
      
       2) The STACK_SPILL must not be coupled to register_is_const(&stack->spilled_ptr)
          condition, for example, the previous content of that memory location could
          also be a pointer to map or map value. Without the fix, a speculative
          store bypass is not mitigated in such precondition and can then lead to
          a type confusion in the speculative domain leaking kernel memory near
          these pointer types.
      
      While brainstorming on various alternative mitigation possibilities, we also
      stumbled upon a retrospective from Chrome developers [0]:
      
        [...] For variant 4, we implemented a mitigation to zero the unused memory
        of the heap prior to allocation, which cost about 1% when done concurrently
        and 4% for scavenging. Variant 4 defeats everything we could think of. We
        explored more mitigations for variant 4 but the threat proved to be more
        pervasive and dangerous than we anticipated. For example, stack slots used
        by the register allocator in the optimizing compiler could be subject to
        type confusion, leading to pointer crafting. Mitigating type confusion for
        stack slots alone would have required a complete redesign of the backend of
        the optimizing compiler, perhaps man years of work, without a guarantee of
        completeness. [...]
      
      From BPF side, the problem space is reduced, however, options are rather
      limited. One idea that has been explored was to xor-obfuscate pointer spills
      to the BPF stack:
      
        [...]
        // preoccupy the CPU store port by running sequence of dummy stores.
        [...]
        2106: (63) *(u32 *)(r7 +29796) = r0
        2107: (63) *(u32 *)(r7 +29800) = r0
        2108: (63) *(u32 *)(r7 +29804) = r0
        2109: (63) *(u32 *)(r7 +29808) = r0
        2110: (63) *(u32 *)(r7 +29812) = r0
        // overwrite scalar with dummy pointer; xored with random 'secret' value
        // of 943576462 before store ...
        2111: (b4) w11 = 943576462
        2112: (af) r11 ^= r7
        2113: (7b) *(u64 *)(r10 -16) = r11
        2114: (79) r11 = *(u64 *)(r10 -16)
        2115: (b4) w2 = 943576462
        2116: (af) r2 ^= r11
        // ... and restored with the same 'secret' value with the help of AX reg.
        2117: (71) r3 = *(u8 *)(r2 +0)
        [...]
      
      While the above would not prevent speculation, it would make data leakage
      infeasible by directing it to random locations. In order to be effective
      and prevent type confusion under speculation, such random secret would have
      to be regenerated for each store. The additional complexity involved for a
      tracking mechanism that prevents jumps such that restoring spilled pointers
      would not get corrupted is not worth the gain for unprivileged. Hence, the
      fix in here eventually opted for emitting a non-public BPF_ST | BPF_NOSPEC
      instruction which the x86 JIT translates into a lfence opcode. Inserting the
      latter in between the store and load instruction is one of the mitigations
      options [1]. The x86 instruction manual notes:
      
        [...] An LFENCE that follows an instruction that stores to memory might
        complete before the data being stored have become globally visible. [...]
      
      The latter meaning that the preceding store instruction finished execution
      and the store is at minimum guaranteed to be in the CPU's store queue, but
      it's not guaranteed to be in that CPU's L1 cache at that point (globally
      visible). The latter would only be guaranteed via sfence. So the load which
      is guaranteed to execute after the lfence for that local CPU would have to
      rely on store-to-load forwarding. [2], in section 2.3 on store buffers says:
      
        [...] For every store operation that is added to the ROB, an entry is
        allocated in the store buffer. This entry requires both the virtual and
        physical address of the target. Only if there is no free entry in the store
        buffer, the frontend stalls until there is an empty slot available in the
        store buffer again. Otherwise, the CPU can immediately continue adding
        subsequent instructions to the ROB and execute them out of order. On Intel
        CPUs, the store buffer has up to 56 entries. [...]
      
      One small upside on the fix is that it lifts constraints from af86ca4e
      where the sanitize_stack_off relative to r10 must be the same when coming
      from different paths. The BPF_ST | BPF_NOSPEC gets emitted after a BPF_STX
      or BPF_ST instruction. This happens either when we store a pointer or data
      value to the BPF stack for the first time, or upon later pointer spills.
      The former needs to be enforced since otherwise stale stack data could be
      leaked under speculation as outlined earlier. For non-x86 JITs the BPF_ST |
      BPF_NOSPEC mapping is currently optimized away, but others could emit a
      speculation barrier as well if necessary. For real-world unprivileged
      programs e.g. generated by LLVM, pointer spill/fill is only generated upon
      register pressure and LLVM only tries to do that for pointers which are not
      used often. The program main impact will be the initial BPF_ST | BPF_NOSPEC
      sanitation for the STACK_INVALID case when the first write to a stack slot
      occurs e.g. upon map lookup. In future we might refine ways to mitigate
      the latter cost.
      
        [0] https://arxiv.org/pdf/1902.05178.pdf
        [1] https://msrc-blog.microsoft.com/2018/05/21/analysis-and-mitigation-of-speculative-store-bypass-cve-2018-3639/
        [2] https://arxiv.org/pdf/1905.05725.pdf
      
      Fixes: af86ca4e ("bpf: Prevent memory disambiguation attack")
      Fixes: f7cf25b2
      
       ("bpf: track spill/fill of constants")
      Co-developed-by: default avatarPiotr Krysiuk <piotras@gmail.com>
      Co-developed-by: default avatarBenedict Schlueter <benedict.schlueter@rub.de>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: default avatarPiotr Krysiuk <piotras@gmail.com>
      Signed-off-by: default avatarBenedict Schlueter <benedict.schlueter@rub.de>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0e928065
    • Daniel Borkmann's avatar
      bpf: Introduce BPF nospec instruction for mitigating Spectre v4 · bea9e2fd
      Daniel Borkmann authored
      [ Upstream commit f5e81d11
      
       ]
      
      In case of JITs, each of the JIT backends compiles the BPF nospec instruction
      /either/ to a machine instruction which emits a speculation barrier /or/ to
      /no/ machine instruction in case the underlying architecture is not affected
      by Speculative Store Bypass or has different mitigations in place already.
      
      This covers both x86 and (implicitly) arm64: In case of x86, we use 'lfence'
      instruction for mitigation. In case of arm64, we rely on the firmware mitigation
      as controlled via the ssbd kernel parameter. Whenever the mitigation is enabled,
      it works for all of the kernel code with no need to provide any additional
      instructions here (hence only comment in arm64 JIT). Other archs can follow
      as needed. The BPF nospec instruction is specifically targeting Spectre v4
      since i) we don't use a serialization barrier for the Spectre v1 case, and
      ii) mitigation instructions for v1 and v4 might be different on some archs.
      
      The BPF nospec is required for a future commit, where the BPF verifier does
      annotate intermediate BPF programs with speculation barriers.
      
      Co-developed-by: default avatarPiotr Krysiuk <piotras@gmail.com>
      Co-developed-by: default avatarBenedict Schlueter <benedict.schlueter@rub.de>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: default avatarPiotr Krysiuk <piotras@gmail.com>
      Signed-off-by: default avatarBenedict Schlueter <benedict.schlueter@rub.de>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bea9e2fd
    • Dan Carpenter's avatar
      can: hi311x: fix a signedness bug in hi3110_cmd() · cd61e665
      Dan Carpenter authored
      [ Upstream commit f6b3c784 ]
      
      The hi3110_cmd() is supposed to return zero on success and negative
      error codes on failure, but it was accidentally declared as a u8 when
      it needs to be an int type.
      
      Fixes: 57e83fb9
      
       ("can: hi311x: Add Holt HI-311x CAN driver")
      Link: https://lore.kernel.org/r/20210729141246.GA1267@kili
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cd61e665
    • Wang Hai's avatar
      sis900: Fix missing pci_disable_device() in probe and remove · 65dfa6cb
      Wang Hai authored
      [ Upstream commit 89fb62fd ]
      
      Replace pci_enable_device() with pcim_enable_device(),
      pci_disable_device() and pci_release_regions() will be
      called in release automatically.
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarWang Hai <wanghai38@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      65dfa6cb
    • Wang Hai's avatar
      tulip: windbond-840: Fix missing pci_disable_device() in probe and remove · 93e5bf4b
      Wang Hai authored
      [ Upstream commit 76a16be0 ]
      
      Replace pci_enable_device() with pcim_enable_device(),
      pci_disable_device() and pci_release_regions() will be
      called in release automatically.
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarWang Hai <wanghai38@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      93e5bf4b
    • Marcelo Ricardo Leitner's avatar
      sctp: fix return value check in __sctp_rcv_asconf_lookup · 58b8c812
      Marcelo Ricardo Leitner authored
      [ Upstream commit 557fb586
      
       ]
      
      As Ben Hutchings noticed, this check should have been inverted: the call
      returns true in case of success.
      
      Reported-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Fixes: 0c5dc070
      
       ("sctp: validate from_addr_param return")
      Signed-off-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Reviewed-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      58b8c812
    • Dima Chumak's avatar
      net/mlx5e: Fix nullptr in mlx5e_hairpin_get_mdev() · 362e9d23
      Dima Chumak authored
      [ Upstream commit b1c2f631 ]
      
      The result of __dev_get_by_index() is not checked for NULL and then gets
      dereferenced immediately.
      
      Also, __dev_get_by_index() must be called while holding either RTNL lock
      or @dev_base_lock, which isn't satisfied by mlx5e_hairpin_get_mdev() or
      its callers. This makes the underlying hlist_for_each_entry() loop not
      safe, and can have adverse effects in itself.
      
      Fix by using dev_get_by_index() and handling nullptr return value when
      ifindex device is not found. Update mlx5e_hairpin_get_mdev() callers to
      check for possible PTR_ERR() result.
      
      Fixes: 77ab67b7
      
       ("net/mlx5e: Basic setup of hairpin object")
      Addresses-Coverity: ("Dereference null return value")
      Signed-off-by: default avatarDima Chumak <dchumak@nvidia.com>
      Reviewed-by: default avatarVlad Buslov <vladbu@nvidia.com>
      Reviewed-by: default avatarRoi Dayan <roid@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      362e9d23
    • Maor Gottlieb's avatar
      net/mlx5: Fix flow table chaining · bd744f2a
      Maor Gottlieb authored
      [ Upstream commit 8b54874e ]
      
      Fix a bug when flow table is created in priority that already
      has other flow tables as shown in the below diagram.
      If the new flow table (FT-B) has the lowest level in the priority,
      we need to connect the flow tables from the previous priority (p0)
      to this new table. In addition when this flow table is destroyed
      (FT-B), we need to connect the flow tables from the previous
      priority (p0) to the next level flow table (FT-C) in the same
      priority of the destroyed table (if exists).
      
                             ---------
                             |root_ns|
                             ---------
                                  |
                  --------------------------------
                  |               |              |
             ----------      ----------      ---------
             |p(prio)-x|     |   p-y  |      |   p-n |
             ----------      ----------      ---------
                  |               |
           ----------------  ------------------
           |ns(e.g bypass)|  |ns(e.g. kernel) |
           ----------------  ------------------
                  |            |           |
      	-------	       ------       ----
              |  p0 |        | p1 |       |p2|
              -------        ------       ----
                 |             |    \
              --------       ------- ------
              | FT-A |       |FT-B | |FT-C|
              --------       ------- ------
      
      Fixes: f90edfd2
      
       ("net/mlx5_core: Connect flow tables")
      Signed-off-by: default avatarMaor Gottlieb <maorg@nvidia.com>
      Reviewed-by: default avatarMark Bloch <mbloch@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bd744f2a
    • Cong Wang's avatar
      skmsg: Make sk_psock_destroy() static · 1b148bd7
      Cong Wang authored
      [ Upstream commit 8063e184
      
       ]
      
      sk_psock_destroy() is a RCU callback, I can't see any reason why
      it could be used outside.
      
      Signed-off-by: default avatarCong Wang <cong.wang@bytedance.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: Jakub Sitnicki <jakub@cloudflare.com>
      Cc: Lorenz Bauer <lmb@cloudflare.com>
      Link: https://lore.kernel.org/bpf/20210127221501.46866-1-xiyou.wangcong@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1b148bd7
    • Bjorn Andersson's avatar
      drm/msm/dp: Initialize the INTF_CONFIG register · 645a1d3b
      Bjorn Andersson authored
      [ Upstream commit f9a39932 ]
      
      Some bootloaders set the widebus enable bit in the INTF_CONFIG register,
      but configuration of widebus isn't yet supported ensure that the
      register has a known value, with widebus disabled.
      
      Fixes: c943b494
      
       ("drm/msm/dp: add displayPort driver support")
      Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
      Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
      Link: https://lore.kernel.org/r/20210722024434.3313167-1-bjorn.andersson@linaro.org
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      645a1d3b
    • Robert Foss's avatar
      drm/msm/dpu: Fix sm8250_mdp register length · 4a684192
      Robert Foss authored
      [ Upstream commit b910a020 ]
      
      The downstream dts lists this value as 0x494, and not
      0x45c.
      
      Fixes: af776a3e
      
       ("drm/msm/dpu: add SM8250 to hw catalog")
      Signed-off-by: default avatarRobert Foss <robert.foss@linaro.org>
      Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@somainline.org>
      Link: https://lore.kernel.org/r/20210628085033.9905-1-robert.foss@linaro.org
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4a684192
    • Pavel Skripkin's avatar
      net: llc: fix skb_over_panic · e6097071
      Pavel Skripkin authored
      [ Upstream commit c7c9d210 ]
      
      Syzbot reported skb_over_panic() in llc_pdu_init_as_xid_cmd(). The
      problem was in wrong LCC header manipulations.
      
      Syzbot's reproducer tries to send XID packet. llc_ui_sendmsg() is
      doing following steps:
      
      	1. skb allocation with size = len + header size
      		len is passed from userpace and header size
      		is 3 since addr->sllc_xid is set.
      
      	2. skb_reserve() for header_len = 3
      	3. filling all other space with memcpy_from_msg()
      
      Ok, at this moment we have fully loaded skb, only headers needs to be
      filled.
      
      Then code comes to llc_sap_action_send_xid_c(). This function pushes 3
      bytes for LLC PDU header and initializes it. Then comes
      llc_pdu_init_as_xid_cmd(). It initalizes next 3 bytes *AFTER* LLC PDU
      header and call skb_push(skb, 3). This looks wrong for 2 reasons:
      
      	1. Bytes rigth after LLC header are user data, so this function
      	   was overwriting payload.
      
      	2. skb_push(skb, 3) call can cause skb_over_panic() since
      	   all free space was filled in llc_ui_sendmsg(). (This can
      	   happen is user passed 686 len: 686 + 14 (eth header) + 3 (LLC
      	   header) = 703. SKB_DATA_ALIGN(703) = 704)
      
      So, in this patch I added 2 new private constansts: LLC_PDU_TYPE_U_XID
      and LLC_PDU_LEN_U_XID. LLC_PDU_LEN_U_XID is used to correctly reserve
      header size to handle LLC + XID case. LLC_PDU_TYPE_U_XID is used by
      llc_pdu_header_init() function to push 6 bytes instead of 3. And finally
      I removed skb_push() call from llc_pdu_init_as_xid_cmd().
      
      This changes should not affect other parts of LLC, since after
      all steps we just transmit buffer.
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Reported-and-tested-by: default avatar <syzbot+5e5a981ad7cc54c4b2b4@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>
      e6097071
    • Vitaly Kuznetsov's avatar
      KVM: x86: Check the right feature bit for MSR_KVM_ASYNC_PF_ACK access · 01f3581d
      Vitaly Kuznetsov authored
      [ Upstream commit 0a31df68 ]
      
      MSR_KVM_ASYNC_PF_ACK MSR is part of interrupt based asynchronous page fault
      interface and not the original (deprecated) KVM_FEATURE_ASYNC_PF. This is
      stated in Documentation/virt/kvm/msr.rst.
      
      Fixes: 66570e96
      
       ("kvm: x86: only provide PV features if enabled in guest's CPUID")
      Signed-off-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
      Reviewed-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
      Reviewed-by: default avatarOliver Upton <oupton@google.com>
      Message-Id: <20210722123018.260035-1-vkuznets@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      01f3581d
    • Jiapeng Chong's avatar
      mlx4: Fix missing error code in mlx4_load_one() · f5f78ae5
      Jiapeng Chong authored
      [ Upstream commit 7e4960b3
      
       ]
      
      The error code is missing in this code scenario, add the error code
      '-EINVAL' to the return value 'err'.
      
      Eliminate the follow smatch warning:
      
      drivers/net/ethernet/mellanox/mlx4/main.c:3538 mlx4_load_one() warn:
      missing error code 'err'.
      
      Reported-by: default avatarAbaci Robot <abaci@linux.alibaba.com>
      Fixes: 7ae0e400
      
       ("net/mlx4_core: Flexible (asymmetric) allocation of EQs and MSI-X vectors for PF/VFs")
      Signed-off-by: default avatarJiapeng Chong <jiapeng.chong@linux.alibaba.com>
      Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f5f78ae5
    • Geetha sowjanya's avatar
      octeontx2-pf: Fix interface down flag on error · 51b751fc
      Geetha sowjanya authored
      [ Upstream commit 69f0aeb1 ]
      
      In the existing code while changing the number of TX/RX
      queues using ethtool the PF/VF interface resources are
      freed and reallocated (otx2_stop and otx2_open is called)
      if the device is in running state. If any resource allocation
      fails in otx2_open, driver free already allocated resources
      and return. But again, when the number of queues changes
      as the device state still running oxt2_stop is called.
      In which we try to free already freed resources leading
      to driver crash.
      This patch fixes the issue by setting the INTF_DOWN flag on
      error and free the resources in otx2_stop only if the flag is
      not set.
      
      Fixes: 50fe6c02
      
       ("octeontx2-pf: Register and handle link notifications")
      Signed-off-by: default avatarGeetha sowjanya <gakula@marvell.com>
      Signed-off-by: default avatarSunil Kovvuri Goutham <Sunil.Goutham@cavium.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      51b751fc
    • Xin Long's avatar
      tipc: do not write skb_shinfo frags when doing decrytion · 4951ffa3
      Xin Long authored
      [ Upstream commit 3cf4375a ]
      
      One skb's skb_shinfo frags are not writable, and they can be shared with
      other skbs' like by pskb_copy(). To write the frags may cause other skb's
      data crash.
      
      So before doing en/decryption, skb_cow_data() should always be called for
      a cloned or nonlinear skb if req dst is using the same sg as req src.
      While at it, the likely branch can be removed, as it will be covered
      by skb_cow_data().
      
      Note that esp_input() has the same issue, and I will fix it in another
      patch. tipc_aead_encrypt() doesn't have this issue, as it only processes
      linear data in the unlikely branch.
      
      Fixes: fc1b6d6d
      
       ("tipc: introduce TIPC encryption & authentication")
      Reported-by: default avatarShuang Li <shuali@redhat.com>
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Acked-by: default avatarJon Maloy <jmaloy@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4951ffa3
    • Shannon Nelson's avatar
      ionic: count csum_none when offload enabled · 7eefa0b7
      Shannon Nelson authored
      [ Upstream commit f07f9815 ]
      
      Be sure to count the csum_none cases when csum offload is
      enabled.
      
      Fixes: 0f3154e6
      
       ("ionic: Add Tx and Rx handling")
      Signed-off-by: default avatarShannon Nelson <snelson@pensando.io>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7eefa0b7
    • Shannon Nelson's avatar
      ionic: fix up dim accounting for tx and rx · 60decbe0
      Shannon Nelson authored
      [ Upstream commit 76ed8a4a ]
      
      We need to count the correct Tx and/or Rx packets for dynamic
      interrupt moderation, depending on which we're processing on
      the queue interrupt.
      
      Fixes: 04a83459
      
       ("ionic: dynamic interrupt moderation")
      Signed-off-by: default avatarShannon Nelson <snelson@pensando.io>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      60decbe0
    • Shannon Nelson's avatar
      ionic: remove intr coalesce update from napi · a7c85a51
      Shannon Nelson authored
      [ Upstream commit a6ff85e0 ]
      
      Move the interrupt coalesce value update out of the napi
      thread and into the dim_work thread and set it only when it
      has actually changed.
      
      Fixes: 04a83459
      
       ("ionic: dynamic interrupt moderation")
      Signed-off-by: default avatarShannon Nelson <snelson@pensando.io>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a7c85a51