]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 5.4
authorSasha Levin <sashal@kernel.org>
Mon, 30 Jan 2023 03:56:04 +0000 (22:56 -0500)
committerSasha Levin <sashal@kernel.org>
Mon, 30 Jan 2023 03:56:04 +0000 (22:56 -0500)
Signed-off-by: Sasha Levin <sashal@kernel.org>
20 files changed:
queue-5.4/ipv4-prevent-potential-spectre-v1-gadget-in-fib_metr.patch [new file with mode: 0644]
queue-5.4/ipv4-prevent-potential-spectre-v1-gadget-in-ip_metri.patch [new file with mode: 0644]
queue-5.4/net-fix-uaf-in-netns-ops-registration-error-path.patch [new file with mode: 0644]
queue-5.4/net-mdio-mux-meson-g12a-force-internal-phy-off-on-mu.patch [new file with mode: 0644]
queue-5.4/net-phy-mdio-i2c-move-header-file-to-include-linux-m.patch [new file with mode: 0644]
queue-5.4/net-ravb-fix-possible-hang-if-ris2_qff1-happen.patch [new file with mode: 0644]
queue-5.4/net-sched-sch_taprio-do-not-schedule-in-taprio_reset.patch [new file with mode: 0644]
queue-5.4/net-tg3-resolve-deadlock-in-tg3_reset_task-during-ee.patch [new file with mode: 0644]
queue-5.4/net-xgene-move-shared-header-file-into-include-linux.patch [new file with mode: 0644]
queue-5.4/netfilter-conntrack-fix-bug-in-for_each_sctp_chunk.patch [new file with mode: 0644]
queue-5.4/netfilter-conntrack-fix-vtag-checks-for-abort-shutdo.patch [new file with mode: 0644]
queue-5.4/netfilter-nft_set_rbtree-skip-elements-in-transactio.patch [new file with mode: 0644]
queue-5.4/netlink-annotate-data-races-around-dst_portid-and-ds.patch [new file with mode: 0644]
queue-5.4/netlink-annotate-data-races-around-nlk-portid.patch [new file with mode: 0644]
queue-5.4/netlink-annotate-data-races-around-sk_state.patch [new file with mode: 0644]
queue-5.4/netlink-prevent-potential-spectre-v1-gadgets.patch [new file with mode: 0644]
queue-5.4/netrom-fix-use-after-free-of-a-listening-socket.patch [new file with mode: 0644]
queue-5.4/sctp-fail-if-no-bound-addresses-can-be-used-for-a-gi.patch [new file with mode: 0644]
queue-5.4/series
queue-5.4/thermal-intel-int340x-add-locking-to-int340x_thermal.patch [new file with mode: 0644]

diff --git a/queue-5.4/ipv4-prevent-potential-spectre-v1-gadget-in-fib_metr.patch b/queue-5.4/ipv4-prevent-potential-spectre-v1-gadget-in-fib_metr.patch
new file mode 100644 (file)
index 0000000..df67af2
--- /dev/null
@@ -0,0 +1,51 @@
+From 06c819ecfa3b7373a59e2d19812be9b2aa0c8252 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 20 Jan 2023 13:31:40 +0000
+Subject: ipv4: prevent potential spectre v1 gadget in fib_metrics_match()
+
+From: Eric Dumazet <edumazet@google.com>
+
+[ Upstream commit 5e9398a26a92fc402d82ce1f97cc67d832527da0 ]
+
+if (!type)
+        continue;
+    if (type > RTAX_MAX)
+        return false;
+    ...
+    fi_val = fi->fib_metrics->metrics[type - 1];
+
+@type being used as an array index, we need to prevent
+cpu speculation or risk leaking kernel memory content.
+
+Fixes: 5f9ae3d9e7e4 ("ipv4: do metrics match when looking up and deleting a route")
+Signed-off-by: Eric Dumazet <edumazet@google.com>
+Link: https://lore.kernel.org/r/20230120133140.3624204-1-edumazet@google.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/ipv4/fib_semantics.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
+index f45b9daf62cf..42a4ee192f8d 100644
+--- a/net/ipv4/fib_semantics.c
++++ b/net/ipv4/fib_semantics.c
+@@ -30,6 +30,7 @@
+ #include <linux/slab.h>
+ #include <linux/netlink.h>
+ #include <linux/hash.h>
++#include <linux/nospec.h>
+ #include <net/arp.h>
+ #include <net/ip.h>
+@@ -1009,6 +1010,7 @@ bool fib_metrics_match(struct fib_config *cfg, struct fib_info *fi)
+               if (type > RTAX_MAX)
+                       return false;
++              type = array_index_nospec(type, RTAX_MAX + 1);
+               if (type == RTAX_CC_ALGO) {
+                       char tmp[TCP_CA_NAME_MAX];
+                       bool ecn_ca = false;
+-- 
+2.39.0
+
diff --git a/queue-5.4/ipv4-prevent-potential-spectre-v1-gadget-in-ip_metri.patch b/queue-5.4/ipv4-prevent-potential-spectre-v1-gadget-in-ip_metri.patch
new file mode 100644 (file)
index 0000000..eab904b
--- /dev/null
@@ -0,0 +1,50 @@
+From b36c4a398680ea75102f50054c66c73321b60867 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 20 Jan 2023 13:30:40 +0000
+Subject: ipv4: prevent potential spectre v1 gadget in ip_metrics_convert()
+
+From: Eric Dumazet <edumazet@google.com>
+
+[ Upstream commit 1d1d63b612801b3f0a39b7d4467cad0abd60e5c8 ]
+
+if (!type)
+               continue;
+       if (type > RTAX_MAX)
+               return -EINVAL;
+       ...
+       metrics[type - 1] = val;
+
+@type being used as an array index, we need to prevent
+cpu speculation or risk leaking kernel memory content.
+
+Fixes: 6cf9dfd3bd62 ("net: fib: move metrics parsing to a helper")
+Signed-off-by: Eric Dumazet <edumazet@google.com>
+Link: https://lore.kernel.org/r/20230120133040.3623463-1-edumazet@google.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/ipv4/metrics.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/net/ipv4/metrics.c b/net/ipv4/metrics.c
+index 3205d5f7c8c9..4966ac2aaf87 100644
+--- a/net/ipv4/metrics.c
++++ b/net/ipv4/metrics.c
+@@ -1,5 +1,6 @@
+ // SPDX-License-Identifier: GPL-2.0-only
+ #include <linux/netlink.h>
++#include <linux/nospec.h>
+ #include <linux/rtnetlink.h>
+ #include <linux/types.h>
+ #include <net/ip.h>
+@@ -28,6 +29,7 @@ static int ip_metrics_convert(struct net *net, struct nlattr *fc_mx,
+                       return -EINVAL;
+               }
++              type = array_index_nospec(type, RTAX_MAX + 1);
+               if (type == RTAX_CC_ALGO) {
+                       char tmp[TCP_CA_NAME_MAX];
+-- 
+2.39.0
+
diff --git a/queue-5.4/net-fix-uaf-in-netns-ops-registration-error-path.patch b/queue-5.4/net-fix-uaf-in-netns-ops-registration-error-path.patch
new file mode 100644 (file)
index 0000000..92eb3eb
--- /dev/null
@@ -0,0 +1,84 @@
+From e5aeb4a2f54f58a074b8a3564a4dd668f99dc55c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 19 Jan 2023 19:55:45 +0100
+Subject: net: fix UaF in netns ops registration error path
+
+From: Paolo Abeni <pabeni@redhat.com>
+
+[ Upstream commit 71ab9c3e2253619136c31c89dbb2c69305cc89b1 ]
+
+If net_assign_generic() fails, the current error path in ops_init() tries
+to clear the gen pointer slot. Anyway, in such error path, the gen pointer
+itself has not been modified yet, and the existing and accessed one is
+smaller than the accessed index, causing an out-of-bounds error:
+
+ BUG: KASAN: slab-out-of-bounds in ops_init+0x2de/0x320
+ Write of size 8 at addr ffff888109124978 by task modprobe/1018
+
+ CPU: 2 PID: 1018 Comm: modprobe Not tainted 6.2.0-rc2.mptcp_ae5ac65fbed5+ #1641
+ Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.1-2.fc37 04/01/2014
+ Call Trace:
+  <TASK>
+  dump_stack_lvl+0x6a/0x9f
+  print_address_description.constprop.0+0x86/0x2b5
+  print_report+0x11b/0x1fb
+  kasan_report+0x87/0xc0
+  ops_init+0x2de/0x320
+  register_pernet_operations+0x2e4/0x750
+  register_pernet_subsys+0x24/0x40
+  tcf_register_action+0x9f/0x560
+  do_one_initcall+0xf9/0x570
+  do_init_module+0x190/0x650
+  load_module+0x1fa5/0x23c0
+  __do_sys_finit_module+0x10d/0x1b0
+  do_syscall_64+0x58/0x80
+  entry_SYSCALL_64_after_hwframe+0x72/0xdc
+ RIP: 0033:0x7f42518f778d
+ Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48
+       89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff
+       ff 73 01 c3 48 8b 0d cb 56 2c 00 f7 d8 64 89 01 48
+ RSP: 002b:00007fff96869688 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
+ RAX: ffffffffffffffda RBX: 00005568ef7f7c90 RCX: 00007f42518f778d
+ RDX: 0000000000000000 RSI: 00005568ef41d796 RDI: 0000000000000003
+ RBP: 00005568ef41d796 R08: 0000000000000000 R09: 0000000000000000
+ R10: 0000000000000003 R11: 0000000000000246 R12: 0000000000000000
+ R13: 00005568ef7f7d30 R14: 0000000000040000 R15: 0000000000000000
+  </TASK>
+
+This change addresses the issue by skipping the gen pointer
+de-reference in the mentioned error-path.
+
+Found by code inspection and verified with explicit error injection
+on a kasan-enabled kernel.
+
+Fixes: d266935ac43d ("net: fix UAF issue in nfqnl_nf_hook_drop() when ops_init() failed")
+Signed-off-by: Paolo Abeni <pabeni@redhat.com>
+Reviewed-by: Simon Horman <simon.horman@corigine.com>
+Link: https://lore.kernel.org/r/cec4e0f3bb2c77ac03a6154a8508d3930beb5f0f.1674154348.git.pabeni@redhat.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/core/net_namespace.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
+index b96df54d0036..534a53124d14 100644
+--- a/net/core/net_namespace.c
++++ b/net/core/net_namespace.c
+@@ -140,12 +140,12 @@ static int ops_init(const struct pernet_operations *ops, struct net *net)
+               return 0;
+       if (ops->id && ops->size) {
+-cleanup:
+               ng = rcu_dereference_protected(net->gen,
+                                              lockdep_is_held(&pernet_ops_rwsem));
+               ng->ptr[*ops->id] = NULL;
+       }
++cleanup:
+       kfree(data);
+ out:
+-- 
+2.39.0
+
diff --git a/queue-5.4/net-mdio-mux-meson-g12a-force-internal-phy-off-on-mu.patch b/queue-5.4/net-mdio-mux-meson-g12a-force-internal-phy-off-on-mu.patch
new file mode 100644 (file)
index 0000000..44f4fbb
--- /dev/null
@@ -0,0 +1,80 @@
+From a58b84797a1753c78b0619823a976126539c8bd0 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 24 Jan 2023 11:11:57 +0100
+Subject: net: mdio-mux-meson-g12a: force internal PHY off on mux switch
+
+From: Jerome Brunet <jbrunet@baylibre.com>
+
+[ Upstream commit 7083df59abbc2b7500db312cac706493be0273ff ]
+
+Force the internal PHY off then on when switching to the internal path.
+This fixes problems where the PHY ID is not properly set.
+
+Fixes: 7090425104db ("net: phy: add amlogic g12a mdio mux support")
+Suggested-by: Qi Duan <qi.duan@amlogic.com>
+Co-developed-by: Heiner Kallweit <hkallweit1@gmail.com>
+Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
+Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
+Link: https://lore.kernel.org/r/20230124101157.232234-1-jbrunet@baylibre.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/phy/mdio-mux-meson-g12a.c | 23 ++++++++++++++++-------
+ 1 file changed, 16 insertions(+), 7 deletions(-)
+
+diff --git a/drivers/net/phy/mdio-mux-meson-g12a.c b/drivers/net/phy/mdio-mux-meson-g12a.c
+index 7a9ad54582e1..aa3ad38e37d7 100644
+--- a/drivers/net/phy/mdio-mux-meson-g12a.c
++++ b/drivers/net/phy/mdio-mux-meson-g12a.c
+@@ -4,6 +4,7 @@
+  */
+ #include <linux/bitfield.h>
++#include <linux/delay.h>
+ #include <linux/clk.h>
+ #include <linux/clk-provider.h>
+ #include <linux/device.h>
+@@ -148,6 +149,7 @@ static const struct clk_ops g12a_ephy_pll_ops = {
+ static int g12a_enable_internal_mdio(struct g12a_mdio_mux *priv)
+ {
++      u32 value;
+       int ret;
+       /* Enable the phy clock */
+@@ -161,18 +163,25 @@ static int g12a_enable_internal_mdio(struct g12a_mdio_mux *priv)
+       /* Initialize ephy control */
+       writel(EPHY_G12A_ID, priv->regs + ETH_PHY_CNTL0);
+-      writel(FIELD_PREP(PHY_CNTL1_ST_MODE, 3) |
+-             FIELD_PREP(PHY_CNTL1_ST_PHYADD, EPHY_DFLT_ADD) |
+-             FIELD_PREP(PHY_CNTL1_MII_MODE, EPHY_MODE_RMII) |
+-             PHY_CNTL1_CLK_EN |
+-             PHY_CNTL1_CLKFREQ |
+-             PHY_CNTL1_PHY_ENB,
+-             priv->regs + ETH_PHY_CNTL1);
++
++      /* Make sure we get a 0 -> 1 transition on the enable bit */
++      value = FIELD_PREP(PHY_CNTL1_ST_MODE, 3) |
++              FIELD_PREP(PHY_CNTL1_ST_PHYADD, EPHY_DFLT_ADD) |
++              FIELD_PREP(PHY_CNTL1_MII_MODE, EPHY_MODE_RMII) |
++              PHY_CNTL1_CLK_EN |
++              PHY_CNTL1_CLKFREQ;
++      writel(value, priv->regs + ETH_PHY_CNTL1);
+       writel(PHY_CNTL2_USE_INTERNAL |
+              PHY_CNTL2_SMI_SRC_MAC |
+              PHY_CNTL2_RX_CLK_EPHY,
+              priv->regs + ETH_PHY_CNTL2);
++      value |= PHY_CNTL1_PHY_ENB;
++      writel(value, priv->regs + ETH_PHY_CNTL1);
++
++      /* The phy needs a bit of time to power up */
++      mdelay(10);
++
+       return 0;
+ }
+-- 
+2.39.0
+
diff --git a/queue-5.4/net-phy-mdio-i2c-move-header-file-to-include-linux-m.patch b/queue-5.4/net-phy-mdio-i2c-move-header-file-to-include-linux-m.patch
new file mode 100644 (file)
index 0000000..4090a6b
--- /dev/null
@@ -0,0 +1,85 @@
+From 5120e6ddc3ba17ce3d9c9d47d9366b4cbab95219 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 27 Aug 2020 04:00:29 +0200
+Subject: net/phy/mdio-i2c: Move header file to include/linux/mdio
+
+From: Andrew Lunn <andrew@lunn.ch>
+
+[ Upstream commit fcba68bd75bb1d42b3aec7f471d382a9e639a672 ]
+
+In preparation for moving all MDIO drivers into drivers/net/mdio, move
+the mdio-i2c header file into include/linux/mdio so it can be used by
+both the MDIO driver and the SFP code which instantiates I2C MDIO
+busses.
+
+v2:
+Add include/linux/mdio
+
+Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Andrew Lunn <andrew@lunn.ch>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Stable-dep-of: 7083df59abbc ("net: mdio-mux-meson-g12a: force internal PHY off on mux switch")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ MAINTAINERS                                        | 1 +
+ drivers/net/phy/mdio-i2c.c                         | 3 +--
+ drivers/net/phy/sfp.c                              | 2 +-
+ {drivers/net/phy => include/linux/mdio}/mdio-i2c.h | 0
+ 4 files changed, 3 insertions(+), 3 deletions(-)
+ rename {drivers/net/phy => include/linux/mdio}/mdio-i2c.h (100%)
+
+diff --git a/MAINTAINERS b/MAINTAINERS
+index 973fcc9143d1..ea8f1c885089 100644
+--- a/MAINTAINERS
++++ b/MAINTAINERS
+@@ -14661,6 +14661,7 @@ L:     netdev@vger.kernel.org
+ S:    Maintained
+ F:    drivers/net/phy/phylink.c
+ F:    drivers/net/phy/sfp*
++F:    include/linux/mdio/mdio-i2c.h
+ F:    include/linux/phylink.h
+ F:    include/linux/sfp.h
+ K:    phylink
+diff --git a/drivers/net/phy/mdio-i2c.c b/drivers/net/phy/mdio-i2c.c
+index 0dce67672548..5969878e0aa7 100644
+--- a/drivers/net/phy/mdio-i2c.c
++++ b/drivers/net/phy/mdio-i2c.c
+@@ -10,10 +10,9 @@
+  * of their settings.
+  */
+ #include <linux/i2c.h>
++#include <linux/mdio/mdio-i2c.h>
+ #include <linux/phy.h>
+-#include "mdio-i2c.h"
+-
+ /*
+  * I2C bus addresses 0x50 and 0x51 are normally an EEPROM, which is
+  * specified to be present in SFP modules.  These correspond with PHY
+diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
+index beaa00342a13..9639aa181968 100644
+--- a/drivers/net/phy/sfp.c
++++ b/drivers/net/phy/sfp.c
+@@ -7,6 +7,7 @@
+ #include <linux/i2c.h>
+ #include <linux/interrupt.h>
+ #include <linux/jiffies.h>
++#include <linux/mdio/mdio-i2c.h>
+ #include <linux/module.h>
+ #include <linux/mutex.h>
+ #include <linux/of.h>
+@@ -16,7 +17,6 @@
+ #include <linux/slab.h>
+ #include <linux/workqueue.h>
+-#include "mdio-i2c.h"
+ #include "sfp.h"
+ #include "swphy.h"
+diff --git a/drivers/net/phy/mdio-i2c.h b/include/linux/mdio/mdio-i2c.h
+similarity index 100%
+rename from drivers/net/phy/mdio-i2c.h
+rename to include/linux/mdio/mdio-i2c.h
+-- 
+2.39.0
+
diff --git a/queue-5.4/net-ravb-fix-possible-hang-if-ris2_qff1-happen.patch b/queue-5.4/net-ravb-fix-possible-hang-if-ris2_qff1-happen.patch
new file mode 100644 (file)
index 0000000..e894d91
--- /dev/null
@@ -0,0 +1,49 @@
+From 14c3cf9d6a3e4b5a5b184381c04476a14f152a92 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 24 Jan 2023 09:02:11 +0900
+Subject: net: ravb: Fix possible hang if RIS2_QFF1 happen
+
+From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
+
+[ Upstream commit f3c07758c9007a6bfff5290d9e19d3c41930c897 ]
+
+Since this driver enables the interrupt by RIC2_QFE1, this driver
+should clear the interrupt flag if it happens. Otherwise, the interrupt
+causes to hang the system.
+
+Note that this also fix a minor coding style (a comment indentation)
+around the fixed code.
+
+Fixes: c156633f1353 ("Renesas Ethernet AVB driver proper")
+Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
+Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/renesas/ravb_main.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
+index 3fd5155bdd5f..231a1295c470 100644
+--- a/drivers/net/ethernet/renesas/ravb_main.c
++++ b/drivers/net/ethernet/renesas/ravb_main.c
+@@ -736,14 +736,14 @@ static void ravb_error_interrupt(struct net_device *ndev)
+       ravb_write(ndev, ~(EIS_QFS | EIS_RESERVED), EIS);
+       if (eis & EIS_QFS) {
+               ris2 = ravb_read(ndev, RIS2);
+-              ravb_write(ndev, ~(RIS2_QFF0 | RIS2_RFFF | RIS2_RESERVED),
++              ravb_write(ndev, ~(RIS2_QFF0 | RIS2_QFF1 | RIS2_RFFF | RIS2_RESERVED),
+                          RIS2);
+               /* Receive Descriptor Empty int */
+               if (ris2 & RIS2_QFF0)
+                       priv->stats[RAVB_BE].rx_over_errors++;
+-                  /* Receive Descriptor Empty int */
++              /* Receive Descriptor Empty int */
+               if (ris2 & RIS2_QFF1)
+                       priv->stats[RAVB_NC].rx_over_errors++;
+-- 
+2.39.0
+
diff --git a/queue-5.4/net-sched-sch_taprio-do-not-schedule-in-taprio_reset.patch b/queue-5.4/net-sched-sch_taprio-do-not-schedule-in-taprio_reset.patch
new file mode 100644 (file)
index 0000000..e1c4990
--- /dev/null
@@ -0,0 +1,89 @@
+From 39f002fa3fcca6fcf1cceca25102db82634b4403 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 23 Jan 2023 08:45:52 +0000
+Subject: net/sched: sch_taprio: do not schedule in taprio_reset()
+
+From: Eric Dumazet <edumazet@google.com>
+
+[ Upstream commit ea4fdbaa2f7798cb25adbe4fd52ffc6356f097bb ]
+
+As reported by syzbot and hinted by Vinicius, I should not have added
+a qdisc_synchronize() call in taprio_reset()
+
+taprio_reset() can be called with qdisc spinlock held (and BH disabled)
+as shown in included syzbot report [1].
+
+Only taprio_destroy() needed this synchronization, as explained
+in the blamed commit changelog.
+
+[1]
+
+BUG: scheduling while atomic: syz-executor150/5091/0x00000202
+2 locks held by syz-executor150/5091:
+Modules linked in:
+Preemption disabled at:
+[<0000000000000000>] 0x0
+Kernel panic - not syncing: scheduling while atomic: panic_on_warn set ...
+CPU: 1 PID: 5091 Comm: syz-executor150 Not tainted 6.2.0-rc3-syzkaller-00219-g010a74f52203 #0
+Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/12/2023
+Call Trace:
+<TASK>
+__dump_stack lib/dump_stack.c:88 [inline]
+dump_stack_lvl+0xd1/0x138 lib/dump_stack.c:106
+panic+0x2cc/0x626 kernel/panic.c:318
+check_panic_on_warn.cold+0x19/0x35 kernel/panic.c:238
+__schedule_bug.cold+0xd5/0xfe kernel/sched/core.c:5836
+schedule_debug kernel/sched/core.c:5865 [inline]
+__schedule+0x34e4/0x5450 kernel/sched/core.c:6500
+schedule+0xde/0x1b0 kernel/sched/core.c:6682
+schedule_timeout+0x14e/0x2a0 kernel/time/timer.c:2167
+schedule_timeout_uninterruptible kernel/time/timer.c:2201 [inline]
+msleep+0xb6/0x100 kernel/time/timer.c:2322
+qdisc_synchronize include/net/sch_generic.h:1295 [inline]
+taprio_reset+0x93/0x270 net/sched/sch_taprio.c:1703
+qdisc_reset+0x10c/0x770 net/sched/sch_generic.c:1022
+dev_reset_queue+0x92/0x130 net/sched/sch_generic.c:1285
+netdev_for_each_tx_queue include/linux/netdevice.h:2464 [inline]
+dev_deactivate_many+0x36d/0x9f0 net/sched/sch_generic.c:1351
+dev_deactivate+0xed/0x1b0 net/sched/sch_generic.c:1374
+qdisc_graft+0xe4a/0x1380 net/sched/sch_api.c:1080
+tc_modify_qdisc+0xb6b/0x19a0 net/sched/sch_api.c:1689
+rtnetlink_rcv_msg+0x43e/0xca0 net/core/rtnetlink.c:6141
+netlink_rcv_skb+0x165/0x440 net/netlink/af_netlink.c:2564
+netlink_unicast_kernel net/netlink/af_netlink.c:1330 [inline]
+netlink_unicast+0x547/0x7f0 net/netlink/af_netlink.c:1356
+netlink_sendmsg+0x91b/0xe10 net/netlink/af_netlink.c:1932
+sock_sendmsg_nosec net/socket.c:714 [inline]
+sock_sendmsg+0xd3/0x120 net/socket.c:734
+____sys_sendmsg+0x712/0x8c0 net/socket.c:2476
+___sys_sendmsg+0x110/0x1b0 net/socket.c:2530
+__sys_sendmsg+0xf7/0x1c0 net/socket.c:2559
+do_syscall_x64 arch/x86/entry/common.c:50 [inline]
+
+Fixes: 3a415d59c1db ("net/sched: sch_taprio: fix possible use-after-free")
+Link: https://lore.kernel.org/netdev/167387581653.2747.13878941339893288655.git-patchwork-notify@kernel.org/T/
+Reported-by: syzbot <syzkaller@googlegroups.com>
+Signed-off-by: Eric Dumazet <edumazet@google.com>
+Cc: Vinicius Costa Gomes <vinicius.gomes@intel.com>
+Link: https://lore.kernel.org/r/20230123084552.574396-1-edumazet@google.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/sched/sch_taprio.c | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
+index 4278a466cb50..b7bd8c3e3158 100644
+--- a/net/sched/sch_taprio.c
++++ b/net/sched/sch_taprio.c
+@@ -1622,7 +1622,6 @@ static void taprio_reset(struct Qdisc *sch)
+       int i;
+       hrtimer_cancel(&q->advance_timer);
+-      qdisc_synchronize(sch);
+       if (q->qdiscs) {
+               for (i = 0; i < dev->num_tx_queues && q->qdiscs[i]; i++)
+-- 
+2.39.0
+
diff --git a/queue-5.4/net-tg3-resolve-deadlock-in-tg3_reset_task-during-ee.patch b/queue-5.4/net-tg3-resolve-deadlock-in-tg3_reset_task-during-ee.patch
new file mode 100644 (file)
index 0000000..7dafdae
--- /dev/null
@@ -0,0 +1,119 @@
+From 3a5937840bbbcd6218b15f0f26da22a0c5032ec4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 24 Jan 2023 13:53:39 -0500
+Subject: net/tg3: resolve deadlock in tg3_reset_task() during EEH
+
+From: David Christensen <drc@linux.vnet.ibm.com>
+
+[ Upstream commit 6c4ca03bd890566d873e3593b32d034bf2f5a087 ]
+
+During EEH error injection testing, a deadlock was encountered in the tg3
+driver when tg3_io_error_detected() was attempting to cancel outstanding
+reset tasks:
+
+crash> foreach UN bt
+...
+PID: 159    TASK: c0000000067c6000  CPU: 8   COMMAND: "eehd"
+...
+ #5 [c00000000681f990] __cancel_work_timer at c00000000019fd18
+ #6 [c00000000681fa30] tg3_io_error_detected at c00800000295f098 [tg3]
+ #7 [c00000000681faf0] eeh_report_error at c00000000004e25c
+...
+
+PID: 290    TASK: c000000036e5f800  CPU: 6   COMMAND: "kworker/6:1"
+...
+ #4 [c00000003721fbc0] rtnl_lock at c000000000c940d8
+ #5 [c00000003721fbe0] tg3_reset_task at c008000002969358 [tg3]
+ #6 [c00000003721fc60] process_one_work at c00000000019e5c4
+...
+
+PID: 296    TASK: c000000037a65800  CPU: 21  COMMAND: "kworker/21:1"
+...
+ #4 [c000000037247bc0] rtnl_lock at c000000000c940d8
+ #5 [c000000037247be0] tg3_reset_task at c008000002969358 [tg3]
+ #6 [c000000037247c60] process_one_work at c00000000019e5c4
+...
+
+PID: 655    TASK: c000000036f49000  CPU: 16  COMMAND: "kworker/16:2"
+...:1
+
+ #4 [c0000000373ebbc0] rtnl_lock at c000000000c940d8
+ #5 [c0000000373ebbe0] tg3_reset_task at c008000002969358 [tg3]
+ #6 [c0000000373ebc60] process_one_work at c00000000019e5c4
+...
+
+Code inspection shows that both tg3_io_error_detected() and
+tg3_reset_task() attempt to acquire the RTNL lock at the beginning of
+their code blocks.  If tg3_reset_task() should happen to execute between
+the times when tg3_io_error_deteced() acquires the RTNL lock and
+tg3_reset_task_cancel() is called, a deadlock will occur.
+
+Moving tg3_reset_task_cancel() call earlier within the code block, prior
+to acquiring RTNL, prevents this from happening, but also exposes another
+deadlock issue where tg3_reset_task() may execute AFTER
+tg3_io_error_detected() has executed:
+
+crash> foreach UN bt
+PID: 159    TASK: c0000000067d2000  CPU: 9   COMMAND: "eehd"
+...
+ #4 [c000000006867a60] rtnl_lock at c000000000c940d8
+ #5 [c000000006867a80] tg3_io_slot_reset at c0080000026c2ea8 [tg3]
+ #6 [c000000006867b00] eeh_report_reset at c00000000004de88
+...
+PID: 363    TASK: c000000037564000  CPU: 6   COMMAND: "kworker/6:1"
+...
+ #3 [c000000036c1bb70] msleep at c000000000259e6c
+ #4 [c000000036c1bba0] napi_disable at c000000000c6b848
+ #5 [c000000036c1bbe0] tg3_reset_task at c0080000026d942c [tg3]
+ #6 [c000000036c1bc60] process_one_work at c00000000019e5c4
+...
+
+This issue can be avoided by aborting tg3_reset_task() if EEH error
+recovery is already in progress.
+
+Fixes: db84bf43ef23 ("tg3: tg3_reset_task() needs to use rtnl_lock to synchronize")
+Signed-off-by: David Christensen <drc@linux.vnet.ibm.com>
+Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
+Link: https://lore.kernel.org/r/20230124185339.225806-1-drc@linux.vnet.ibm.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/broadcom/tg3.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
+index a9962474d551..d0cd86af29d9 100644
+--- a/drivers/net/ethernet/broadcom/tg3.c
++++ b/drivers/net/ethernet/broadcom/tg3.c
+@@ -11195,7 +11195,7 @@ static void tg3_reset_task(struct work_struct *work)
+       rtnl_lock();
+       tg3_full_lock(tp, 0);
+-      if (!netif_running(tp->dev)) {
++      if (tp->pcierr_recovery || !netif_running(tp->dev)) {
+               tg3_flag_clear(tp, RESET_TASK_PENDING);
+               tg3_full_unlock(tp);
+               rtnl_unlock();
+@@ -18187,6 +18187,9 @@ static pci_ers_result_t tg3_io_error_detected(struct pci_dev *pdev,
+       netdev_info(netdev, "PCI I/O error detected\n");
++      /* Want to make sure that the reset task doesn't run */
++      tg3_reset_task_cancel(tp);
++
+       rtnl_lock();
+       /* Could be second call or maybe we don't have netdev yet */
+@@ -18203,9 +18206,6 @@ static pci_ers_result_t tg3_io_error_detected(struct pci_dev *pdev,
+       tg3_timer_stop(tp);
+-      /* Want to make sure that the reset task doesn't run */
+-      tg3_reset_task_cancel(tp);
+-
+       netif_device_detach(netdev);
+       /* Clean up software state, even if MMIO is blocked */
+-- 
+2.39.0
+
diff --git a/queue-5.4/net-xgene-move-shared-header-file-into-include-linux.patch b/queue-5.4/net-xgene-move-shared-header-file-into-include-linux.patch
new file mode 100644 (file)
index 0000000..1c7b908
--- /dev/null
@@ -0,0 +1,76 @@
+From a47670ad3c1d411547943033c0235b65840952f6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 27 Aug 2020 04:00:30 +0200
+Subject: net: xgene: Move shared header file into include/linux
+
+From: Andrew Lunn <andrew@lunn.ch>
+
+[ Upstream commit 232e15e1d7ddb191c28248cb681f4544c0ff1c54 ]
+
+This header file is currently included into the ethernet driver via a
+relative path into the PHY subsystem. This is bad practice, and causes
+issues for the upcoming move of the MDIO driver. Move the header file
+into include/linux to clean this up.
+
+v2:
+Move header to include/linux/mdio
+
+Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: Andrew Lunn <andrew@lunn.ch>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Stable-dep-of: 7083df59abbc ("net: mdio-mux-meson-g12a: force internal PHY off on mux switch")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/apm/xgene/xgene_enet_main.h     | 2 +-
+ drivers/net/phy/mdio-xgene.c                         | 2 +-
+ {drivers/net/phy => include/linux/mdio}/mdio-xgene.h | 0
+ 3 files changed, 2 insertions(+), 2 deletions(-)
+ rename {drivers/net/phy => include/linux/mdio}/mdio-xgene.h (100%)
+
+diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.h b/drivers/net/ethernet/apm/xgene/xgene_enet_main.h
+index 18f4923b1723..6a253f81c555 100644
+--- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.h
++++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.h
+@@ -18,6 +18,7 @@
+ #include <linux/of_platform.h>
+ #include <linux/of_net.h>
+ #include <linux/of_mdio.h>
++#include <linux/mdio/mdio-xgene.h>
+ #include <linux/module.h>
+ #include <net/ip.h>
+ #include <linux/prefetch.h>
+@@ -26,7 +27,6 @@
+ #include "xgene_enet_hw.h"
+ #include "xgene_enet_cle.h"
+ #include "xgene_enet_ring2.h"
+-#include "../../../phy/mdio-xgene.h"
+ #define XGENE_DRV_VERSION     "v1.0"
+ #define ETHER_MIN_PACKET      64
+diff --git a/drivers/net/phy/mdio-xgene.c b/drivers/net/phy/mdio-xgene.c
+index 34990eaa3298..461207cdf5d6 100644
+--- a/drivers/net/phy/mdio-xgene.c
++++ b/drivers/net/phy/mdio-xgene.c
+@@ -11,6 +11,7 @@
+ #include <linux/efi.h>
+ #include <linux/if_vlan.h>
+ #include <linux/io.h>
++#include <linux/mdio/mdio-xgene.h>
+ #include <linux/module.h>
+ #include <linux/of_platform.h>
+ #include <linux/of_net.h>
+@@ -18,7 +19,6 @@
+ #include <linux/prefetch.h>
+ #include <linux/phy.h>
+ #include <net/ip.h>
+-#include "mdio-xgene.h"
+ static bool xgene_mdio_status;
+diff --git a/drivers/net/phy/mdio-xgene.h b/include/linux/mdio/mdio-xgene.h
+similarity index 100%
+rename from drivers/net/phy/mdio-xgene.h
+rename to include/linux/mdio/mdio-xgene.h
+-- 
+2.39.0
+
diff --git a/queue-5.4/netfilter-conntrack-fix-bug-in-for_each_sctp_chunk.patch b/queue-5.4/netfilter-conntrack-fix-bug-in-for_each_sctp_chunk.patch
new file mode 100644 (file)
index 0000000..c20e8aa
--- /dev/null
@@ -0,0 +1,42 @@
+From c2c3a7a150f040ed17c41b906c11d609ec5096ef Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 24 Jan 2023 02:47:19 +0100
+Subject: netfilter: conntrack: fix bug in for_each_sctp_chunk
+
+From: Sriram Yagnaraman <sriram.yagnaraman@est.tech>
+
+[ Upstream commit 98ee0077452527f971567db01386de3c3d97ce13 ]
+
+skb_header_pointer() will return NULL if offset + sizeof(_sch) exceeds
+skb->len, so this offset < skb->len test is redundant.
+
+if sch->length == 0, this will end up in an infinite loop, add a check
+for sch->length > 0
+
+Fixes: 9fb9cbb1082d ("[NETFILTER]: Add nf_conntrack subsystem.")
+Suggested-by: Florian Westphal <fw@strlen.de>
+Signed-off-by: Sriram Yagnaraman <sriram.yagnaraman@est.tech>
+Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/netfilter/nf_conntrack_proto_sctp.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c
+index 72d0aa603cd6..c0264bbc8466 100644
+--- a/net/netfilter/nf_conntrack_proto_sctp.c
++++ b/net/netfilter/nf_conntrack_proto_sctp.c
+@@ -155,8 +155,8 @@ static void sctp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
+ #define for_each_sctp_chunk(skb, sch, _sch, offset, dataoff, count)   \
+ for ((offset) = (dataoff) + sizeof(struct sctphdr), (count) = 0;      \
+-      (offset) < (skb)->len &&                                        \
+-      ((sch) = skb_header_pointer((skb), (offset), sizeof(_sch), &(_sch)));   \
++      ((sch) = skb_header_pointer((skb), (offset), sizeof(_sch), &(_sch))) && \
++      (sch)->length;  \
+       (offset) += (ntohs((sch)->length) + 3) & ~3, (count)++)
+ /* Some validity checks to make sure the chunks are fine */
+-- 
+2.39.0
+
diff --git a/queue-5.4/netfilter-conntrack-fix-vtag-checks-for-abort-shutdo.patch b/queue-5.4/netfilter-conntrack-fix-vtag-checks-for-abort-shutdo.patch
new file mode 100644 (file)
index 0000000..d0e1d89
--- /dev/null
@@ -0,0 +1,71 @@
+From 38a6a38f76a09a6dbd805904b8afbcf814421d2c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 24 Jan 2023 02:47:18 +0100
+Subject: netfilter: conntrack: fix vtag checks for ABORT/SHUTDOWN_COMPLETE
+
+From: Sriram Yagnaraman <sriram.yagnaraman@est.tech>
+
+[ Upstream commit a9993591fa94246b16b444eea55d84c54608282a ]
+
+RFC 9260, Sec 8.5.1 states that for ABORT/SHUTDOWN_COMPLETE, the chunk
+MUST be accepted if the vtag of the packet matches its own tag and the
+T bit is not set OR if it is set to its peer's vtag and the T bit is set
+in chunk flags. Otherwise the packet MUST be silently dropped.
+
+Update vtag verification for ABORT/SHUTDOWN_COMPLETE based on the above
+description.
+
+Fixes: 9fb9cbb1082d ("[NETFILTER]: Add nf_conntrack subsystem.")
+Signed-off-by: Sriram Yagnaraman <sriram.yagnaraman@est.tech>
+Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/netfilter/nf_conntrack_proto_sctp.c | 25 ++++++++++++++++---------
+ 1 file changed, 16 insertions(+), 9 deletions(-)
+
+diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c
+index 7626f3e1c70a..72d0aa603cd6 100644
+--- a/net/netfilter/nf_conntrack_proto_sctp.c
++++ b/net/netfilter/nf_conntrack_proto_sctp.c
+@@ -412,22 +412,29 @@ int nf_conntrack_sctp_packet(struct nf_conn *ct,
+       for_each_sctp_chunk (skb, sch, _sch, offset, dataoff, count) {
+               /* Special cases of Verification tag check (Sec 8.5.1) */
+               if (sch->type == SCTP_CID_INIT) {
+-                      /* Sec 8.5.1 (A) */
++                      /* (A) vtag MUST be zero */
+                       if (sh->vtag != 0)
+                               goto out_unlock;
+               } else if (sch->type == SCTP_CID_ABORT) {
+-                      /* Sec 8.5.1 (B) */
+-                      if (sh->vtag != ct->proto.sctp.vtag[dir] &&
+-                          sh->vtag != ct->proto.sctp.vtag[!dir])
++                      /* (B) vtag MUST match own vtag if T flag is unset OR
++                       * MUST match peer's vtag if T flag is set
++                       */
++                      if ((!(sch->flags & SCTP_CHUNK_FLAG_T) &&
++                           sh->vtag != ct->proto.sctp.vtag[dir]) ||
++                          ((sch->flags & SCTP_CHUNK_FLAG_T) &&
++                           sh->vtag != ct->proto.sctp.vtag[!dir]))
+                               goto out_unlock;
+               } else if (sch->type == SCTP_CID_SHUTDOWN_COMPLETE) {
+-                      /* Sec 8.5.1 (C) */
+-                      if (sh->vtag != ct->proto.sctp.vtag[dir] &&
+-                          sh->vtag != ct->proto.sctp.vtag[!dir] &&
+-                          sch->flags & SCTP_CHUNK_FLAG_T)
++                      /* (C) vtag MUST match own vtag if T flag is unset OR
++                       * MUST match peer's vtag if T flag is set
++                       */
++                      if ((!(sch->flags & SCTP_CHUNK_FLAG_T) &&
++                           sh->vtag != ct->proto.sctp.vtag[dir]) ||
++                          ((sch->flags & SCTP_CHUNK_FLAG_T) &&
++                           sh->vtag != ct->proto.sctp.vtag[!dir]))
+                               goto out_unlock;
+               } else if (sch->type == SCTP_CID_COOKIE_ECHO) {
+-                      /* Sec 8.5.1 (D) */
++                      /* (D) vtag must be same as init_vtag as found in INIT_ACK */
+                       if (sh->vtag != ct->proto.sctp.vtag[dir])
+                               goto out_unlock;
+               } else if (sch->type == SCTP_CID_HEARTBEAT) {
+-- 
+2.39.0
+
diff --git a/queue-5.4/netfilter-nft_set_rbtree-skip-elements-in-transactio.patch b/queue-5.4/netfilter-nft_set_rbtree-skip-elements-in-transactio.patch
new file mode 100644 (file)
index 0000000..b495dc2
--- /dev/null
@@ -0,0 +1,69 @@
+From 1985a3899c8525a6d75586942116f090ffd91009 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 14 Jan 2023 23:49:46 +0100
+Subject: netfilter: nft_set_rbtree: skip elements in transaction from garbage
+ collection
+
+From: Pablo Neira Ayuso <pablo@netfilter.org>
+
+[ Upstream commit 5d235d6ce75c12a7fdee375eb211e4116f7ab01b ]
+
+Skip interference with an ongoing transaction, do not perform garbage
+collection on inactive elements. Reset annotated previous end interval
+if the expired element is marked as busy (control plane removed the
+element right before expiration).
+
+Fixes: 8d8540c4f5e0 ("netfilter: nft_set_rbtree: add timeout support")
+Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
+Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/netfilter/nft_set_rbtree.c | 16 +++++++++++++++-
+ 1 file changed, 15 insertions(+), 1 deletion(-)
+
+diff --git a/net/netfilter/nft_set_rbtree.c b/net/netfilter/nft_set_rbtree.c
+index ee7c29e0a9d7..093eea02f9d2 100644
+--- a/net/netfilter/nft_set_rbtree.c
++++ b/net/netfilter/nft_set_rbtree.c
+@@ -389,23 +389,37 @@ static void nft_rbtree_gc(struct work_struct *work)
+       struct nft_rbtree *priv;
+       struct rb_node *node;
+       struct nft_set *set;
++      struct net *net;
++      u8 genmask;
+       priv = container_of(work, struct nft_rbtree, gc_work.work);
+       set  = nft_set_container_of(priv);
++      net  = read_pnet(&set->net);
++      genmask = nft_genmask_cur(net);
+       write_lock_bh(&priv->lock);
+       write_seqcount_begin(&priv->count);
+       for (node = rb_first(&priv->root); node != NULL; node = rb_next(node)) {
+               rbe = rb_entry(node, struct nft_rbtree_elem, node);
++              if (!nft_set_elem_active(&rbe->ext, genmask))
++                      continue;
++
++              /* elements are reversed in the rbtree for historical reasons,
++               * from highest to lowest value, that is why end element is
++               * always visited before the start element.
++               */
+               if (nft_rbtree_interval_end(rbe)) {
+                       rbe_end = rbe;
+                       continue;
+               }
+               if (!nft_set_elem_expired(&rbe->ext))
+                       continue;
+-              if (nft_set_elem_mark_busy(&rbe->ext))
++
++              if (nft_set_elem_mark_busy(&rbe->ext)) {
++                      rbe_end = NULL;
+                       continue;
++              }
+               if (rbe_prev) {
+                       rb_erase(&rbe_prev->node, &priv->root);
+-- 
+2.39.0
+
diff --git a/queue-5.4/netlink-annotate-data-races-around-dst_portid-and-ds.patch b/queue-5.4/netlink-annotate-data-races-around-dst_portid-and-ds.patch
new file mode 100644 (file)
index 0000000..f5039eb
--- /dev/null
@@ -0,0 +1,87 @@
+From 8a6327aa57725a9875c83bd559ae28a2826ed606 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 20 Jan 2023 12:59:54 +0000
+Subject: netlink: annotate data races around dst_portid and dst_group
+
+From: Eric Dumazet <edumazet@google.com>
+
+[ Upstream commit 004db64d185a5f23dfb891d7701e23713b2420ee ]
+
+netlink_getname(), netlink_sendmsg() and netlink_getsockbyportid()
+can read nlk->dst_portid and nlk->dst_group while another
+thread is changing them.
+
+Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
+Signed-off-by: Eric Dumazet <edumazet@google.com>
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/netlink/af_netlink.c | 23 ++++++++++++++---------
+ 1 file changed, 14 insertions(+), 9 deletions(-)
+
+diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
+index f6b985877d9c..d398623d8275 100644
+--- a/net/netlink/af_netlink.c
++++ b/net/netlink/af_netlink.c
+@@ -1081,8 +1081,9 @@ static int netlink_connect(struct socket *sock, struct sockaddr *addr,
+       if (addr->sa_family == AF_UNSPEC) {
+               sk->sk_state    = NETLINK_UNCONNECTED;
+-              nlk->dst_portid = 0;
+-              nlk->dst_group  = 0;
++              /* dst_portid and dst_group can be read locklessly */
++              WRITE_ONCE(nlk->dst_portid, 0);
++              WRITE_ONCE(nlk->dst_group, 0);
+               return 0;
+       }
+       if (addr->sa_family != AF_NETLINK)
+@@ -1104,8 +1105,9 @@ static int netlink_connect(struct socket *sock, struct sockaddr *addr,
+       if (err == 0) {
+               sk->sk_state    = NETLINK_CONNECTED;
+-              nlk->dst_portid = nladdr->nl_pid;
+-              nlk->dst_group  = ffs(nladdr->nl_groups);
++              /* dst_portid and dst_group can be read locklessly */
++              WRITE_ONCE(nlk->dst_portid, nladdr->nl_pid);
++              WRITE_ONCE(nlk->dst_group, ffs(nladdr->nl_groups));
+       }
+       return err;
+@@ -1122,8 +1124,9 @@ static int netlink_getname(struct socket *sock, struct sockaddr *addr,
+       nladdr->nl_pad = 0;
+       if (peer) {
+-              nladdr->nl_pid = nlk->dst_portid;
+-              nladdr->nl_groups = netlink_group_mask(nlk->dst_group);
++              /* Paired with WRITE_ONCE() in netlink_connect() */
++              nladdr->nl_pid = READ_ONCE(nlk->dst_portid);
++              nladdr->nl_groups = netlink_group_mask(READ_ONCE(nlk->dst_group));
+       } else {
+               /* Paired with WRITE_ONCE() in netlink_insert() */
+               nladdr->nl_pid = READ_ONCE(nlk->portid);
+@@ -1153,8 +1156,9 @@ static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
+       /* Don't bother queuing skb if kernel socket has no input function */
+       nlk = nlk_sk(sock);
++      /* dst_portid can be changed in netlink_connect() */
+       if (sock->sk_state == NETLINK_CONNECTED &&
+-          nlk->dst_portid != nlk_sk(ssk)->portid) {
++          READ_ONCE(nlk->dst_portid) != nlk_sk(ssk)->portid) {
+               sock_put(sock);
+               return ERR_PTR(-ECONNREFUSED);
+       }
+@@ -1890,8 +1894,9 @@ static int netlink_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
+                       goto out;
+               netlink_skb_flags |= NETLINK_SKB_DST;
+       } else {
+-              dst_portid = nlk->dst_portid;
+-              dst_group = nlk->dst_group;
++              /* Paired with WRITE_ONCE() in netlink_connect() */
++              dst_portid = READ_ONCE(nlk->dst_portid);
++              dst_group = READ_ONCE(nlk->dst_group);
+       }
+       /* Paired with WRITE_ONCE() in netlink_insert() */
+-- 
+2.39.0
+
diff --git a/queue-5.4/netlink-annotate-data-races-around-nlk-portid.patch b/queue-5.4/netlink-annotate-data-races-around-nlk-portid.patch
new file mode 100644 (file)
index 0000000..4080419
--- /dev/null
@@ -0,0 +1,87 @@
+From 283052f728f5d9d6593810ae9def7c9456e5843b Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 20 Jan 2023 12:59:53 +0000
+Subject: netlink: annotate data races around nlk->portid
+
+From: Eric Dumazet <edumazet@google.com>
+
+[ Upstream commit c1bb9484e3b05166880da8574504156ccbd0549e ]
+
+syzbot reminds us netlink_getname() runs locklessly [1]
+
+This first patch annotates the race against nlk->portid.
+
+Following patches take care of the remaining races.
+
+[1]
+BUG: KCSAN: data-race in netlink_getname / netlink_insert
+
+write to 0xffff88814176d310 of 4 bytes by task 2315 on cpu 1:
+netlink_insert+0xf1/0x9a0 net/netlink/af_netlink.c:583
+netlink_autobind+0xae/0x180 net/netlink/af_netlink.c:856
+netlink_sendmsg+0x444/0x760 net/netlink/af_netlink.c:1895
+sock_sendmsg_nosec net/socket.c:714 [inline]
+sock_sendmsg net/socket.c:734 [inline]
+____sys_sendmsg+0x38f/0x500 net/socket.c:2476
+___sys_sendmsg net/socket.c:2530 [inline]
+__sys_sendmsg+0x19a/0x230 net/socket.c:2559
+__do_sys_sendmsg net/socket.c:2568 [inline]
+__se_sys_sendmsg net/socket.c:2566 [inline]
+__x64_sys_sendmsg+0x42/0x50 net/socket.c:2566
+do_syscall_x64 arch/x86/entry/common.c:50 [inline]
+do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
+entry_SYSCALL_64_after_hwframe+0x63/0xcd
+
+read to 0xffff88814176d310 of 4 bytes by task 2316 on cpu 0:
+netlink_getname+0xcd/0x1a0 net/netlink/af_netlink.c:1144
+__sys_getsockname+0x11d/0x1b0 net/socket.c:2026
+__do_sys_getsockname net/socket.c:2041 [inline]
+__se_sys_getsockname net/socket.c:2038 [inline]
+__x64_sys_getsockname+0x3e/0x50 net/socket.c:2038
+do_syscall_x64 arch/x86/entry/common.c:50 [inline]
+do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
+entry_SYSCALL_64_after_hwframe+0x63/0xcd
+
+value changed: 0x00000000 -> 0xc9a49780
+
+Reported by Kernel Concurrency Sanitizer on:
+CPU: 0 PID: 2316 Comm: syz-executor.2 Not tainted 6.2.0-rc3-syzkaller-00030-ge8f60cd7db24-dirty #0
+Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
+
+Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
+Signed-off-by: Eric Dumazet <edumazet@google.com>
+Reported-by: syzbot <syzkaller@googlegroups.com>
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/netlink/af_netlink.c | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
+index 86b70385dce3..f6b985877d9c 100644
+--- a/net/netlink/af_netlink.c
++++ b/net/netlink/af_netlink.c
+@@ -569,7 +569,9 @@ static int netlink_insert(struct sock *sk, u32 portid)
+       if (nlk_sk(sk)->bound)
+               goto err;
+-      nlk_sk(sk)->portid = portid;
++      /* portid can be read locklessly from netlink_getname(). */
++      WRITE_ONCE(nlk_sk(sk)->portid, portid);
++
+       sock_hold(sk);
+       err = __netlink_insert(table, sk);
+@@ -1123,7 +1125,8 @@ static int netlink_getname(struct socket *sock, struct sockaddr *addr,
+               nladdr->nl_pid = nlk->dst_portid;
+               nladdr->nl_groups = netlink_group_mask(nlk->dst_group);
+       } else {
+-              nladdr->nl_pid = nlk->portid;
++              /* Paired with WRITE_ONCE() in netlink_insert() */
++              nladdr->nl_pid = READ_ONCE(nlk->portid);
+               netlink_lock_table();
+               nladdr->nl_groups = nlk->groups ? nlk->groups[0] : 0;
+               netlink_unlock_table();
+-- 
+2.39.0
+
diff --git a/queue-5.4/netlink-annotate-data-races-around-sk_state.patch b/queue-5.4/netlink-annotate-data-races-around-sk_state.patch
new file mode 100644 (file)
index 0000000..e83a306
--- /dev/null
@@ -0,0 +1,58 @@
+From bf7c71e766802bfacf91f5a4d85253517db0ad63 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 20 Jan 2023 12:59:55 +0000
+Subject: netlink: annotate data races around sk_state
+
+From: Eric Dumazet <edumazet@google.com>
+
+[ Upstream commit 9b663b5cbb15b494ef132a3c937641c90646eb73 ]
+
+netlink_getsockbyportid() reads sk_state while a concurrent
+netlink_connect() can change its value.
+
+Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
+Signed-off-by: Eric Dumazet <edumazet@google.com>
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/netlink/af_netlink.c | 10 ++++++----
+ 1 file changed, 6 insertions(+), 4 deletions(-)
+
+diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
+index d398623d8275..a232fcbd721c 100644
+--- a/net/netlink/af_netlink.c
++++ b/net/netlink/af_netlink.c
+@@ -1080,7 +1080,8 @@ static int netlink_connect(struct socket *sock, struct sockaddr *addr,
+               return -EINVAL;
+       if (addr->sa_family == AF_UNSPEC) {
+-              sk->sk_state    = NETLINK_UNCONNECTED;
++              /* paired with READ_ONCE() in netlink_getsockbyportid() */
++              WRITE_ONCE(sk->sk_state, NETLINK_UNCONNECTED);
+               /* dst_portid and dst_group can be read locklessly */
+               WRITE_ONCE(nlk->dst_portid, 0);
+               WRITE_ONCE(nlk->dst_group, 0);
+@@ -1104,7 +1105,8 @@ static int netlink_connect(struct socket *sock, struct sockaddr *addr,
+               err = netlink_autobind(sock);
+       if (err == 0) {
+-              sk->sk_state    = NETLINK_CONNECTED;
++              /* paired with READ_ONCE() in netlink_getsockbyportid() */
++              WRITE_ONCE(sk->sk_state, NETLINK_CONNECTED);
+               /* dst_portid and dst_group can be read locklessly */
+               WRITE_ONCE(nlk->dst_portid, nladdr->nl_pid);
+               WRITE_ONCE(nlk->dst_group, ffs(nladdr->nl_groups));
+@@ -1156,8 +1158,8 @@ static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
+       /* Don't bother queuing skb if kernel socket has no input function */
+       nlk = nlk_sk(sock);
+-      /* dst_portid can be changed in netlink_connect() */
+-      if (sock->sk_state == NETLINK_CONNECTED &&
++      /* dst_portid and sk_state can be changed in netlink_connect() */
++      if (READ_ONCE(sock->sk_state) == NETLINK_CONNECTED &&
+           READ_ONCE(nlk->dst_portid) != nlk_sk(ssk)->portid) {
+               sock_put(sock);
+               return ERR_PTR(-ECONNREFUSED);
+-- 
+2.39.0
+
diff --git a/queue-5.4/netlink-prevent-potential-spectre-v1-gadgets.patch b/queue-5.4/netlink-prevent-potential-spectre-v1-gadgets.patch
new file mode 100644 (file)
index 0000000..f08f2aa
--- /dev/null
@@ -0,0 +1,68 @@
+From 90740585650b0c76b52b3b6bc8fdd68c9d99986c Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 19 Jan 2023 11:01:50 +0000
+Subject: netlink: prevent potential spectre v1 gadgets
+
+From: Eric Dumazet <edumazet@google.com>
+
+[ Upstream commit f0950402e8c76e7dcb08563f1b4e8000fbc62455 ]
+
+Most netlink attributes are parsed and validated from
+__nla_validate_parse() or validate_nla()
+
+    u16 type = nla_type(nla);
+
+    if (type == 0 || type > maxtype) {
+        /* error or continue */
+    }
+
+@type is then used as an array index and can be used
+as a Spectre v1 gadget.
+
+array_index_nospec() can be used to prevent leaking
+content of kernel memory to malicious users.
+
+This should take care of vast majority of netlink uses,
+but an audit is needed to take care of others where
+validation is not yet centralized in core netlink functions.
+
+Fixes: bfa83a9e03cf ("[NETLINK]: Type-safe netlink messages/attributes interface")
+Signed-off-by: Eric Dumazet <edumazet@google.com>
+Link: https://lore.kernel.org/r/20230119110150.2678537-1-edumazet@google.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ lib/nlattr.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/lib/nlattr.c b/lib/nlattr.c
+index 0d84f79cb4b5..b5ce5e46c06e 100644
+--- a/lib/nlattr.c
++++ b/lib/nlattr.c
+@@ -10,6 +10,7 @@
+ #include <linux/kernel.h>
+ #include <linux/errno.h>
+ #include <linux/jiffies.h>
++#include <linux/nospec.h>
+ #include <linux/skbuff.h>
+ #include <linux/string.h>
+ #include <linux/types.h>
+@@ -169,6 +170,7 @@ static int validate_nla(const struct nlattr *nla, int maxtype,
+       if (type <= 0 || type > maxtype)
+               return 0;
++      type = array_index_nospec(type, maxtype + 1);
+       pt = &policy[type];
+       BUG_ON(pt->type > NLA_TYPE_MAX);
+@@ -377,6 +379,7 @@ static int __nla_validate_parse(const struct nlattr *head, int len, int maxtype,
+                       }
+                       continue;
+               }
++              type = array_index_nospec(type, maxtype + 1);
+               if (policy) {
+                       int err = validate_nla(nla, maxtype, policy,
+                                              validate, extack);
+-- 
+2.39.0
+
diff --git a/queue-5.4/netrom-fix-use-after-free-of-a-listening-socket.patch b/queue-5.4/netrom-fix-use-after-free-of-a-listening-socket.patch
new file mode 100644 (file)
index 0000000..5dd039d
--- /dev/null
@@ -0,0 +1,161 @@
+From 88d4c29746a7aeee7c398dc3e24b9fead14d231a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 20 Jan 2023 15:19:27 -0800
+Subject: netrom: Fix use-after-free of a listening socket.
+
+From: Kuniyuki Iwashima <kuniyu@amazon.com>
+
+[ Upstream commit 409db27e3a2eb5e8ef7226ca33be33361b3ed1c9 ]
+
+syzbot reported a use-after-free in do_accept(), precisely nr_accept()
+as sk_prot_alloc() allocated the memory and sock_put() frees it. [0]
+
+The issue could happen if the heartbeat timer is fired and
+nr_heartbeat_expiry() calls nr_destroy_socket(), where a socket
+has SOCK_DESTROY or a listening socket has SOCK_DEAD.
+
+In this case, the first condition cannot be true.  SOCK_DESTROY is
+flagged in nr_release() only when the file descriptor is close()d,
+but accept() is being called for the listening socket, so the second
+condition must be true.
+
+Usually, the AF_NETROM listener neither starts timers nor sets
+SOCK_DEAD.  However, the condition is met if connect() fails before
+listen().  connect() starts the t1 timer and heartbeat timer, and
+t1timer calls nr_disconnect() when timeout happens.  Then, SOCK_DEAD
+is set, and if we call listen(), the heartbeat timer calls
+nr_destroy_socket().
+
+  nr_connect
+    nr_establish_data_link(sk)
+      nr_start_t1timer(sk)
+    nr_start_heartbeat(sk)
+                                    nr_t1timer_expiry
+                                      nr_disconnect(sk, ETIMEDOUT)
+                                        nr_sk(sk)->state = NR_STATE_0
+                                        sk->sk_state = TCP_CLOSE
+                                        sock_set_flag(sk, SOCK_DEAD)
+nr_listen
+  if (sk->sk_state != TCP_LISTEN)
+    sk->sk_state = TCP_LISTEN
+                                    nr_heartbeat_expiry
+                                      switch (nr->state)
+                                      case NR_STATE_0
+                                        if (sk->sk_state == TCP_LISTEN &&
+                                            sock_flag(sk, SOCK_DEAD))
+                                          nr_destroy_socket(sk)
+
+This path seems expected, and nr_destroy_socket() is called to clean
+up resources.  Initially, there was sock_hold() before nr_destroy_socket()
+so that the socket would not be freed, but the commit 517a16b1a88b
+("netrom: Decrease sock refcount when sock timers expire") accidentally
+removed it.
+
+To fix use-after-free, let's add sock_hold().
+
+[0]:
+BUG: KASAN: use-after-free in do_accept+0x483/0x510 net/socket.c:1848
+Read of size 8 at addr ffff88807978d398 by task syz-executor.3/5315
+
+CPU: 0 PID: 5315 Comm: syz-executor.3 Not tainted 6.2.0-rc3-syzkaller-00165-gd9fc1511728c #0
+Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
+Call Trace:
+ <TASK>
+ __dump_stack lib/dump_stack.c:88 [inline]
+ dump_stack_lvl+0xd1/0x138 lib/dump_stack.c:106
+ print_address_description mm/kasan/report.c:306 [inline]
+ print_report+0x15e/0x461 mm/kasan/report.c:417
+ kasan_report+0xbf/0x1f0 mm/kasan/report.c:517
+ do_accept+0x483/0x510 net/socket.c:1848
+ __sys_accept4_file net/socket.c:1897 [inline]
+ __sys_accept4+0x9a/0x120 net/socket.c:1927
+ __do_sys_accept net/socket.c:1944 [inline]
+ __se_sys_accept net/socket.c:1941 [inline]
+ __x64_sys_accept+0x75/0xb0 net/socket.c:1941
+ do_syscall_x64 arch/x86/entry/common.c:50 [inline]
+ do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
+ entry_SYSCALL_64_after_hwframe+0x63/0xcd
+RIP: 0033:0x7fa436a8c0c9
+Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
+RSP: 002b:00007fa437784168 EFLAGS: 00000246 ORIG_RAX: 000000000000002b
+RAX: ffffffffffffffda RBX: 00007fa436bac050 RCX: 00007fa436a8c0c9
+RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000005
+RBP: 00007fa436ae7ae9 R08: 0000000000000000 R09: 0000000000000000
+R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
+R13: 00007ffebc6700df R14: 00007fa437784300 R15: 0000000000022000
+ </TASK>
+
+Allocated by task 5294:
+ kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
+ kasan_set_track+0x25/0x30 mm/kasan/common.c:52
+ ____kasan_kmalloc mm/kasan/common.c:371 [inline]
+ ____kasan_kmalloc mm/kasan/common.c:330 [inline]
+ __kasan_kmalloc+0xa3/0xb0 mm/kasan/common.c:380
+ kasan_kmalloc include/linux/kasan.h:211 [inline]
+ __do_kmalloc_node mm/slab_common.c:968 [inline]
+ __kmalloc+0x5a/0xd0 mm/slab_common.c:981
+ kmalloc include/linux/slab.h:584 [inline]
+ sk_prot_alloc+0x140/0x290 net/core/sock.c:2038
+ sk_alloc+0x3a/0x7a0 net/core/sock.c:2091
+ nr_create+0xb6/0x5f0 net/netrom/af_netrom.c:433
+ __sock_create+0x359/0x790 net/socket.c:1515
+ sock_create net/socket.c:1566 [inline]
+ __sys_socket_create net/socket.c:1603 [inline]
+ __sys_socket_create net/socket.c:1588 [inline]
+ __sys_socket+0x133/0x250 net/socket.c:1636
+ __do_sys_socket net/socket.c:1649 [inline]
+ __se_sys_socket net/socket.c:1647 [inline]
+ __x64_sys_socket+0x73/0xb0 net/socket.c:1647
+ do_syscall_x64 arch/x86/entry/common.c:50 [inline]
+ do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
+ entry_SYSCALL_64_after_hwframe+0x63/0xcd
+
+Freed by task 14:
+ kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
+ kasan_set_track+0x25/0x30 mm/kasan/common.c:52
+ kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:518
+ ____kasan_slab_free mm/kasan/common.c:236 [inline]
+ ____kasan_slab_free+0x13b/0x1a0 mm/kasan/common.c:200
+ kasan_slab_free include/linux/kasan.h:177 [inline]
+ __cache_free mm/slab.c:3394 [inline]
+ __do_kmem_cache_free mm/slab.c:3580 [inline]
+ __kmem_cache_free+0xcd/0x3b0 mm/slab.c:3587
+ sk_prot_free net/core/sock.c:2074 [inline]
+ __sk_destruct+0x5df/0x750 net/core/sock.c:2166
+ sk_destruct net/core/sock.c:2181 [inline]
+ __sk_free+0x175/0x460 net/core/sock.c:2192
+ sk_free+0x7c/0xa0 net/core/sock.c:2203
+ sock_put include/net/sock.h:1991 [inline]
+ nr_heartbeat_expiry+0x1d7/0x460 net/netrom/nr_timer.c:148
+ call_timer_fn+0x1da/0x7c0 kernel/time/timer.c:1700
+ expire_timers+0x2c6/0x5c0 kernel/time/timer.c:1751
+ __run_timers kernel/time/timer.c:2022 [inline]
+ __run_timers kernel/time/timer.c:1995 [inline]
+ run_timer_softirq+0x326/0x910 kernel/time/timer.c:2035
+ __do_softirq+0x1fb/0xadc kernel/softirq.c:571
+
+Fixes: 517a16b1a88b ("netrom: Decrease sock refcount when sock timers expire")
+Reported-by: syzbot+5fafd5cfe1fc91f6b352@syzkaller.appspotmail.com
+Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
+Link: https://lore.kernel.org/r/20230120231927.51711-1-kuniyu@amazon.com
+Signed-off-by: Paolo Abeni <pabeni@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/netrom/nr_timer.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/net/netrom/nr_timer.c b/net/netrom/nr_timer.c
+index a8da88db7893..4e7c968cde2d 100644
+--- a/net/netrom/nr_timer.c
++++ b/net/netrom/nr_timer.c
+@@ -121,6 +121,7 @@ static void nr_heartbeat_expiry(struct timer_list *t)
+                  is accepted() it isn't 'dead' so doesn't get removed. */
+               if (sock_flag(sk, SOCK_DESTROY) ||
+                   (sk->sk_state == TCP_LISTEN && sock_flag(sk, SOCK_DEAD))) {
++                      sock_hold(sk);
+                       bh_unlock_sock(sk);
+                       nr_destroy_socket(sk);
+                       goto out;
+-- 
+2.39.0
+
diff --git a/queue-5.4/sctp-fail-if-no-bound-addresses-can-be-used-for-a-gi.patch b/queue-5.4/sctp-fail-if-no-bound-addresses-can-be-used-for-a-gi.patch
new file mode 100644 (file)
index 0000000..f959e46
--- /dev/null
@@ -0,0 +1,68 @@
+From 774f1a25544e12ffd29779aa76356a15a187f1ac Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 23 Jan 2023 14:59:33 -0300
+Subject: sctp: fail if no bound addresses can be used for a given scope
+
+From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
+
+[ Upstream commit 458e279f861d3f61796894cd158b780765a1569f ]
+
+Currently, if you bind the socket to something like:
+        servaddr.sin6_family = AF_INET6;
+        servaddr.sin6_port = htons(0);
+        servaddr.sin6_scope_id = 0;
+        inet_pton(AF_INET6, "::1", &servaddr.sin6_addr);
+
+And then request a connect to:
+        connaddr.sin6_family = AF_INET6;
+        connaddr.sin6_port = htons(20000);
+        connaddr.sin6_scope_id = if_nametoindex("lo");
+        inet_pton(AF_INET6, "fe88::1", &connaddr.sin6_addr);
+
+What the stack does is:
+ - bind the socket
+ - create a new asoc
+ - to handle the connect
+   - copy the addresses that can be used for the given scope
+   - try to connect
+
+But the copy returns 0 addresses, and the effect is that it ends up
+trying to connect as if the socket wasn't bound, which is not the
+desired behavior. This unexpected behavior also allows KASLR leaks
+through SCTP diag interface.
+
+The fix here then is, if when trying to copy the addresses that can
+be used for the scope used in connect() it returns 0 addresses, bail
+out. This is what TCP does with a similar reproducer.
+
+Reported-by: Pietro Borrello <borrello@diag.uniroma1.it>
+Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
+Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
+Reviewed-by: Xin Long <lucien.xin@gmail.com>
+Link: https://lore.kernel.org/r/9fcd182f1099f86c6661f3717f63712ddd1c676c.1674496737.git.marcelo.leitner@gmail.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/sctp/bind_addr.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/net/sctp/bind_addr.c b/net/sctp/bind_addr.c
+index a825e74d01fc..614bc081ca50 100644
+--- a/net/sctp/bind_addr.c
++++ b/net/sctp/bind_addr.c
+@@ -73,6 +73,12 @@ int sctp_bind_addr_copy(struct net *net, struct sctp_bind_addr *dest,
+               }
+       }
++      /* If somehow no addresses were found that can be used with this
++       * scope, it's an error.
++       */
++      if (list_empty(&dest->address_list))
++              error = -ENETUNREACH;
++
+ out:
+       if (error)
+               sctp_bind_addr_clean(dest);
+-- 
+2.39.0
+
index 0aa2faf1987f3481053b228b1821e9408371f6d8..7c7e64eede346feb520991fc14353d0aa91a0fef 100644 (file)
@@ -84,3 +84,22 @@ thermal-intel-int340x-protect-trip-temperature-from-concurrent-updates.patch
 arm-9280-1-mm-fix-warning-on-phys_addr_t-to-void-pointer-assignment.patch
 edac-device-respect-any-driver-supplied-workqueue-polling-value.patch
 edac-qcom-do-not-pass-llcc_driv_data-as-edac_device_ctl_info-s-pvt_info.patch
+netlink-prevent-potential-spectre-v1-gadgets.patch
+net-fix-uaf-in-netns-ops-registration-error-path.patch
+netfilter-nft_set_rbtree-skip-elements-in-transactio.patch
+netlink-annotate-data-races-around-nlk-portid.patch
+netlink-annotate-data-races-around-dst_portid-and-ds.patch
+netlink-annotate-data-races-around-sk_state.patch
+ipv4-prevent-potential-spectre-v1-gadget-in-ip_metri.patch
+ipv4-prevent-potential-spectre-v1-gadget-in-fib_metr.patch
+netfilter-conntrack-fix-vtag-checks-for-abort-shutdo.patch
+netfilter-conntrack-fix-bug-in-for_each_sctp_chunk.patch
+netrom-fix-use-after-free-of-a-listening-socket.patch
+net-sched-sch_taprio-do-not-schedule-in-taprio_reset.patch
+sctp-fail-if-no-bound-addresses-can-be-used-for-a-gi.patch
+net-ravb-fix-possible-hang-if-ris2_qff1-happen.patch
+thermal-intel-int340x-add-locking-to-int340x_thermal.patch
+net-tg3-resolve-deadlock-in-tg3_reset_task-during-ee.patch
+net-phy-mdio-i2c-move-header-file-to-include-linux-m.patch
+net-xgene-move-shared-header-file-into-include-linux.patch
+net-mdio-mux-meson-g12a-force-internal-phy-off-on-mu.patch
diff --git a/queue-5.4/thermal-intel-int340x-add-locking-to-int340x_thermal.patch b/queue-5.4/thermal-intel-int340x-add-locking-to-int340x_thermal.patch
new file mode 100644 (file)
index 0000000..d4e08e3
--- /dev/null
@@ -0,0 +1,58 @@
+From 3e485d04e313ca50b8e130acbc80ad5d72e668ab Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 25 Jan 2023 13:17:42 +0100
+Subject: thermal: intel: int340x: Add locking to
+ int340x_thermal_get_trip_type()
+
+From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+
+[ Upstream commit acd7e9ee57c880b99671dd99680cb707b7b5b0ee ]
+
+In order to prevent int340x_thermal_get_trip_type() from possibly
+racing with int340x_thermal_read_trips() invoked by int3403_notify()
+add locking to it in analogy with int340x_thermal_get_trip_temp().
+
+Fixes: 6757a7abe47b ("thermal: intel: int340x: Protect trip temperature from concurrent updates")
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ .../intel/int340x_thermal/int340x_thermal_zone.c       | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
+index 62ba34a4d7ae..9090f87b4491 100644
+--- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
++++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
+@@ -80,11 +80,13 @@ static int int340x_thermal_get_trip_type(struct thermal_zone_device *zone,
+                                        enum thermal_trip_type *type)
+ {
+       struct int34x_thermal_zone *d = zone->devdata;
+-      int i;
++      int i, ret = 0;
+       if (d->override_ops && d->override_ops->get_trip_type)
+               return d->override_ops->get_trip_type(zone, trip, type);
++      mutex_lock(&d->trip_mutex);
++
+       if (trip < d->aux_trip_nr)
+               *type = THERMAL_TRIP_PASSIVE;
+       else if (trip == d->crt_trip_id)
+@@ -102,10 +104,12 @@ static int int340x_thermal_get_trip_type(struct thermal_zone_device *zone,
+                       }
+               }
+               if (i == INT340X_THERMAL_MAX_ACT_TRIP_COUNT)
+-                      return -EINVAL;
++                      ret = -EINVAL;
+       }
+-      return 0;
++      mutex_unlock(&d->trip_mutex);
++
++      return ret;
+ }
+ static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone,
+-- 
+2.39.0
+