]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.15-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 22 Aug 2022 13:13:40 +0000 (15:13 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 22 Aug 2022 13:13:40 +0000 (15:13 +0200)
added patches:
fec-fix-timer-capture-timing-in-fec_ptp_enable_pps.patch
gcc-plugins-undefine-latent_entropy_plugin-when-plugin-disabled-for-a-file.patch
i2c-imx-make-sure-to-unregister-adapter-on-remove.patch
i40e-fix-to-stop-tx_timeout-recovery-if-globr-fails.patch
ice-ignore-eexist-when-setting-promisc-mode.patch
igb-add-lock-to-avoid-data-race.patch
kbuild-fix-the-modules-order-between-drivers-and-libs.patch
mlxsw-spectrum-clear-ptp-configuration-after-unregistering-the-netdevice.patch
net-dsa-don-t-warn-in-dsa_port_set_state_now-when-driver-doesn-t-support-it.patch
net-dsa-felix-fix-ethtool-256-511-and-512-1023-tx-packet-counters.patch
net-dsa-microchip-ksz9477-fix-fdb_dump-last-invalid-entry.patch
net-dsa-mv88e6060-prevent-crash-on-an-unused-port.patch
net-dsa-sja1105-fix-buffer-overflow-in-sja1105_setup_devlink_regions.patch
net-fix-potential-refcount-leak-in-ndisc_router_discovery.patch
net-genl-fix-error-path-memory-leak-in-policy-dumping.patch
net-moxa-pass-pdev-instead-of-ndev-to-dma-functions.patch
net-sunrpc-fix-potential-memory-leaks-in-rpc_sysfs_xprt_state_change.patch
netfilter-nf_tables-check-nft_set_concat-flag-if-field_count-is-specified.patch
netfilter-nf_tables-disallow-nft_set_elem_catchall-and-nft_set_elem_interval_end.patch
netfilter-nf_tables-disallow-nfta_set_elem_key_end-with-nft_set_elem_interval_end-flag.patch
netfilter-nf_tables-nfta_set_elem_key_end-requires-concat-and-interval-flags.patch
netfilter-nf_tables-possible-module-reference-underflow-in-error-path.patch
netfilter-nf_tables-really-skip-inactive-sets-when-allocating-name.patch
netfilter-nf_tables-validate-nfta_set_elem_objref-based-on-nft_set_object-flag.patch
powerpc-pci-fix-get_phb_number-locking.patch
regulator-pca9450-remove-restrictions-for-regulator-name.patch
spi-meson-spicc-add-local-pow2-clock-ops-to-preserve-rate-between-messages.patch
stmmac-intel-add-a-missing-clk_disable_unprepare-call-in-intel_eth_pci_remove.patch

29 files changed:
queue-5.15/fec-fix-timer-capture-timing-in-fec_ptp_enable_pps.patch [new file with mode: 0644]
queue-5.15/gcc-plugins-undefine-latent_entropy_plugin-when-plugin-disabled-for-a-file.patch [new file with mode: 0644]
queue-5.15/i2c-imx-make-sure-to-unregister-adapter-on-remove.patch [new file with mode: 0644]
queue-5.15/i40e-fix-to-stop-tx_timeout-recovery-if-globr-fails.patch [new file with mode: 0644]
queue-5.15/ice-ignore-eexist-when-setting-promisc-mode.patch [new file with mode: 0644]
queue-5.15/igb-add-lock-to-avoid-data-race.patch [new file with mode: 0644]
queue-5.15/kbuild-fix-the-modules-order-between-drivers-and-libs.patch [new file with mode: 0644]
queue-5.15/mlxsw-spectrum-clear-ptp-configuration-after-unregistering-the-netdevice.patch [new file with mode: 0644]
queue-5.15/net-dsa-don-t-warn-in-dsa_port_set_state_now-when-driver-doesn-t-support-it.patch [new file with mode: 0644]
queue-5.15/net-dsa-felix-fix-ethtool-256-511-and-512-1023-tx-packet-counters.patch [new file with mode: 0644]
queue-5.15/net-dsa-microchip-ksz9477-fix-fdb_dump-last-invalid-entry.patch [new file with mode: 0644]
queue-5.15/net-dsa-mv88e6060-prevent-crash-on-an-unused-port.patch [new file with mode: 0644]
queue-5.15/net-dsa-sja1105-fix-buffer-overflow-in-sja1105_setup_devlink_regions.patch [new file with mode: 0644]
queue-5.15/net-fix-potential-refcount-leak-in-ndisc_router_discovery.patch [new file with mode: 0644]
queue-5.15/net-genl-fix-error-path-memory-leak-in-policy-dumping.patch [new file with mode: 0644]
queue-5.15/net-moxa-pass-pdev-instead-of-ndev-to-dma-functions.patch [new file with mode: 0644]
queue-5.15/net-sunrpc-fix-potential-memory-leaks-in-rpc_sysfs_xprt_state_change.patch [new file with mode: 0644]
queue-5.15/netfilter-nf_tables-check-nft_set_concat-flag-if-field_count-is-specified.patch [new file with mode: 0644]
queue-5.15/netfilter-nf_tables-disallow-nft_set_elem_catchall-and-nft_set_elem_interval_end.patch [new file with mode: 0644]
queue-5.15/netfilter-nf_tables-disallow-nfta_set_elem_key_end-with-nft_set_elem_interval_end-flag.patch [new file with mode: 0644]
queue-5.15/netfilter-nf_tables-nfta_set_elem_key_end-requires-concat-and-interval-flags.patch [new file with mode: 0644]
queue-5.15/netfilter-nf_tables-possible-module-reference-underflow-in-error-path.patch [new file with mode: 0644]
queue-5.15/netfilter-nf_tables-really-skip-inactive-sets-when-allocating-name.patch [new file with mode: 0644]
queue-5.15/netfilter-nf_tables-validate-nfta_set_elem_objref-based-on-nft_set_object-flag.patch [new file with mode: 0644]
queue-5.15/powerpc-pci-fix-get_phb_number-locking.patch [new file with mode: 0644]
queue-5.15/regulator-pca9450-remove-restrictions-for-regulator-name.patch [new file with mode: 0644]
queue-5.15/series
queue-5.15/spi-meson-spicc-add-local-pow2-clock-ops-to-preserve-rate-between-messages.patch [new file with mode: 0644]
queue-5.15/stmmac-intel-add-a-missing-clk_disable_unprepare-call-in-intel_eth_pci_remove.patch [new file with mode: 0644]

diff --git a/queue-5.15/fec-fix-timer-capture-timing-in-fec_ptp_enable_pps.patch b/queue-5.15/fec-fix-timer-capture-timing-in-fec_ptp_enable_pps.patch
new file mode 100644 (file)
index 0000000..9075c88
--- /dev/null
@@ -0,0 +1,39 @@
+From 61d5e2a251fb20c2c5e998c3f1d52ed6d5360319 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Cs=C3=B3k=C3=A1s=20Bence?= <csokas.bence@prolan.hu>
+Date: Thu, 11 Aug 2022 12:13:49 +0200
+Subject: fec: Fix timer capture timing in `fec_ptp_enable_pps()`
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Csókás Bence <csokas.bence@prolan.hu>
+
+commit 61d5e2a251fb20c2c5e998c3f1d52ed6d5360319 upstream.
+
+Code reimplements functionality already in `fec_ptp_read()`,
+but misses check for FEC_QUIRK_BUG_CAPTURE. Replace with function call.
+
+Fixes: 28b5f058cf1d ("net: fec: ptp: fix convergence issue to support LinuxPTP stack")
+Signed-off-by: Csókás Bence <csokas.bence@prolan.hu>
+Link: https://lore.kernel.org/r/20220811101348.13755-1-csokas.bence@prolan.hu
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/ethernet/freescale/fec_ptp.c |    6 +-----
+ 1 file changed, 1 insertion(+), 5 deletions(-)
+
+--- a/drivers/net/ethernet/freescale/fec_ptp.c
++++ b/drivers/net/ethernet/freescale/fec_ptp.c
+@@ -136,11 +136,7 @@ static int fec_ptp_enable_pps(struct fec
+                * NSEC_PER_SEC - ts.tv_nsec. Add the remaining nanoseconds
+                * to current timer would be next second.
+                */
+-              tempval = readl(fep->hwp + FEC_ATIME_CTRL);
+-              tempval |= FEC_T_CTRL_CAPTURE;
+-              writel(tempval, fep->hwp + FEC_ATIME_CTRL);
+-
+-              tempval = readl(fep->hwp + FEC_ATIME);
++              tempval = fep->cc.read(&fep->cc);
+               /* Convert the ptp local counter to 1588 timestamp */
+               ns = timecounter_cyc2time(&fep->tc, tempval);
+               ts = ns_to_timespec64(ns);
diff --git a/queue-5.15/gcc-plugins-undefine-latent_entropy_plugin-when-plugin-disabled-for-a-file.patch b/queue-5.15/gcc-plugins-undefine-latent_entropy_plugin-when-plugin-disabled-for-a-file.patch
new file mode 100644 (file)
index 0000000..3f05939
--- /dev/null
@@ -0,0 +1,73 @@
+From 012e8d2034f1bda8863435cd589636e618d6a659 Mon Sep 17 00:00:00 2001
+From: Andrew Donnellan <ajd@linux.ibm.com>
+Date: Tue, 16 Aug 2022 15:17:20 +1000
+Subject: gcc-plugins: Undefine LATENT_ENTROPY_PLUGIN when plugin disabled for a file
+
+From: Andrew Donnellan <ajd@linux.ibm.com>
+
+commit 012e8d2034f1bda8863435cd589636e618d6a659 upstream.
+
+Commit 36d4b36b6959 ("lib/nodemask: inline next_node_in() and
+node_random()") refactored some code by moving node_random() from
+lib/nodemask.c to include/linux/nodemask.h, thus requiring nodemask.h to
+include random.h, which conditionally defines add_latent_entropy()
+depending on whether the macro LATENT_ENTROPY_PLUGIN is defined.
+
+This broke the build on powerpc, where nodemask.h is indirectly included
+in arch/powerpc/kernel/prom_init.c, part of the early boot machinery that
+is excluded from the latent entropy plugin using
+DISABLE_LATENT_ENTROPY_PLUGIN. It turns out that while we add a gcc flag
+to disable the actual plugin, we don't undefine LATENT_ENTROPY_PLUGIN.
+
+This leads to the following:
+
+    CC      arch/powerpc/kernel/prom_init.o
+  In file included from ./include/linux/nodemask.h:97,
+                   from ./include/linux/mmzone.h:17,
+                   from ./include/linux/gfp.h:7,
+                   from ./include/linux/xarray.h:15,
+                   from ./include/linux/radix-tree.h:21,
+                   from ./include/linux/idr.h:15,
+                   from ./include/linux/kernfs.h:12,
+                   from ./include/linux/sysfs.h:16,
+                   from ./include/linux/kobject.h:20,
+                   from ./include/linux/pci.h:35,
+                   from arch/powerpc/kernel/prom_init.c:24:
+  ./include/linux/random.h: In function 'add_latent_entropy':
+  ./include/linux/random.h:25:46: error: 'latent_entropy' undeclared (first use in this function); did you mean 'add_latent_entropy'?
+     25 |         add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
+        |                                              ^~~~~~~~~~~~~~
+        |                                              add_latent_entropy
+  ./include/linux/random.h:25:46: note: each undeclared identifier is reported only once for each function it appears in
+  make[2]: *** [scripts/Makefile.build:249: arch/powerpc/kernel/prom_init.o] Fehler 1
+  make[1]: *** [scripts/Makefile.build:465: arch/powerpc/kernel] Fehler 2
+  make: *** [Makefile:1855: arch/powerpc] Error 2
+
+Change the DISABLE_LATENT_ENTROPY_PLUGIN flags to undefine
+LATENT_ENTROPY_PLUGIN for files where the plugin is disabled.
+
+Cc: Yury Norov <yury.norov@gmail.com>
+Fixes: 38addce8b600 ("gcc-plugins: Add latent_entropy plugin")
+Link: https://bugzilla.kernel.org/show_bug.cgi?id=216367
+Link: https://lore.kernel.org/linuxppc-dev/alpine.DEB.2.22.394.2208152006320.289321@ramsan.of.borg/
+Reported-by: Erhard Furtner <erhard_f@mailbox.org>
+Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
+Reviewed-by: Yury Norov <yury.norov@gmail.com>
+Signed-off-by: Kees Cook <keescook@chromium.org>
+Link: https://lore.kernel.org/r/20220816051720.44108-1-ajd@linux.ibm.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ scripts/Makefile.gcc-plugins |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/scripts/Makefile.gcc-plugins
++++ b/scripts/Makefile.gcc-plugins
+@@ -6,7 +6,7 @@ gcc-plugin-$(CONFIG_GCC_PLUGIN_LATENT_EN
+ gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY)         \
+               += -DLATENT_ENTROPY_PLUGIN
+ ifdef CONFIG_GCC_PLUGIN_LATENT_ENTROPY
+-    DISABLE_LATENT_ENTROPY_PLUGIN += -fplugin-arg-latent_entropy_plugin-disable
++    DISABLE_LATENT_ENTROPY_PLUGIN += -fplugin-arg-latent_entropy_plugin-disable -ULATENT_ENTROPY_PLUGIN
+ endif
+ export DISABLE_LATENT_ENTROPY_PLUGIN
diff --git a/queue-5.15/i2c-imx-make-sure-to-unregister-adapter-on-remove.patch b/queue-5.15/i2c-imx-make-sure-to-unregister-adapter-on-remove.patch
new file mode 100644 (file)
index 0000000..7b6e0f6
--- /dev/null
@@ -0,0 +1,71 @@
+From d98bdd3a5b50446d8e010be5b04ce81c4eabf728 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de>
+Date: Wed, 20 Jul 2022 17:09:33 +0200
+Subject: i2c: imx: Make sure to unregister adapter on remove()
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
+
+commit d98bdd3a5b50446d8e010be5b04ce81c4eabf728 upstream.
+
+If for whatever reasons pm_runtime_resume_and_get() fails and .remove() is
+exited early, the i2c adapter stays around and the irq still calls its
+handler, while the driver data and the register mapping go away. So if
+later the i2c adapter is accessed or the irq triggers this results in
+havoc accessing freed memory and unmapped registers.
+
+So unregister the software resources even if resume failed, and only skip
+the hardware access in that case.
+
+Fixes: 588eb93ea49f ("i2c: imx: add runtime pm support to improve the performance")
+Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
+Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
+Signed-off-by: Wolfram Sang <wsa@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/i2c/busses/i2c-imx.c |   20 +++++++++++---------
+ 1 file changed, 11 insertions(+), 9 deletions(-)
+
+--- a/drivers/i2c/busses/i2c-imx.c
++++ b/drivers/i2c/busses/i2c-imx.c
+@@ -1487,9 +1487,7 @@ static int i2c_imx_remove(struct platfor
+       struct imx_i2c_struct *i2c_imx = platform_get_drvdata(pdev);
+       int irq, ret;
+-      ret = pm_runtime_resume_and_get(&pdev->dev);
+-      if (ret < 0)
+-              return ret;
++      ret = pm_runtime_get_sync(&pdev->dev);
+       /* remove adapter */
+       dev_dbg(&i2c_imx->adapter.dev, "adapter removed\n");
+@@ -1498,17 +1496,21 @@ static int i2c_imx_remove(struct platfor
+       if (i2c_imx->dma)
+               i2c_imx_dma_free(i2c_imx);
+-      /* setup chip registers to defaults */
+-      imx_i2c_write_reg(0, i2c_imx, IMX_I2C_IADR);
+-      imx_i2c_write_reg(0, i2c_imx, IMX_I2C_IFDR);
+-      imx_i2c_write_reg(0, i2c_imx, IMX_I2C_I2CR);
+-      imx_i2c_write_reg(0, i2c_imx, IMX_I2C_I2SR);
++      if (ret == 0) {
++              /* setup chip registers to defaults */
++              imx_i2c_write_reg(0, i2c_imx, IMX_I2C_IADR);
++              imx_i2c_write_reg(0, i2c_imx, IMX_I2C_IFDR);
++              imx_i2c_write_reg(0, i2c_imx, IMX_I2C_I2CR);
++              imx_i2c_write_reg(0, i2c_imx, IMX_I2C_I2SR);
++              clk_disable(i2c_imx->clk);
++      }
+       clk_notifier_unregister(i2c_imx->clk, &i2c_imx->clk_change_nb);
+       irq = platform_get_irq(pdev, 0);
+       if (irq >= 0)
+               free_irq(irq, i2c_imx);
+-      clk_disable_unprepare(i2c_imx->clk);
++
++      clk_unprepare(i2c_imx->clk);
+       pm_runtime_put_noidle(&pdev->dev);
+       pm_runtime_disable(&pdev->dev);
diff --git a/queue-5.15/i40e-fix-to-stop-tx_timeout-recovery-if-globr-fails.patch b/queue-5.15/i40e-fix-to-stop-tx_timeout-recovery-if-globr-fails.patch
new file mode 100644 (file)
index 0000000..46b4ca3
--- /dev/null
@@ -0,0 +1,42 @@
+From 57c942bc3bef0970f0b21f8e0998e76a900ea80d Mon Sep 17 00:00:00 2001
+From: Alan Brady <alan.brady@intel.com>
+Date: Tue, 2 Aug 2022 10:19:17 +0200
+Subject: i40e: Fix to stop tx_timeout recovery if GLOBR fails
+
+From: Alan Brady <alan.brady@intel.com>
+
+commit 57c942bc3bef0970f0b21f8e0998e76a900ea80d upstream.
+
+When a tx_timeout fires, the PF attempts to recover by incrementally
+resetting.  First we try a PFR, then CORER and finally a GLOBR.  If the
+GLOBR fails, then we keep hitting the tx_timeout and incrementing the
+recovery level and issuing dmesgs, which is both annoying to the user
+and accomplishes nothing.
+
+If the GLOBR fails, then we're pretty much totally hosed, and there's
+not much else we can do to recover, so this makes it such that we just
+kill the VSI and stop hitting the tx_timeout in such a case.
+
+Fixes: 41c445ff0f48 ("i40e: main driver core")
+Signed-off-by: Alan Brady <alan.brady@intel.com>
+Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
+Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
+Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/ethernet/intel/i40e/i40e_main.c |    4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
++++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
+@@ -383,7 +383,9 @@ static void i40e_tx_timeout(struct net_d
+               set_bit(__I40E_GLOBAL_RESET_REQUESTED, pf->state);
+               break;
+       default:
+-              netdev_err(netdev, "tx_timeout recovery unsuccessful\n");
++              netdev_err(netdev, "tx_timeout recovery unsuccessful, device is in non-recoverable state.\n");
++              set_bit(__I40E_DOWN_REQUESTED, pf->state);
++              set_bit(__I40E_VSI_DOWN_REQUESTED, vsi->state);
+               break;
+       }
diff --git a/queue-5.15/ice-ignore-eexist-when-setting-promisc-mode.patch b/queue-5.15/ice-ignore-eexist-when-setting-promisc-mode.patch
new file mode 100644 (file)
index 0000000..98afaac
--- /dev/null
@@ -0,0 +1,38 @@
+From 11e551a2efa4481bd4f616ab75374a2710b480e9 Mon Sep 17 00:00:00 2001
+From: Grzegorz Siwik <grzegorz.siwik@intel.com>
+Date: Fri, 12 Aug 2022 15:25:48 +0200
+Subject: ice: Ignore EEXIST when setting promisc mode
+
+From: Grzegorz Siwik <grzegorz.siwik@intel.com>
+
+commit 11e551a2efa4481bd4f616ab75374a2710b480e9 upstream.
+
+Ignore EEXIST error when setting promiscuous mode.
+This fix is needed because the driver could set promiscuous mode
+when it still has not cleared properly.
+Promiscuous mode could be set only once, so setting it second
+time will be rejected.
+
+Fixes: 5eda8afd6bcc ("ice: Add support for PF/VF promiscuous mode")
+Signed-off-by: Grzegorz Siwik <grzegorz.siwik@intel.com>
+Link: https://lore.kernel.org/all/CAK8fFZ7m-KR57M_rYX6xZN39K89O=LGooYkKsu6HKt0Bs+x6xQ@mail.gmail.com/
+Tested-by: Jaroslav Pulchart <jaroslav.pulchart@gooddata.com>
+Tested-by: Igor Raits <igor@gooddata.com>
+Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
+Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/ethernet/intel/ice/ice_switch.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/net/ethernet/intel/ice/ice_switch.c
++++ b/drivers/net/ethernet/intel/ice/ice_switch.c
+@@ -2614,7 +2614,7 @@ ice_set_vlan_vsi_promisc(struct ice_hw *
+               else
+                       status = ice_set_vsi_promisc(hw, vsi_handle,
+                                                    promisc_mask, vlan_id);
+-              if (status)
++              if (status && status != -EEXIST)
+                       break;
+       }
diff --git a/queue-5.15/igb-add-lock-to-avoid-data-race.patch b/queue-5.15/igb-add-lock-to-avoid-data-race.patch
new file mode 100644 (file)
index 0000000..2e15d33
--- /dev/null
@@ -0,0 +1,126 @@
+From 6faee3d4ee8be0f0367d0c3d826afb3571b7a5e0 Mon Sep 17 00:00:00 2001
+From: Lin Ma <linma@zju.edu.cn>
+Date: Wed, 17 Aug 2022 11:49:21 -0700
+Subject: igb: Add lock to avoid data race
+
+From: Lin Ma <linma@zju.edu.cn>
+
+commit 6faee3d4ee8be0f0367d0c3d826afb3571b7a5e0 upstream.
+
+The commit c23d92b80e0b ("igb: Teardown SR-IOV before
+unregister_netdev()") places the unregister_netdev() call after the
+igb_disable_sriov() call to avoid functionality issue.
+
+However, it introduces several race conditions when detaching a device.
+For example, when .remove() is called, the below interleaving leads to
+use-after-free.
+
+ (FREE from device detaching)      |   (USE from netdev core)
+igb_remove                         |  igb_ndo_get_vf_config
+ igb_disable_sriov                 |  vf >= adapter->vfs_allocated_count?
+  kfree(adapter->vf_data)          |
+  adapter->vfs_allocated_count = 0 |
+                                   |    memcpy(... adapter->vf_data[vf]
+
+Moreover, the igb_disable_sriov() also suffers from data race with the
+requests from VF driver.
+
+ (FREE from device detaching)      |   (USE from requests)
+igb_remove                         |  igb_msix_other
+ igb_disable_sriov                 |   igb_msg_task
+  kfree(adapter->vf_data)          |    vf < adapter->vfs_allocated_count
+  adapter->vfs_allocated_count = 0 |
+
+To this end, this commit first eliminates the data races from netdev
+core by using rtnl_lock (similar to commit 719479230893 ("dpaa2-eth: add
+MAC/PHY support through phylink")). And then adds a spinlock to
+eliminate races from driver requests. (similar to commit 1e53834ce541
+("ixgbe: Add locking to prevent panic when setting sriov_numvfs to zero")
+
+Fixes: c23d92b80e0b ("igb: Teardown SR-IOV before unregister_netdev()")
+Signed-off-by: Lin Ma <linma@zju.edu.cn>
+Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com>
+Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
+Link: https://lore.kernel.org/r/20220817184921.735244-1-anthony.l.nguyen@intel.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/ethernet/intel/igb/igb.h      |    2 ++
+ drivers/net/ethernet/intel/igb/igb_main.c |   12 +++++++++++-
+ 2 files changed, 13 insertions(+), 1 deletion(-)
+
+--- a/drivers/net/ethernet/intel/igb/igb.h
++++ b/drivers/net/ethernet/intel/igb/igb.h
+@@ -664,6 +664,8 @@ struct igb_adapter {
+       struct igb_mac_addr *mac_table;
+       struct vf_mac_filter vf_macs;
+       struct vf_mac_filter *vf_mac_list;
++      /* lock for VF resources */
++      spinlock_t vfs_lock;
+ };
+ /* flags controlling PTP/1588 function */
+--- a/drivers/net/ethernet/intel/igb/igb_main.c
++++ b/drivers/net/ethernet/intel/igb/igb_main.c
+@@ -3637,6 +3637,7 @@ static int igb_disable_sriov(struct pci_
+       struct net_device *netdev = pci_get_drvdata(pdev);
+       struct igb_adapter *adapter = netdev_priv(netdev);
+       struct e1000_hw *hw = &adapter->hw;
++      unsigned long flags;
+       /* reclaim resources allocated to VFs */
+       if (adapter->vf_data) {
+@@ -3649,12 +3650,13 @@ static int igb_disable_sriov(struct pci_
+                       pci_disable_sriov(pdev);
+                       msleep(500);
+               }
+-
++              spin_lock_irqsave(&adapter->vfs_lock, flags);
+               kfree(adapter->vf_mac_list);
+               adapter->vf_mac_list = NULL;
+               kfree(adapter->vf_data);
+               adapter->vf_data = NULL;
+               adapter->vfs_allocated_count = 0;
++              spin_unlock_irqrestore(&adapter->vfs_lock, flags);
+               wr32(E1000_IOVCTL, E1000_IOVCTL_REUSE_VFQ);
+               wrfl();
+               msleep(100);
+@@ -3814,7 +3816,9 @@ static void igb_remove(struct pci_dev *p
+       igb_release_hw_control(adapter);
+ #ifdef CONFIG_PCI_IOV
++      rtnl_lock();
+       igb_disable_sriov(pdev);
++      rtnl_unlock();
+ #endif
+       unregister_netdev(netdev);
+@@ -3974,6 +3978,9 @@ static int igb_sw_init(struct igb_adapte
+       spin_lock_init(&adapter->nfc_lock);
+       spin_lock_init(&adapter->stats64_lock);
++
++      /* init spinlock to avoid concurrency of VF resources */
++      spin_lock_init(&adapter->vfs_lock);
+ #ifdef CONFIG_PCI_IOV
+       switch (hw->mac.type) {
+       case e1000_82576:
+@@ -7846,8 +7853,10 @@ unlock:
+ static void igb_msg_task(struct igb_adapter *adapter)
+ {
+       struct e1000_hw *hw = &adapter->hw;
++      unsigned long flags;
+       u32 vf;
++      spin_lock_irqsave(&adapter->vfs_lock, flags);
+       for (vf = 0; vf < adapter->vfs_allocated_count; vf++) {
+               /* process any reset requests */
+               if (!igb_check_for_rst(hw, vf))
+@@ -7861,6 +7870,7 @@ static void igb_msg_task(struct igb_adap
+               if (!igb_check_for_ack(hw, vf))
+                       igb_rcv_ack_from_vf(adapter, vf);
+       }
++      spin_unlock_irqrestore(&adapter->vfs_lock, flags);
+ }
+ /**
diff --git a/queue-5.15/kbuild-fix-the-modules-order-between-drivers-and-libs.patch b/queue-5.15/kbuild-fix-the-modules-order-between-drivers-and-libs.patch
new file mode 100644 (file)
index 0000000..3cfb171
--- /dev/null
@@ -0,0 +1,48 @@
+From 113147510b48e764e624e3d0e6707a1e48bc05a9 Mon Sep 17 00:00:00 2001
+From: Masahiro Yamada <masahiroy@kernel.org>
+Date: Sun, 14 Aug 2022 08:09:28 +0900
+Subject: kbuild: fix the modules order between drivers and libs
+
+From: Masahiro Yamada <masahiroy@kernel.org>
+
+commit 113147510b48e764e624e3d0e6707a1e48bc05a9 upstream.
+
+Commit b2c885549122 ("kbuild: update modules.order only when contained
+modules are updated") accidentally changed the modules order.
+
+Prior to that commit, the modules order was determined based on
+vmlinux-dirs, which lists core-y/m, drivers-y/m, libs-y/m, in this order.
+
+Now, subdir-modorder lists them in a different order: core-y/m, libs-y/m,
+drivers-y/m.
+
+Presumably, there was no practical issue because the modules in drivers
+and libs are orthogonal, but there is no reason to have this distortion.
+
+Get back to the original order.
+
+Fixes: b2c885549122 ("kbuild: update modules.order only when contained modules are updated")
+Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Makefile |    6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+--- a/Makefile
++++ b/Makefile
+@@ -1155,13 +1155,11 @@ vmlinux-alldirs        := $(sort $(vmlinux-dirs
+                    $(patsubst %/,%,$(filter %/, $(core-) \
+                       $(drivers-) $(libs-))))
+-subdir-modorder := $(addsuffix modules.order,$(filter %/, \
+-                      $(core-y) $(core-m) $(libs-y) $(libs-m) \
+-                      $(drivers-y) $(drivers-m)))
+-
+ build-dirs    := $(vmlinux-dirs)
+ clean-dirs    := $(vmlinux-alldirs)
++subdir-modorder := $(addsuffix /modules.order, $(build-dirs))
++
+ # Externally visible symbols (used by link-vmlinux.sh)
+ KBUILD_VMLINUX_OBJS := $(head-y) $(patsubst %/,%/built-in.a, $(core-y))
+ KBUILD_VMLINUX_OBJS += $(addsuffix built-in.a, $(filter %/, $(libs-y)))
diff --git a/queue-5.15/mlxsw-spectrum-clear-ptp-configuration-after-unregistering-the-netdevice.patch b/queue-5.15/mlxsw-spectrum-clear-ptp-configuration-after-unregistering-the-netdevice.patch
new file mode 100644 (file)
index 0000000..36dec33
--- /dev/null
@@ -0,0 +1,41 @@
+From a159e986ad26d3f35c0157ac92760ba5e44e6785 Mon Sep 17 00:00:00 2001
+From: Amit Cohen <amcohen@nvidia.com>
+Date: Fri, 12 Aug 2022 17:32:01 +0200
+Subject: mlxsw: spectrum: Clear PTP configuration after unregistering the netdevice
+
+From: Amit Cohen <amcohen@nvidia.com>
+
+commit a159e986ad26d3f35c0157ac92760ba5e44e6785 upstream.
+
+Currently as part of removing port, PTP API is called to clear the
+existing configuration and set the 'rx_filter' and 'tx_type' to zero.
+The clearing is done before unregistering the netdevice, which means that
+there is a window of time in which the user can reconfigure PTP in the
+port, and this configuration will not be cleared.
+
+Reorder the operations, clear PTP configuration after unregistering the
+netdevice.
+
+Fixes: 8748642751ede ("mlxsw: spectrum: PTP: Support SIOCGHWTSTAMP, SIOCSHWTSTAMP ioctls")
+Signed-off-by: Amit Cohen <amcohen@nvidia.com>
+Signed-off-by: Ido Schimmel <idosch@nvidia.com>
+Signed-off-by: Petr Machata <petrm@nvidia.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/ethernet/mellanox/mlxsw/spectrum.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
++++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+@@ -1730,9 +1730,9 @@ static void mlxsw_sp_port_remove(struct
+       cancel_delayed_work_sync(&mlxsw_sp_port->periodic_hw_stats.update_dw);
+       cancel_delayed_work_sync(&mlxsw_sp_port->ptp.shaper_dw);
+-      mlxsw_sp_port_ptp_clear(mlxsw_sp_port);
+       mlxsw_core_port_clear(mlxsw_sp->core, local_port, mlxsw_sp);
+       unregister_netdev(mlxsw_sp_port->dev); /* This calls ndo_stop */
++      mlxsw_sp_port_ptp_clear(mlxsw_sp_port);
+       mlxsw_sp_port_vlan_classification_set(mlxsw_sp_port, true, true);
+       mlxsw_sp->ports[local_port] = NULL;
+       mlxsw_sp_port_vlan_flush(mlxsw_sp_port, true);
diff --git a/queue-5.15/net-dsa-don-t-warn-in-dsa_port_set_state_now-when-driver-doesn-t-support-it.patch b/queue-5.15/net-dsa-don-t-warn-in-dsa_port_set_state_now-when-driver-doesn-t-support-it.patch
new file mode 100644 (file)
index 0000000..de7be7a
--- /dev/null
@@ -0,0 +1,48 @@
+From 211987f3ac734000ea1548784b2a4539a974fbc8 Mon Sep 17 00:00:00 2001
+From: Vladimir Oltean <vladimir.oltean@nxp.com>
+Date: Tue, 16 Aug 2022 23:14:45 +0300
+Subject: net: dsa: don't warn in dsa_port_set_state_now() when driver doesn't support it
+
+From: Vladimir Oltean <vladimir.oltean@nxp.com>
+
+commit 211987f3ac734000ea1548784b2a4539a974fbc8 upstream.
+
+ds->ops->port_stp_state_set() is, like most DSA methods, optional, and
+if absent, the port is supposed to remain in the forwarding state (as
+standalone). Such is the case with the mv88e6060 driver, which does not
+offload the bridge layer. DSA warns that the STP state can't be changed
+to FORWARDING as part of dsa_port_enable_rt(), when in fact it should not.
+
+The error message is also not up to modern standards, so take the
+opportunity to make it more descriptive.
+
+Fixes: fd3645413197 ("net: dsa: change scope of STP state setter")
+Reported-by: Sergei Antonov <saproj@gmail.com>
+Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
+Reviewed-by: Sergei Antonov <saproj@gmail.com>
+Link: https://lore.kernel.org/r/20220816201445.1809483-1-vladimir.oltean@nxp.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/dsa/port.c |    7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+--- a/net/dsa/port.c
++++ b/net/dsa/port.c
+@@ -111,11 +111,14 @@ int dsa_port_set_state(struct dsa_port *
+ static void dsa_port_set_state_now(struct dsa_port *dp, u8 state,
+                                  bool do_fast_age)
+ {
++      struct dsa_switch *ds = dp->ds;
+       int err;
+       err = dsa_port_set_state(dp, state, do_fast_age);
+-      if (err)
+-              pr_err("DSA: failed to set STP state %u (%d)\n", state, err);
++      if (err && err != -EOPNOTSUPP) {
++              dev_err(ds->dev, "port %d failed to set STP state %u: %pe\n",
++                      dp->index, state, ERR_PTR(err));
++      }
+ }
+ int dsa_port_enable_rt(struct dsa_port *dp, struct phy_device *phy)
diff --git a/queue-5.15/net-dsa-felix-fix-ethtool-256-511-and-512-1023-tx-packet-counters.patch b/queue-5.15/net-dsa-felix-fix-ethtool-256-511-and-512-1023-tx-packet-counters.patch
new file mode 100644 (file)
index 0000000..fa0464d
--- /dev/null
@@ -0,0 +1,32 @@
+From 40d21c4565bce064c73a03b79a157a3493c518b9 Mon Sep 17 00:00:00 2001
+From: Vladimir Oltean <vladimir.oltean@nxp.com>
+Date: Tue, 16 Aug 2022 16:53:45 +0300
+Subject: net: dsa: felix: fix ethtool 256-511 and 512-1023 TX packet counters
+
+From: Vladimir Oltean <vladimir.oltean@nxp.com>
+
+commit 40d21c4565bce064c73a03b79a157a3493c518b9 upstream.
+
+What the driver actually reports as 256-511 is in fact 512-1023, and the
+TX packets in the 256-511 bucket are not reported. Fix that.
+
+Fixes: 56051948773e ("net: dsa: ocelot: add driver for Felix switch family")
+Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/dsa/ocelot/felix_vsc9959.c |    3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/drivers/net/dsa/ocelot/felix_vsc9959.c
++++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
+@@ -578,7 +578,8 @@ static const struct ocelot_stat_layout v
+       { .offset = 0x87,       .name = "tx_frames_below_65_octets", },
+       { .offset = 0x88,       .name = "tx_frames_65_to_127_octets", },
+       { .offset = 0x89,       .name = "tx_frames_128_255_octets", },
+-      { .offset = 0x8B,       .name = "tx_frames_256_511_octets", },
++      { .offset = 0x8A,       .name = "tx_frames_256_511_octets", },
++      { .offset = 0x8B,       .name = "tx_frames_512_1023_octets", },
+       { .offset = 0x8C,       .name = "tx_frames_1024_1526_octets", },
+       { .offset = 0x8D,       .name = "tx_frames_over_1526_octets", },
+       { .offset = 0x8E,       .name = "tx_yellow_prio_0", },
diff --git a/queue-5.15/net-dsa-microchip-ksz9477-fix-fdb_dump-last-invalid-entry.patch b/queue-5.15/net-dsa-microchip-ksz9477-fix-fdb_dump-last-invalid-entry.patch
new file mode 100644 (file)
index 0000000..0d66744
--- /dev/null
@@ -0,0 +1,41 @@
+From 36c0d935015766bf20d621c18313f17691bda5e3 Mon Sep 17 00:00:00 2001
+From: Arun Ramadoss <arun.ramadoss@microchip.com>
+Date: Tue, 16 Aug 2022 16:25:16 +0530
+Subject: net: dsa: microchip: ksz9477: fix fdb_dump last invalid entry
+
+From: Arun Ramadoss <arun.ramadoss@microchip.com>
+
+commit 36c0d935015766bf20d621c18313f17691bda5e3 upstream.
+
+In the ksz9477_fdb_dump function it reads the ALU control register and
+exit from the timeout loop if there is valid entry or search is
+complete. After exiting the loop, it reads the alu entry and report to
+the user space irrespective of entry is valid. It works till the valid
+entry. If the loop exited when search is complete, it reads the alu
+table. The table returns all ones and it is reported to user space. So
+bridge fdb show gives ff:ff:ff:ff:ff:ff as last entry for every port.
+To fix it, after exiting the loop the entry is reported only if it is
+valid one.
+
+Fixes: b987e98e50ab ("dsa: add DSA switch driver for Microchip KSZ9477")
+Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com>
+Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
+Link: https://lore.kernel.org/r/20220816105516.18350-1-arun.ramadoss@microchip.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/dsa/microchip/ksz9477.c |    3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/drivers/net/dsa/microchip/ksz9477.c
++++ b/drivers/net/dsa/microchip/ksz9477.c
+@@ -759,6 +759,9 @@ static int ksz9477_port_fdb_dump(struct
+                       goto exit;
+               }
++              if (!(ksz_data & ALU_VALID))
++                      continue;
++
+               /* read ALU table */
+               ksz9477_read_table(dev, alu_table);
diff --git a/queue-5.15/net-dsa-mv88e6060-prevent-crash-on-an-unused-port.patch b/queue-5.15/net-dsa-mv88e6060-prevent-crash-on-an-unused-port.patch
new file mode 100644 (file)
index 0000000..e0cda12
--- /dev/null
@@ -0,0 +1,53 @@
+From 246bbf2f977ea36aaf41f5d24370fef433250728 Mon Sep 17 00:00:00 2001
+From: Sergei Antonov <saproj@gmail.com>
+Date: Thu, 11 Aug 2022 10:09:39 +0300
+Subject: net: dsa: mv88e6060: prevent crash on an unused port
+
+From: Sergei Antonov <saproj@gmail.com>
+
+commit 246bbf2f977ea36aaf41f5d24370fef433250728 upstream.
+
+If the port isn't a CPU port nor a user port, 'cpu_dp'
+is a null pointer and a crash happened on dereferencing
+it in mv88e6060_setup_port():
+
+[    9.575872] Unable to handle kernel NULL pointer dereference at virtual address 00000014
+...
+[    9.942216]  mv88e6060_setup from dsa_register_switch+0x814/0xe84
+[    9.948616]  dsa_register_switch from mdio_probe+0x2c/0x54
+[    9.954433]  mdio_probe from really_probe.part.0+0x98/0x2a0
+[    9.960375]  really_probe.part.0 from driver_probe_device+0x30/0x10c
+[    9.967029]  driver_probe_device from __device_attach_driver+0xb8/0x13c
+[    9.973946]  __device_attach_driver from bus_for_each_drv+0x90/0xe0
+[    9.980509]  bus_for_each_drv from __device_attach+0x110/0x184
+[    9.986632]  __device_attach from bus_probe_device+0x8c/0x94
+[    9.992577]  bus_probe_device from deferred_probe_work_func+0x78/0xa8
+[    9.999311]  deferred_probe_work_func from process_one_work+0x290/0x73c
+[   10.006292]  process_one_work from worker_thread+0x30/0x4b8
+[   10.012155]  worker_thread from kthread+0xd4/0x10c
+[   10.017238]  kthread from ret_from_fork+0x14/0x3c
+
+Fixes: 0abfd494deef ("net: dsa: use dedicated CPU port")
+CC: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
+CC: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Sergei Antonov <saproj@gmail.com>
+Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
+Link: https://lore.kernel.org/r/20220811070939.1717146-1-saproj@gmail.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/dsa/mv88e6060.c |    3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/drivers/net/dsa/mv88e6060.c
++++ b/drivers/net/dsa/mv88e6060.c
+@@ -118,6 +118,9 @@ static int mv88e6060_setup_port(struct m
+       int addr = REG_PORT(p);
+       int ret;
++      if (dsa_is_unused_port(priv->ds, p))
++              return 0;
++
+       /* Do not force flow control, disable Ingress and Egress
+        * Header tagging, disable VLAN tunneling, and set the port
+        * state to Forwarding.  Additionally, if this is the CPU
diff --git a/queue-5.15/net-dsa-sja1105-fix-buffer-overflow-in-sja1105_setup_devlink_regions.patch b/queue-5.15/net-dsa-sja1105-fix-buffer-overflow-in-sja1105_setup_devlink_regions.patch
new file mode 100644 (file)
index 0000000..5be9063
--- /dev/null
@@ -0,0 +1,34 @@
+From fd8e899cdb5ecaf8e8ee73854a99e10807eef1de Mon Sep 17 00:00:00 2001
+From: Rustam Subkhankulov <subkhankulov@ispras.ru>
+Date: Wed, 17 Aug 2022 03:38:45 +0300
+Subject: net: dsa: sja1105: fix buffer overflow in sja1105_setup_devlink_regions()
+
+From: Rustam Subkhankulov <subkhankulov@ispras.ru>
+
+commit fd8e899cdb5ecaf8e8ee73854a99e10807eef1de upstream.
+
+If an error occurs in dsa_devlink_region_create(), then 'priv->regions'
+array will be accessed by negative index '-1'.
+
+Found by Linux Verification Center (linuxtesting.org) with SVACE.
+
+Signed-off-by: Rustam Subkhankulov <subkhankulov@ispras.ru>
+Fixes: bf425b82059e ("net: dsa: sja1105: expose static config as devlink region")
+Link: https://lore.kernel.org/r/20220817003845.389644-1-subkhankulov@ispras.ru
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/dsa/sja1105/sja1105_devlink.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/net/dsa/sja1105/sja1105_devlink.c
++++ b/drivers/net/dsa/sja1105/sja1105_devlink.c
+@@ -93,7 +93,7 @@ static int sja1105_setup_devlink_regions
+               region = dsa_devlink_region_create(ds, ops, 1, size);
+               if (IS_ERR(region)) {
+-                      while (i-- >= 0)
++                      while (--i >= 0)
+                               dsa_devlink_region_destroy(priv->regions[i]);
+                       return PTR_ERR(region);
+               }
diff --git a/queue-5.15/net-fix-potential-refcount-leak-in-ndisc_router_discovery.patch b/queue-5.15/net-fix-potential-refcount-leak-in-ndisc_router_discovery.patch
new file mode 100644 (file)
index 0000000..9a9228b
--- /dev/null
@@ -0,0 +1,40 @@
+From 7396ba87f1edf549284869451665c7c4e74ecd4f Mon Sep 17 00:00:00 2001
+From: Xin Xiong <xiongx18@fudan.edu.cn>
+Date: Sat, 13 Aug 2022 20:49:08 +0800
+Subject: net: fix potential refcount leak in ndisc_router_discovery()
+
+From: Xin Xiong <xiongx18@fudan.edu.cn>
+
+commit 7396ba87f1edf549284869451665c7c4e74ecd4f upstream.
+
+The issue happens on specific paths in the function. After both the
+object `rt` and `neigh` are grabbed successfully, when `lifetime` is
+nonzero but the metric needs change, the function just deletes the
+route and set `rt` to NULL. Then, it may try grabbing `rt` and `neigh`
+again if above conditions hold. The function simply overwrite `neigh`
+if succeeds or returns if fails, without decreasing the reference
+count of previous `neigh`. This may result in memory leaks.
+
+Fix it by decrementing the reference count of `neigh` in place.
+
+Fixes: 6b2e04bc240f ("net: allow user to set metric on default route learned via Router Advertisement")
+Signed-off-by: Xin Xiong <xiongx18@fudan.edu.cn>
+Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/ipv6/ndisc.c |    3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/net/ipv6/ndisc.c
++++ b/net/ipv6/ndisc.c
+@@ -1317,6 +1317,9 @@ static void ndisc_router_discovery(struc
+       if (!rt && lifetime) {
+               ND_PRINTK(3, info, "RA: adding default router\n");
++              if (neigh)
++                      neigh_release(neigh);
++
+               rt = rt6_add_dflt_router(net, &ipv6_hdr(skb)->saddr,
+                                        skb->dev, pref, defrtr_usr_metric);
+               if (!rt) {
diff --git a/queue-5.15/net-genl-fix-error-path-memory-leak-in-policy-dumping.patch b/queue-5.15/net-genl-fix-error-path-memory-leak-in-policy-dumping.patch
new file mode 100644 (file)
index 0000000..fc0f834
--- /dev/null
@@ -0,0 +1,84 @@
+From 249801360db3dec4f73768c502192020bfddeacc Mon Sep 17 00:00:00 2001
+From: Jakub Kicinski <kuba@kernel.org>
+Date: Tue, 16 Aug 2022 09:19:39 -0700
+Subject: net: genl: fix error path memory leak in policy dumping
+
+From: Jakub Kicinski <kuba@kernel.org>
+
+commit 249801360db3dec4f73768c502192020bfddeacc upstream.
+
+If construction of the array of policies fails when recording
+non-first policy we need to unwind.
+
+netlink_policy_dump_add_policy() itself also needs fixing as
+it currently gives up on error without recording the allocated
+pointer in the pstate pointer.
+
+Reported-by: syzbot+dc54d9ba8153b216cae0@syzkaller.appspotmail.com
+Fixes: 50a896cf2d6f ("genetlink: properly support per-op policy dumping")
+Link: https://lore.kernel.org/r/20220816161939.577583-1-kuba@kernel.org
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/netlink/genetlink.c |    6 +++++-
+ net/netlink/policy.c    |   14 ++++++++++++--
+ 2 files changed, 17 insertions(+), 3 deletions(-)
+
+--- a/net/netlink/genetlink.c
++++ b/net/netlink/genetlink.c
+@@ -1174,13 +1174,17 @@ static int ctrl_dumppolicy_start(struct
+                                                            op.policy,
+                                                            op.maxattr);
+                       if (err)
+-                              return err;
++                              goto err_free_state;
+               }
+       }
+       if (!ctx->state)
+               return -ENODATA;
+       return 0;
++
++err_free_state:
++      netlink_policy_dump_free(ctx->state);
++      return err;
+ }
+ static void *ctrl_dumppolicy_prep(struct sk_buff *skb,
+--- a/net/netlink/policy.c
++++ b/net/netlink/policy.c
+@@ -144,7 +144,7 @@ int netlink_policy_dump_add_policy(struc
+       err = add_policy(&state, policy, maxtype);
+       if (err)
+-              return err;
++              goto err_try_undo;
+       for (policy_idx = 0;
+            policy_idx < state->n_alloc && state->policies[policy_idx].policy;
+@@ -164,7 +164,7 @@ int netlink_policy_dump_add_policy(struc
+                                                policy[type].nested_policy,
+                                                policy[type].len);
+                               if (err)
+-                                      return err;
++                                      goto err_try_undo;
+                               break;
+                       default:
+                               break;
+@@ -174,6 +174,16 @@ int netlink_policy_dump_add_policy(struc
+       *pstate = state;
+       return 0;
++
++err_try_undo:
++      /* Try to preserve reasonable unwind semantics - if we're starting from
++       * scratch clean up fully, otherwise record what we got and caller will.
++       */
++      if (!*pstate)
++              netlink_policy_dump_free(state);
++      else
++              *pstate = state;
++      return err;
+ }
+ static bool
diff --git a/queue-5.15/net-moxa-pass-pdev-instead-of-ndev-to-dma-functions.patch b/queue-5.15/net-moxa-pass-pdev-instead-of-ndev-to-dma-functions.patch
new file mode 100644 (file)
index 0000000..cb5812b
--- /dev/null
@@ -0,0 +1,111 @@
+From 3a12df22a8f68954a4ba48435c06b3d1791c87c4 Mon Sep 17 00:00:00 2001
+From: Sergei Antonov <saproj@gmail.com>
+Date: Fri, 12 Aug 2022 20:13:39 +0300
+Subject: net: moxa: pass pdev instead of ndev to DMA functions
+
+From: Sergei Antonov <saproj@gmail.com>
+
+commit 3a12df22a8f68954a4ba48435c06b3d1791c87c4 upstream.
+
+dma_map_single() calls fail in moxart_mac_setup_desc_ring() and
+moxart_mac_start_xmit() which leads to an incessant output of this:
+
+[   16.043925] moxart-ethernet 92000000.mac eth0: DMA mapping error
+[   16.050957] moxart-ethernet 92000000.mac eth0: DMA mapping error
+[   16.058229] moxart-ethernet 92000000.mac eth0: DMA mapping error
+
+Passing pdev to DMA is a common approach among net drivers.
+
+Fixes: 6c821bd9edc9 ("net: Add MOXA ART SoCs ethernet driver")
+Signed-off-by: Sergei Antonov <saproj@gmail.com>
+Suggested-by: Andrew Lunn <andrew@lunn.ch>
+Reviewed-by: Andrew Lunn <andrew@lunn.ch>
+Link: https://lore.kernel.org/r/20220812171339.2271788-1-saproj@gmail.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/ethernet/moxa/moxart_ether.c |   20 ++++++++++----------
+ 1 file changed, 10 insertions(+), 10 deletions(-)
+
+--- a/drivers/net/ethernet/moxa/moxart_ether.c
++++ b/drivers/net/ethernet/moxa/moxart_ether.c
+@@ -77,7 +77,7 @@ static void moxart_mac_free_memory(struc
+       int i;
+       for (i = 0; i < RX_DESC_NUM; i++)
+-              dma_unmap_single(&ndev->dev, priv->rx_mapping[i],
++              dma_unmap_single(&priv->pdev->dev, priv->rx_mapping[i],
+                                priv->rx_buf_size, DMA_FROM_DEVICE);
+       if (priv->tx_desc_base)
+@@ -147,11 +147,11 @@ static void moxart_mac_setup_desc_ring(s
+                      desc + RX_REG_OFFSET_DESC1);
+               priv->rx_buf[i] = priv->rx_buf_base + priv->rx_buf_size * i;
+-              priv->rx_mapping[i] = dma_map_single(&ndev->dev,
++              priv->rx_mapping[i] = dma_map_single(&priv->pdev->dev,
+                                                    priv->rx_buf[i],
+                                                    priv->rx_buf_size,
+                                                    DMA_FROM_DEVICE);
+-              if (dma_mapping_error(&ndev->dev, priv->rx_mapping[i]))
++              if (dma_mapping_error(&priv->pdev->dev, priv->rx_mapping[i]))
+                       netdev_err(ndev, "DMA mapping error\n");
+               moxart_desc_write(priv->rx_mapping[i],
+@@ -240,7 +240,7 @@ static int moxart_rx_poll(struct napi_st
+               if (len > RX_BUF_SIZE)
+                       len = RX_BUF_SIZE;
+-              dma_sync_single_for_cpu(&ndev->dev,
++              dma_sync_single_for_cpu(&priv->pdev->dev,
+                                       priv->rx_mapping[rx_head],
+                                       priv->rx_buf_size, DMA_FROM_DEVICE);
+               skb = netdev_alloc_skb_ip_align(ndev, len);
+@@ -294,7 +294,7 @@ static void moxart_tx_finished(struct ne
+       unsigned int tx_tail = priv->tx_tail;
+       while (tx_tail != tx_head) {
+-              dma_unmap_single(&ndev->dev, priv->tx_mapping[tx_tail],
++              dma_unmap_single(&priv->pdev->dev, priv->tx_mapping[tx_tail],
+                                priv->tx_len[tx_tail], DMA_TO_DEVICE);
+               ndev->stats.tx_packets++;
+@@ -358,9 +358,9 @@ static netdev_tx_t moxart_mac_start_xmit
+       len = skb->len > TX_BUF_SIZE ? TX_BUF_SIZE : skb->len;
+-      priv->tx_mapping[tx_head] = dma_map_single(&ndev->dev, skb->data,
++      priv->tx_mapping[tx_head] = dma_map_single(&priv->pdev->dev, skb->data,
+                                                  len, DMA_TO_DEVICE);
+-      if (dma_mapping_error(&ndev->dev, priv->tx_mapping[tx_head])) {
++      if (dma_mapping_error(&priv->pdev->dev, priv->tx_mapping[tx_head])) {
+               netdev_err(ndev, "DMA mapping error\n");
+               goto out_unlock;
+       }
+@@ -379,7 +379,7 @@ static netdev_tx_t moxart_mac_start_xmit
+               len = ETH_ZLEN;
+       }
+-      dma_sync_single_for_device(&ndev->dev, priv->tx_mapping[tx_head],
++      dma_sync_single_for_device(&priv->pdev->dev, priv->tx_mapping[tx_head],
+                                  priv->tx_buf_size, DMA_TO_DEVICE);
+       txdes1 = TX_DESC1_LTS | TX_DESC1_FTS | (len & TX_DESC1_BUF_SIZE_MASK);
+@@ -493,7 +493,7 @@ static int moxart_mac_probe(struct platf
+       priv->tx_buf_size = TX_BUF_SIZE;
+       priv->rx_buf_size = RX_BUF_SIZE;
+-      priv->tx_desc_base = dma_alloc_coherent(&pdev->dev, TX_REG_DESC_SIZE *
++      priv->tx_desc_base = dma_alloc_coherent(p_dev, TX_REG_DESC_SIZE *
+                                               TX_DESC_NUM, &priv->tx_base,
+                                               GFP_DMA | GFP_KERNEL);
+       if (!priv->tx_desc_base) {
+@@ -501,7 +501,7 @@ static int moxart_mac_probe(struct platf
+               goto init_fail;
+       }
+-      priv->rx_desc_base = dma_alloc_coherent(&pdev->dev, RX_REG_DESC_SIZE *
++      priv->rx_desc_base = dma_alloc_coherent(p_dev, RX_REG_DESC_SIZE *
+                                               RX_DESC_NUM, &priv->rx_base,
+                                               GFP_DMA | GFP_KERNEL);
+       if (!priv->rx_desc_base) {
diff --git a/queue-5.15/net-sunrpc-fix-potential-memory-leaks-in-rpc_sysfs_xprt_state_change.patch b/queue-5.15/net-sunrpc-fix-potential-memory-leaks-in-rpc_sysfs_xprt_state_change.patch
new file mode 100644 (file)
index 0000000..868de9b
--- /dev/null
@@ -0,0 +1,43 @@
+From bfc48f1b0505ffcb03a6d749139b7577d6b81ae0 Mon Sep 17 00:00:00 2001
+From: Xin Xiong <xiongx18@fudan.edu.cn>
+Date: Wed, 10 Aug 2022 23:29:13 +0800
+Subject: net/sunrpc: fix potential memory leaks in rpc_sysfs_xprt_state_change()
+
+From: Xin Xiong <xiongx18@fudan.edu.cn>
+
+commit bfc48f1b0505ffcb03a6d749139b7577d6b81ae0 upstream.
+
+The issue happens on some error handling paths. When the function
+fails to grab the object `xprt`, it simply returns 0, forgetting to
+decrease the reference count of another object `xps`, which is
+increased by rpc_sysfs_xprt_kobj_get_xprt_switch(), causing refcount
+leaks. Also, the function forgets to check whether `xps` is valid
+before using it, which may result in NULL-dereferencing issues.
+
+Fix it by adding proper error handling code when either `xprt` or
+`xps` is NULL.
+
+Fixes: 5b7eb78486cd ("SUNRPC: take a xprt offline using sysfs")
+Signed-off-by: Xin Xiong <xiongx18@fudan.edu.cn>
+Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/sunrpc/sysfs.c |    6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+--- a/net/sunrpc/sysfs.c
++++ b/net/sunrpc/sysfs.c
+@@ -282,8 +282,10 @@ static ssize_t rpc_sysfs_xprt_state_chan
+       int offline = 0, online = 0, remove = 0;
+       struct rpc_xprt_switch *xps = rpc_sysfs_xprt_kobj_get_xprt_switch(kobj);
+-      if (!xprt)
+-              return 0;
++      if (!xprt || !xps) {
++              count = 0;
++              goto out_put;
++      }
+       if (!strncmp(buf, "offline", 7))
+               offline = 1;
diff --git a/queue-5.15/netfilter-nf_tables-check-nft_set_concat-flag-if-field_count-is-specified.patch b/queue-5.15/netfilter-nf_tables-check-nft_set_concat-flag-if-field_count-is-specified.patch
new file mode 100644 (file)
index 0000000..db7113d
--- /dev/null
@@ -0,0 +1,40 @@
+From 1b6345d4160ecd3d04bd8cd75df90c67811e8cc9 Mon Sep 17 00:00:00 2001
+From: Pablo Neira Ayuso <pablo@netfilter.org>
+Date: Mon, 15 Aug 2022 17:55:07 +0200
+Subject: netfilter: nf_tables: check NFT_SET_CONCAT flag if field_count is specified
+
+From: Pablo Neira Ayuso <pablo@netfilter.org>
+
+commit 1b6345d4160ecd3d04bd8cd75df90c67811e8cc9 upstream.
+
+Since f3a2181e16f1 ("netfilter: nf_tables: Support for sets with
+multiple ranged fields"), it possible to combine intervals and
+concatenations. Later on, ef516e8625dd ("netfilter: nf_tables:
+reintroduce the NFT_SET_CONCAT flag") provides the NFT_SET_CONCAT flag
+for userspace to report that the set stores a concatenation.
+
+Make sure NFT_SET_CONCAT is set on if field_count is specified for
+consistency. Otherwise, if NFT_SET_CONCAT is specified with no
+field_count, bail out with EINVAL.
+
+Fixes: ef516e8625dd ("netfilter: nf_tables: reintroduce the NFT_SET_CONCAT flag")
+Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/netfilter/nf_tables_api.c |    5 +++++
+ 1 file changed, 5 insertions(+)
+
+--- a/net/netfilter/nf_tables_api.c
++++ b/net/netfilter/nf_tables_api.c
+@@ -4354,6 +4354,11 @@ static int nf_tables_newset(struct sk_bu
+               err = nf_tables_set_desc_parse(&desc, nla[NFTA_SET_DESC]);
+               if (err < 0)
+                       return err;
++
++              if (desc.field_count > 1 && !(flags & NFT_SET_CONCAT))
++                      return -EINVAL;
++      } else if (flags & NFT_SET_CONCAT) {
++              return -EINVAL;
+       }
+       if (nla[NFTA_SET_EXPR] || nla[NFTA_SET_EXPRESSIONS])
diff --git a/queue-5.15/netfilter-nf_tables-disallow-nft_set_elem_catchall-and-nft_set_elem_interval_end.patch b/queue-5.15/netfilter-nf_tables-disallow-nft_set_elem_catchall-and-nft_set_elem_interval_end.patch
new file mode 100644 (file)
index 0000000..aa89d89
--- /dev/null
@@ -0,0 +1,30 @@
+From fc0ae524b5fd2938c94d56da3f749f11eb3273d5 Mon Sep 17 00:00:00 2001
+From: Pablo Neira Ayuso <pablo@netfilter.org>
+Date: Sat, 13 Aug 2022 15:22:05 +0200
+Subject: netfilter: nf_tables: disallow NFT_SET_ELEM_CATCHALL and NFT_SET_ELEM_INTERVAL_END
+
+From: Pablo Neira Ayuso <pablo@netfilter.org>
+
+commit fc0ae524b5fd2938c94d56da3f749f11eb3273d5 upstream.
+
+These flags are mutually exclusive, report EINVAL in this case.
+
+Fixes: aaa31047a6d2 ("netfilter: nftables: add catch-all set element support")
+Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/netfilter/nf_tables_api.c |    3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/net/netfilter/nf_tables_api.c
++++ b/net/netfilter/nf_tables_api.c
+@@ -5101,6 +5101,9 @@ static int nft_setelem_parse_flags(const
+       if (!(set->flags & NFT_SET_INTERVAL) &&
+           *flags & NFT_SET_ELEM_INTERVAL_END)
+               return -EINVAL;
++      if ((*flags & (NFT_SET_ELEM_INTERVAL_END | NFT_SET_ELEM_CATCHALL)) ==
++          (NFT_SET_ELEM_INTERVAL_END | NFT_SET_ELEM_CATCHALL))
++              return -EINVAL;
+       return 0;
+ }
diff --git a/queue-5.15/netfilter-nf_tables-disallow-nfta_set_elem_key_end-with-nft_set_elem_interval_end-flag.patch b/queue-5.15/netfilter-nf_tables-disallow-nfta_set_elem_key_end-with-nft_set_elem_interval_end-flag.patch
new file mode 100644 (file)
index 0000000..0111cc0
--- /dev/null
@@ -0,0 +1,29 @@
+From 4963674c2e71fc062f8f089f0f58ffbb5533060b Mon Sep 17 00:00:00 2001
+From: Pablo Neira Ayuso <pablo@netfilter.org>
+Date: Tue, 9 Aug 2022 13:39:18 +0200
+Subject: netfilter: nf_tables: disallow NFTA_SET_ELEM_KEY_END with NFT_SET_ELEM_INTERVAL_END flag
+
+From: Pablo Neira Ayuso <pablo@netfilter.org>
+
+commit 4963674c2e71fc062f8f089f0f58ffbb5533060b upstream.
+
+These are mutually exclusive, actually NFTA_SET_ELEM_KEY_END replaces
+the flag notation.
+
+Fixes: 7b225d0b5c6d ("netfilter: nf_tables: add NFTA_SET_ELEM_KEY_END attribute")
+Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/netfilter/nf_tables_api.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/net/netfilter/nf_tables_api.c
++++ b/net/netfilter/nf_tables_api.c
+@@ -5768,6 +5768,7 @@ static int nft_add_set_elem(struct nft_c
+             nla[NFTA_SET_ELEM_EXPIRATION] ||
+             nla[NFTA_SET_ELEM_USERDATA] ||
+             nla[NFTA_SET_ELEM_EXPR] ||
++            nla[NFTA_SET_ELEM_KEY_END] ||
+             nla[NFTA_SET_ELEM_EXPRESSIONS]))
+               return -EINVAL;
diff --git a/queue-5.15/netfilter-nf_tables-nfta_set_elem_key_end-requires-concat-and-interval-flags.patch b/queue-5.15/netfilter-nf_tables-nfta_set_elem_key_end-requires-concat-and-interval-flags.patch
new file mode 100644 (file)
index 0000000..1140bf1
--- /dev/null
@@ -0,0 +1,71 @@
+From 88cccd908d51397f9754f89a937cd13fa59dee37 Mon Sep 17 00:00:00 2001
+From: Pablo Neira Ayuso <pablo@netfilter.org>
+Date: Fri, 12 Aug 2022 16:21:28 +0200
+Subject: netfilter: nf_tables: NFTA_SET_ELEM_KEY_END requires concat and interval flags
+
+From: Pablo Neira Ayuso <pablo@netfilter.org>
+
+commit 88cccd908d51397f9754f89a937cd13fa59dee37 upstream.
+
+If the NFT_SET_CONCAT|NFT_SET_INTERVAL flags are set on, then the
+netlink attribute NFTA_SET_ELEM_KEY_END must be specified. Otherwise,
+NFTA_SET_ELEM_KEY_END should not be present.
+
+For catch-all element, NFTA_SET_ELEM_KEY_END should not be present.
+The NFT_SET_ELEM_INTERVAL_END is never used with this set flags
+combination.
+
+Fixes: 7b225d0b5c6d ("netfilter: nf_tables: add NFTA_SET_ELEM_KEY_END attribute")
+Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/netfilter/nf_tables_api.c |   24 ++++++++++++++++++++++++
+ 1 file changed, 24 insertions(+)
+
+--- a/net/netfilter/nf_tables_api.c
++++ b/net/netfilter/nf_tables_api.c
+@@ -5711,6 +5711,24 @@ static void nft_setelem_remove(const str
+               set->ops->remove(net, set, elem);
+ }
++static bool nft_setelem_valid_key_end(const struct nft_set *set,
++                                    struct nlattr **nla, u32 flags)
++{
++      if ((set->flags & (NFT_SET_CONCAT | NFT_SET_INTERVAL)) ==
++                        (NFT_SET_CONCAT | NFT_SET_INTERVAL)) {
++              if (flags & NFT_SET_ELEM_INTERVAL_END)
++                      return false;
++              if (!nla[NFTA_SET_ELEM_KEY_END] &&
++                  !(flags & NFT_SET_ELEM_CATCHALL))
++                      return false;
++      } else {
++              if (nla[NFTA_SET_ELEM_KEY_END])
++                      return false;
++      }
++
++      return true;
++}
++
+ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,
+                           const struct nlattr *attr, u32 nlmsg_flags)
+ {
+@@ -5770,6 +5788,9 @@ static int nft_add_set_elem(struct nft_c
+                       return -EINVAL;
+       }
++      if (!nft_setelem_valid_key_end(set, nla, flags))
++              return -EINVAL;
++
+       if ((flags & NFT_SET_ELEM_INTERVAL_END) &&
+            (nla[NFTA_SET_ELEM_DATA] ||
+             nla[NFTA_SET_ELEM_OBJREF] ||
+@@ -6192,6 +6213,9 @@ static int nft_del_setelem(struct nft_ct
+       if (!nla[NFTA_SET_ELEM_KEY] && !(flags & NFT_SET_ELEM_CATCHALL))
+               return -EINVAL;
++      if (!nft_setelem_valid_key_end(set, nla, flags))
++              return -EINVAL;
++
+       nft_set_ext_prepare(&tmpl);
+       if (flags != 0) {
diff --git a/queue-5.15/netfilter-nf_tables-possible-module-reference-underflow-in-error-path.patch b/queue-5.15/netfilter-nf_tables-possible-module-reference-underflow-in-error-path.patch
new file mode 100644 (file)
index 0000000..6e92e8f
--- /dev/null
@@ -0,0 +1,31 @@
+From c485c35ff6783ccd12c160fcac6a0e504e83e0bf Mon Sep 17 00:00:00 2001
+From: Pablo Neira Ayuso <pablo@netfilter.org>
+Date: Tue, 9 Aug 2022 17:23:52 +0200
+Subject: netfilter: nf_tables: possible module reference underflow in error path
+
+From: Pablo Neira Ayuso <pablo@netfilter.org>
+
+commit c485c35ff6783ccd12c160fcac6a0e504e83e0bf upstream.
+
+dst->ops is set on when nft_expr_clone() fails, but module refcount has
+not been bumped yet, therefore nft_expr_destroy() leads to module
+reference underflow.
+
+Fixes: 8cfd9b0f8515 ("netfilter: nftables: generalize set expressions support")
+Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/netfilter/nf_tables_api.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/net/netfilter/nf_tables_api.c
++++ b/net/netfilter/nf_tables_api.c
+@@ -5479,7 +5479,7 @@ int nft_set_elem_expr_clone(const struct
+               err = nft_expr_clone(expr, set->exprs[i]);
+               if (err < 0) {
+-                      nft_expr_destroy(ctx, expr);
++                      kfree(expr);
+                       goto err_expr;
+               }
+               expr_array[i] = expr;
diff --git a/queue-5.15/netfilter-nf_tables-really-skip-inactive-sets-when-allocating-name.patch b/queue-5.15/netfilter-nf_tables-really-skip-inactive-sets-when-allocating-name.patch
new file mode 100644 (file)
index 0000000..c218a09
--- /dev/null
@@ -0,0 +1,30 @@
+From 271c5ca826e0c3c53e0eb4032f8eaedea1ee391c Mon Sep 17 00:00:00 2001
+From: Pablo Neira Ayuso <pablo@netfilter.org>
+Date: Tue, 9 Aug 2022 17:23:53 +0200
+Subject: netfilter: nf_tables: really skip inactive sets when allocating name
+
+From: Pablo Neira Ayuso <pablo@netfilter.org>
+
+commit 271c5ca826e0c3c53e0eb4032f8eaedea1ee391c upstream.
+
+While looping to build the bitmap of used anonymous set names, check the
+current set in the iteration, instead of the one that is being created.
+
+Fixes: 37a9cc525525 ("netfilter: nf_tables: add generation mask to sets")
+Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/netfilter/nf_tables_api.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/net/netfilter/nf_tables_api.c
++++ b/net/netfilter/nf_tables_api.c
+@@ -3810,7 +3810,7 @@ cont:
+               list_for_each_entry(i, &ctx->table->sets, list) {
+                       int tmp;
+-                      if (!nft_is_active_next(ctx->net, set))
++                      if (!nft_is_active_next(ctx->net, i))
+                               continue;
+                       if (!sscanf(i->name, name, &tmp))
+                               continue;
diff --git a/queue-5.15/netfilter-nf_tables-validate-nfta_set_elem_objref-based-on-nft_set_object-flag.patch b/queue-5.15/netfilter-nf_tables-validate-nfta_set_elem_objref-based-on-nft_set_object-flag.patch
new file mode 100644 (file)
index 0000000..524d092
--- /dev/null
@@ -0,0 +1,51 @@
+From 5a2f3dc31811e93be15522d9eb13ed61460b76c8 Mon Sep 17 00:00:00 2001
+From: Pablo Neira Ayuso <pablo@netfilter.org>
+Date: Fri, 12 Aug 2022 16:19:23 +0200
+Subject: netfilter: nf_tables: validate NFTA_SET_ELEM_OBJREF based on NFT_SET_OBJECT flag
+
+From: Pablo Neira Ayuso <pablo@netfilter.org>
+
+commit 5a2f3dc31811e93be15522d9eb13ed61460b76c8 upstream.
+
+If the NFTA_SET_ELEM_OBJREF netlink attribute is present and
+NFT_SET_OBJECT flag is set on, report EINVAL.
+
+Move existing sanity check earlier to validate that NFT_SET_OBJECT
+requires NFTA_SET_ELEM_OBJREF.
+
+Fixes: 8aeff920dcc9 ("netfilter: nf_tables: add stateful object reference to set elements")
+Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/netfilter/nf_tables_api.c |   13 +++++++++----
+ 1 file changed, 9 insertions(+), 4 deletions(-)
+
+--- a/net/netfilter/nf_tables_api.c
++++ b/net/netfilter/nf_tables_api.c
+@@ -5761,6 +5761,15 @@ static int nft_add_set_elem(struct nft_c
+                       return -EINVAL;
+       }
++      if (set->flags & NFT_SET_OBJECT) {
++              if (!nla[NFTA_SET_ELEM_OBJREF] &&
++                  !(flags & NFT_SET_ELEM_INTERVAL_END))
++                      return -EINVAL;
++      } else {
++              if (nla[NFTA_SET_ELEM_OBJREF])
++                      return -EINVAL;
++      }
++
+       if ((flags & NFT_SET_ELEM_INTERVAL_END) &&
+            (nla[NFTA_SET_ELEM_DATA] ||
+             nla[NFTA_SET_ELEM_OBJREF] ||
+@@ -5899,10 +5908,6 @@ static int nft_add_set_elem(struct nft_c
+       }
+       if (nla[NFTA_SET_ELEM_OBJREF] != NULL) {
+-              if (!(set->flags & NFT_SET_OBJECT)) {
+-                      err = -EINVAL;
+-                      goto err_parse_key_end;
+-              }
+               obj = nft_obj_lookup(ctx->net, ctx->table,
+                                    nla[NFTA_SET_ELEM_OBJREF],
+                                    set->objtype, genmask);
diff --git a/queue-5.15/powerpc-pci-fix-get_phb_number-locking.patch b/queue-5.15/powerpc-pci-fix-get_phb_number-locking.patch
new file mode 100644 (file)
index 0000000..f581934
--- /dev/null
@@ -0,0 +1,105 @@
+From 8d48562a2729742f767b0fdd994d6b2a56a49c63 Mon Sep 17 00:00:00 2001
+From: Michael Ellerman <mpe@ellerman.id.au>
+Date: Mon, 15 Aug 2022 16:55:23 +1000
+Subject: powerpc/pci: Fix get_phb_number() locking
+
+From: Michael Ellerman <mpe@ellerman.id.au>
+
+commit 8d48562a2729742f767b0fdd994d6b2a56a49c63 upstream.
+
+The recent change to get_phb_number() causes a DEBUG_ATOMIC_SLEEP
+warning on some systems:
+
+  BUG: sleeping function called from invalid context at kernel/locking/mutex.c:580
+  in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1, name: swapper
+  preempt_count: 1, expected: 0
+  RCU nest depth: 0, expected: 0
+  1 lock held by swapper/1:
+   #0: c157efb0 (hose_spinlock){+.+.}-{2:2}, at: pcibios_alloc_controller+0x64/0x220
+  Preemption disabled at:
+  [<00000000>] 0x0
+  CPU: 0 PID: 1 Comm: swapper Not tainted 5.19.0-yocto-standard+ #1
+  Call Trace:
+  [d101dc90] [c073b264] dump_stack_lvl+0x50/0x8c (unreliable)
+  [d101dcb0] [c0093b70] __might_resched+0x258/0x2a8
+  [d101dcd0] [c0d3e634] __mutex_lock+0x6c/0x6ec
+  [d101dd50] [c0a84174] of_alias_get_id+0x50/0xf4
+  [d101dd80] [c002ec78] pcibios_alloc_controller+0x1b8/0x220
+  [d101ddd0] [c140c9dc] pmac_pci_init+0x198/0x784
+  [d101de50] [c140852c] discover_phbs+0x30/0x4c
+  [d101de60] [c0007fd4] do_one_initcall+0x94/0x344
+  [d101ded0] [c1403b40] kernel_init_freeable+0x1a8/0x22c
+  [d101df10] [c00086e0] kernel_init+0x34/0x160
+  [d101df30] [c001b334] ret_from_kernel_thread+0x5c/0x64
+
+This is because pcibios_alloc_controller() holds hose_spinlock but
+of_alias_get_id() takes of_mutex which can sleep.
+
+The hose_spinlock protects the phb_bitmap, and also the hose_list, but
+it doesn't need to be held while get_phb_number() calls the OF routines,
+because those are only looking up information in the device tree.
+
+So fix it by having get_phb_number() take the hose_spinlock itself, only
+where required, and then dropping the lock before returning.
+pcibios_alloc_controller() then needs to take the lock again before the
+list_add() but that's safe, the order of the list is not important.
+
+Fixes: 0fe1e96fef0a ("powerpc/pci: Prefer PCI domain assignment via DT 'linux,pci-domain' and alias")
+Reported-by: Guenter Roeck <linux@roeck-us.net>
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Link: https://lore.kernel.org/r/20220815065550.1303620-1-mpe@ellerman.id.au
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/powerpc/kernel/pci-common.c |   16 ++++++++++------
+ 1 file changed, 10 insertions(+), 6 deletions(-)
+
+--- a/arch/powerpc/kernel/pci-common.c
++++ b/arch/powerpc/kernel/pci-common.c
+@@ -67,10 +67,6 @@ void set_pci_dma_ops(const struct dma_ma
+       pci_dma_ops = dma_ops;
+ }
+-/*
+- * This function should run under locking protection, specifically
+- * hose_spinlock.
+- */
+ static int get_phb_number(struct device_node *dn)
+ {
+       int ret, phb_id = -1;
+@@ -107,15 +103,20 @@ static int get_phb_number(struct device_
+       if (!ret)
+               phb_id = (int)(prop & (MAX_PHBS - 1));
++      spin_lock(&hose_spinlock);
++
+       /* We need to be sure to not use the same PHB number twice. */
+       if ((phb_id >= 0) && !test_and_set_bit(phb_id, phb_bitmap))
+-              return phb_id;
++              goto out_unlock;
+       /* If everything fails then fallback to dynamic PHB numbering. */
+       phb_id = find_first_zero_bit(phb_bitmap, MAX_PHBS);
+       BUG_ON(phb_id >= MAX_PHBS);
+       set_bit(phb_id, phb_bitmap);
++out_unlock:
++      spin_unlock(&hose_spinlock);
++
+       return phb_id;
+ }
+@@ -126,10 +127,13 @@ struct pci_controller *pcibios_alloc_con
+       phb = zalloc_maybe_bootmem(sizeof(struct pci_controller), GFP_KERNEL);
+       if (phb == NULL)
+               return NULL;
+-      spin_lock(&hose_spinlock);
++
+       phb->global_number = get_phb_number(dev);
++
++      spin_lock(&hose_spinlock);
+       list_add_tail(&phb->list_node, &hose_list);
+       spin_unlock(&hose_spinlock);
++
+       phb->dn = dev;
+       phb->is_dynamic = slab_is_available();
+ #ifdef CONFIG_PPC64
diff --git a/queue-5.15/regulator-pca9450-remove-restrictions-for-regulator-name.patch b/queue-5.15/regulator-pca9450-remove-restrictions-for-regulator-name.patch
new file mode 100644 (file)
index 0000000..506b226
--- /dev/null
@@ -0,0 +1,50 @@
+From b0de7fa706506bf0591037908376351beda8c5d6 Mon Sep 17 00:00:00 2001
+From: Frieder Schrempf <frieder.schrempf@kontron.de>
+Date: Tue, 2 Aug 2022 08:43:34 +0200
+Subject: regulator: pca9450: Remove restrictions for regulator-name
+
+From: Frieder Schrempf <frieder.schrempf@kontron.de>
+
+commit b0de7fa706506bf0591037908376351beda8c5d6 upstream.
+
+The device bindings shouldn't put any constraints on the regulator-name
+property specified in the generic bindings. This allows using arbitrary
+and descriptive names for the regulators.
+
+Suggested-by: Mark Brown <broonie@kernel.org>
+Fixes: 7ae9e3a6bf3f ("dt-bindings: regulator: add pca9450 regulator yaml")
+Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
+Link: https://lore.kernel.org/r/20220802064335.8481-1-frieder@fris.de
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ Documentation/devicetree/bindings/regulator/nxp,pca9450-regulator.yaml |   11 ----------
+ 1 file changed, 11 deletions(-)
+
+--- a/Documentation/devicetree/bindings/regulator/nxp,pca9450-regulator.yaml
++++ b/Documentation/devicetree/bindings/regulator/nxp,pca9450-regulator.yaml
+@@ -47,12 +47,6 @@ properties:
+         description:
+           Properties for single LDO regulator.
+-        properties:
+-          regulator-name:
+-            pattern: "^LDO[1-5]$"
+-            description:
+-              should be "LDO1", ..., "LDO5"
+-
+         unevaluatedProperties: false
+       "^BUCK[1-6]$":
+@@ -62,11 +56,6 @@ properties:
+           Properties for single BUCK regulator.
+         properties:
+-          regulator-name:
+-            pattern: "^BUCK[1-6]$"
+-            description:
+-              should be "BUCK1", ..., "BUCK6"
+-
+           nxp,dvs-run-voltage:
+             $ref: "/schemas/types.yaml#/definitions/uint32"
+             minimum: 600000
index 0c825eb2748f1689667ab2e1e84feacace5967e8..55b74bec3c565b3d1aa9c8ca872fc4d8e63d4326 100644 (file)
@@ -122,3 +122,31 @@ asoc-tas2770-fix-handling-of-mute-unmute.patch
 asoc-codec-tlv320aic32x4-fix-mono-playback-via-i2s.patch
 netfilter-nf_tables-use-read_once-and-write_once-for-shared-generation-id-access.patch
 fs-ntfs3-uninitialized-variable-in-ntfs_set_acl_ex.patch
+netfilter-nf_tables-disallow-nfta_set_elem_key_end-with-nft_set_elem_interval_end-flag.patch
+netfilter-nf_tables-possible-module-reference-underflow-in-error-path.patch
+netfilter-nf_tables-really-skip-inactive-sets-when-allocating-name.patch
+netfilter-nf_tables-validate-nfta_set_elem_objref-based-on-nft_set_object-flag.patch
+netfilter-nf_tables-nfta_set_elem_key_end-requires-concat-and-interval-flags.patch
+netfilter-nf_tables-disallow-nft_set_elem_catchall-and-nft_set_elem_interval_end.patch
+netfilter-nf_tables-check-nft_set_concat-flag-if-field_count-is-specified.patch
+powerpc-pci-fix-get_phb_number-locking.patch
+spi-meson-spicc-add-local-pow2-clock-ops-to-preserve-rate-between-messages.patch
+net-sunrpc-fix-potential-memory-leaks-in-rpc_sysfs_xprt_state_change.patch
+net-dsa-mv88e6060-prevent-crash-on-an-unused-port.patch
+mlxsw-spectrum-clear-ptp-configuration-after-unregistering-the-netdevice.patch
+net-moxa-pass-pdev-instead-of-ndev-to-dma-functions.patch
+net-fix-potential-refcount-leak-in-ndisc_router_discovery.patch
+net-dsa-microchip-ksz9477-fix-fdb_dump-last-invalid-entry.patch
+net-dsa-felix-fix-ethtool-256-511-and-512-1023-tx-packet-counters.patch
+net-genl-fix-error-path-memory-leak-in-policy-dumping.patch
+net-dsa-don-t-warn-in-dsa_port_set_state_now-when-driver-doesn-t-support-it.patch
+net-dsa-sja1105-fix-buffer-overflow-in-sja1105_setup_devlink_regions.patch
+ice-ignore-eexist-when-setting-promisc-mode.patch
+i2c-imx-make-sure-to-unregister-adapter-on-remove.patch
+regulator-pca9450-remove-restrictions-for-regulator-name.patch
+i40e-fix-to-stop-tx_timeout-recovery-if-globr-fails.patch
+fec-fix-timer-capture-timing-in-fec_ptp_enable_pps.patch
+stmmac-intel-add-a-missing-clk_disable_unprepare-call-in-intel_eth_pci_remove.patch
+igb-add-lock-to-avoid-data-race.patch
+kbuild-fix-the-modules-order-between-drivers-and-libs.patch
+gcc-plugins-undefine-latent_entropy_plugin-when-plugin-disabled-for-a-file.patch
diff --git a/queue-5.15/spi-meson-spicc-add-local-pow2-clock-ops-to-preserve-rate-between-messages.patch b/queue-5.15/spi-meson-spicc-add-local-pow2-clock-ops-to-preserve-rate-between-messages.patch
new file mode 100644 (file)
index 0000000..9504df0
--- /dev/null
@@ -0,0 +1,255 @@
+From 09992025dacd258c823f50e82db09d7ef06cdac4 Mon Sep 17 00:00:00 2001
+From: Neil Armstrong <narmstrong@baylibre.com>
+Date: Thu, 11 Aug 2022 15:44:45 +0200
+Subject: spi: meson-spicc: add local pow2 clock ops to preserve rate between messages
+
+From: Neil Armstrong <narmstrong@baylibre.com>
+
+commit 09992025dacd258c823f50e82db09d7ef06cdac4 upstream.
+
+At the end of a message, the HW gets a reset in meson_spicc_unprepare_transfer(),
+this resets the SPICC_CONREG register and notably the value set by the
+Common Clock Framework.
+
+This is problematic because:
+- the register value CCF can be different from the corresponding CCF cached rate
+- CCF is allowed to change the clock rate whenever the HW state
+
+This introduces:
+- local pow2 clock ops checking the HW state before allowing a clock operation
+- separation of legacy pow2 clock patch and new enhanced clock path
+- SPICC_CONREG datarate value is now value kepts across messages
+
+It has been checked that:
+- SPICC_CONREG datarate value is kept across messages
+- CCF is only allowed to change the SPICC_CONREG datarate value when busy
+- SPICC_CONREG datarate value is correct for each transfer
+
+This didn't appear before commit 3e0cf4d3fc29 ("spi: meson-spicc: add a linear clock divider support")
+because we recalculated and wrote the rate for each xfer.
+
+Fixes: 3e0cf4d3fc29 ("spi: meson-spicc: add a linear clock divider support")
+Reported-by: Da Xue <da@libre.computer>
+Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
+Link: https://lore.kernel.org/r/20220811134445.678446-1-narmstrong@baylibre.com
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/spi/spi-meson-spicc.c |  129 ++++++++++++++++++++++++++++++++----------
+ 1 file changed, 101 insertions(+), 28 deletions(-)
+
+--- a/drivers/spi/spi-meson-spicc.c
++++ b/drivers/spi/spi-meson-spicc.c
+@@ -156,6 +156,7 @@ struct meson_spicc_device {
+       void __iomem                    *base;
+       struct clk                      *core;
+       struct clk                      *pclk;
++      struct clk_divider              pow2_div;
+       struct clk                      *clk;
+       struct spi_message              *message;
+       struct spi_transfer             *xfer;
+@@ -168,6 +169,8 @@ struct meson_spicc_device {
+       unsigned long                   xfer_remain;
+ };
++#define pow2_clk_to_spicc(_div) container_of(_div, struct meson_spicc_device, pow2_div)
++
+ static void meson_spicc_oen_enable(struct meson_spicc_device *spicc)
+ {
+       u32 conf;
+@@ -421,7 +424,7 @@ static int meson_spicc_prepare_message(s
+ {
+       struct meson_spicc_device *spicc = spi_master_get_devdata(master);
+       struct spi_device *spi = message->spi;
+-      u32 conf = 0;
++      u32 conf = readl_relaxed(spicc->base + SPICC_CONREG) & SPICC_DATARATE_MASK;
+       /* Store current message */
+       spicc->message = message;
+@@ -458,8 +461,6 @@ static int meson_spicc_prepare_message(s
+       /* Select CS */
+       conf |= FIELD_PREP(SPICC_CS_MASK, spi->chip_select);
+-      /* Default Clock rate core/4 */
+-
+       /* Default 8bit word */
+       conf |= FIELD_PREP(SPICC_BITLENGTH_MASK, 8 - 1);
+@@ -476,12 +477,16 @@ static int meson_spicc_prepare_message(s
+ static int meson_spicc_unprepare_transfer(struct spi_master *master)
+ {
+       struct meson_spicc_device *spicc = spi_master_get_devdata(master);
++      u32 conf = readl_relaxed(spicc->base + SPICC_CONREG) & SPICC_DATARATE_MASK;
+       /* Disable all IRQs */
+       writel(0, spicc->base + SPICC_INTREG);
+       device_reset_optional(&spicc->pdev->dev);
++      /* Set default configuration, keeping datarate field */
++      writel_relaxed(conf, spicc->base + SPICC_CONREG);
++
+       return 0;
+ }
+@@ -518,14 +523,60 @@ static void meson_spicc_cleanup(struct s
+  * Clk path for G12A series:
+  *    pclk -> pow2 fixed div -> pow2 div -> mux -> out
+  *    pclk -> enh fixed div -> enh div -> mux -> out
++ *
++ * The pow2 divider is tied to the controller HW state, and the
++ * divider is only valid when the controller is initialized.
++ *
++ * A set of clock ops is added to make sure we don't read/set this
++ * clock rate while the controller is in an unknown state.
+  */
+-static int meson_spicc_clk_init(struct meson_spicc_device *spicc)
++static unsigned long meson_spicc_pow2_recalc_rate(struct clk_hw *hw,
++                                                unsigned long parent_rate)
++{
++      struct clk_divider *divider = to_clk_divider(hw);
++      struct meson_spicc_device *spicc = pow2_clk_to_spicc(divider);
++
++      if (!spicc->master->cur_msg || !spicc->master->busy)
++              return 0;
++
++      return clk_divider_ops.recalc_rate(hw, parent_rate);
++}
++
++static int meson_spicc_pow2_determine_rate(struct clk_hw *hw,
++                                         struct clk_rate_request *req)
++{
++      struct clk_divider *divider = to_clk_divider(hw);
++      struct meson_spicc_device *spicc = pow2_clk_to_spicc(divider);
++
++      if (!spicc->master->cur_msg || !spicc->master->busy)
++              return -EINVAL;
++
++      return clk_divider_ops.determine_rate(hw, req);
++}
++
++static int meson_spicc_pow2_set_rate(struct clk_hw *hw, unsigned long rate,
++                                   unsigned long parent_rate)
++{
++      struct clk_divider *divider = to_clk_divider(hw);
++      struct meson_spicc_device *spicc = pow2_clk_to_spicc(divider);
++
++      if (!spicc->master->cur_msg || !spicc->master->busy)
++              return -EINVAL;
++
++      return clk_divider_ops.set_rate(hw, rate, parent_rate);
++}
++
++const struct clk_ops meson_spicc_pow2_clk_ops = {
++      .recalc_rate = meson_spicc_pow2_recalc_rate,
++      .determine_rate = meson_spicc_pow2_determine_rate,
++      .set_rate = meson_spicc_pow2_set_rate,
++};
++
++static int meson_spicc_pow2_clk_init(struct meson_spicc_device *spicc)
+ {
+       struct device *dev = &spicc->pdev->dev;
+-      struct clk_fixed_factor *pow2_fixed_div, *enh_fixed_div;
+-      struct clk_divider *pow2_div, *enh_div;
+-      struct clk_mux *mux;
++      struct clk_fixed_factor *pow2_fixed_div;
+       struct clk_init_data init;
+       struct clk *clk;
+       struct clk_parent_data parent_data[2];
+@@ -560,31 +611,45 @@ static int meson_spicc_clk_init(struct m
+       if (WARN_ON(IS_ERR(clk)))
+               return PTR_ERR(clk);
+-      pow2_div = devm_kzalloc(dev, sizeof(*pow2_div), GFP_KERNEL);
+-      if (!pow2_div)
+-              return -ENOMEM;
+-
+       snprintf(name, sizeof(name), "%s#pow2_div", dev_name(dev));
+       init.name = name;
+-      init.ops = &clk_divider_ops;
+-      init.flags = CLK_SET_RATE_PARENT;
++      init.ops = &meson_spicc_pow2_clk_ops;
++      /*
++       * Set NOCACHE here to make sure we read the actual HW value
++       * since we reset the HW after each transfer.
++       */
++      init.flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE;
+       parent_data[0].hw = &pow2_fixed_div->hw;
+       init.num_parents = 1;
+-      pow2_div->shift = 16,
+-      pow2_div->width = 3,
+-      pow2_div->flags = CLK_DIVIDER_POWER_OF_TWO,
+-      pow2_div->reg = spicc->base + SPICC_CONREG;
+-      pow2_div->hw.init = &init;
++      spicc->pow2_div.shift = 16,
++      spicc->pow2_div.width = 3,
++      spicc->pow2_div.flags = CLK_DIVIDER_POWER_OF_TWO,
++      spicc->pow2_div.reg = spicc->base + SPICC_CONREG;
++      spicc->pow2_div.hw.init = &init;
+-      clk = devm_clk_register(dev, &pow2_div->hw);
+-      if (WARN_ON(IS_ERR(clk)))
+-              return PTR_ERR(clk);
++      spicc->clk = devm_clk_register(dev, &spicc->pow2_div.hw);
++      if (WARN_ON(IS_ERR(spicc->clk)))
++              return PTR_ERR(spicc->clk);
+-      if (!spicc->data->has_enhance_clk_div) {
+-              spicc->clk = clk;
+-              return 0;
+-      }
++      return 0;
++}
++
++static int meson_spicc_enh_clk_init(struct meson_spicc_device *spicc)
++{
++      struct device *dev = &spicc->pdev->dev;
++      struct clk_fixed_factor *enh_fixed_div;
++      struct clk_divider *enh_div;
++      struct clk_mux *mux;
++      struct clk_init_data init;
++      struct clk *clk;
++      struct clk_parent_data parent_data[2];
++      char name[64];
++
++      memset(&init, 0, sizeof(init));
++      memset(&parent_data, 0, sizeof(parent_data));
++
++      init.parent_data = parent_data;
+       /* algorithm for enh div: rate = freq / 2 / (N + 1) */
+@@ -637,7 +702,7 @@ static int meson_spicc_clk_init(struct m
+       snprintf(name, sizeof(name), "%s#sel", dev_name(dev));
+       init.name = name;
+       init.ops = &clk_mux_ops;
+-      parent_data[0].hw = &pow2_div->hw;
++      parent_data[0].hw = &spicc->pow2_div.hw;
+       parent_data[1].hw = &enh_div->hw;
+       init.num_parents = 2;
+       init.flags = CLK_SET_RATE_PARENT;
+@@ -754,12 +819,20 @@ static int meson_spicc_probe(struct plat
+       meson_spicc_oen_enable(spicc);
+-      ret = meson_spicc_clk_init(spicc);
++      ret = meson_spicc_pow2_clk_init(spicc);
+       if (ret) {
+-              dev_err(&pdev->dev, "clock registration failed\n");
++              dev_err(&pdev->dev, "pow2 clock registration failed\n");
+               goto out_clk;
+       }
++      if (spicc->data->has_enhance_clk_div) {
++              ret = meson_spicc_enh_clk_init(spicc);
++              if (ret) {
++                      dev_err(&pdev->dev, "clock registration failed\n");
++                      goto out_clk;
++              }
++      }
++
+       ret = devm_spi_register_master(&pdev->dev, master);
+       if (ret) {
+               dev_err(&pdev->dev, "spi master registration failed\n");
diff --git a/queue-5.15/stmmac-intel-add-a-missing-clk_disable_unprepare-call-in-intel_eth_pci_remove.patch b/queue-5.15/stmmac-intel-add-a-missing-clk_disable_unprepare-call-in-intel_eth_pci_remove.patch
new file mode 100644 (file)
index 0000000..3317347
--- /dev/null
@@ -0,0 +1,47 @@
+From 5c23d6b717e4e956376f3852b90f58e262946b50 Mon Sep 17 00:00:00 2001
+From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
+Date: Tue, 16 Aug 2022 16:23:57 +0200
+Subject: stmmac: intel: Add a missing clk_disable_unprepare() call in intel_eth_pci_remove()
+
+From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
+
+commit 5c23d6b717e4e956376f3852b90f58e262946b50 upstream.
+
+Commit 09f012e64e4b ("stmmac: intel: Fix clock handling on error and remove
+paths") removed this clk_disable_unprepare()
+
+This was partly revert by commit ac322f86b56c ("net: stmmac: Fix clock
+handling on remove path") which removed this clk_disable_unprepare()
+because:
+"
+   While unloading the dwmac-intel driver, clk_disable_unprepare() is
+   being called twice in stmmac_dvr_remove() and
+   intel_eth_pci_remove(). This causes kernel panic on the second call.
+"
+
+However later on, commit 5ec55823438e8 ("net: stmmac: add clocks management
+for gmac driver") has updated stmmac_dvr_remove() which do not call
+clk_disable_unprepare() anymore.
+
+So this call should now be called from intel_eth_pci_remove().
+
+Fixes: 5ec55823438e8 ("net: stmmac: add clocks management for gmac driver")
+Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
+Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Link: https://lore.kernel.org/r/d7c8c1dadf40df3a7c9e643f76ffadd0ccc1ad1b.1660659689.git.christophe.jaillet@wanadoo.fr
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
++++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
+@@ -1098,6 +1098,7 @@ static void intel_eth_pci_remove(struct
+       stmmac_dvr_remove(&pdev->dev);
++      clk_disable_unprepare(priv->plat->stmmac_clk);
+       clk_unregister_fixed_rate(priv->plat->stmmac_clk);
+       pcim_iounmap_regions(pdev, BIT(0));