]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 5.4
authorSasha Levin <sashal@kernel.org>
Sun, 12 Nov 2023 02:50:15 +0000 (21:50 -0500)
committerSasha Levin <sashal@kernel.org>
Sun, 12 Nov 2023 02:50:15 +0000 (21:50 -0500)
Signed-off-by: Sasha Levin <sashal@kernel.org>
19 files changed:
queue-5.4/dccp-call-security_inet_conn_request-after-setting-i.patch [new file with mode: 0644]
queue-5.4/dccp-tcp-call-security_inet_conn_request-after-setti.patch [new file with mode: 0644]
queue-5.4/fix-termination-state-for-idr_for_each_entry_ul.patch [new file with mode: 0644]
queue-5.4/inet-shrink-struct-flowi_common.patch [new file with mode: 0644]
queue-5.4/input-synaptics-rmi4-fix-use-after-free-in-rmi_unreg.patch [new file with mode: 0644]
queue-5.4/llc-verify-mac-len-before-reading-mac-header.patch [new file with mode: 0644]
queue-5.4/net-r8169-disable-multicast-filter-for-rtl8168h-and-.patch [new file with mode: 0644]
queue-5.4/net-smc-fix-dangling-sock-under-state-smc_appfinclos.patch [new file with mode: 0644]
queue-5.4/net-stmmac-xgmac-enable-support-for-multiple-flexibl.patch [new file with mode: 0644]
queue-5.4/netfilter-nat-fix-ipv6-nat-redirect-with-mapped-and-.patch [new file with mode: 0644]
queue-5.4/netfilter-nft_redir-use-struct-nf_nat_range2-through.patch [new file with mode: 0644]
queue-5.4/netfilter-xt_recent-fix-increase-ipv6-literal-buffer.patch [new file with mode: 0644]
queue-5.4/pwm-brcmstb-utilize-appropriate-clock-apis-in-suspen.patch [new file with mode: 0644]
queue-5.4/pwm-sti-avoid-conditional-gotos.patch [new file with mode: 0644]
queue-5.4/pwm-sti-reduce-number-of-allocations-and-drop-usage-.patch [new file with mode: 0644]
queue-5.4/r8169-respect-userspace-disabling-iff_multicast.patch [new file with mode: 0644]
queue-5.4/series
queue-5.4/tg3-power-down-device-only-on-system_power_off.patch [new file with mode: 0644]
queue-5.4/tipc-change-nla_policy-for-bearer-related-names-to-n.patch [new file with mode: 0644]

diff --git a/queue-5.4/dccp-call-security_inet_conn_request-after-setting-i.patch b/queue-5.4/dccp-call-security_inet_conn_request-after-setting-i.patch
new file mode 100644 (file)
index 0000000..9745af4
--- /dev/null
@@ -0,0 +1,59 @@
+From 98c7d574a53a4fa10eaa52c9c5f21e8b502dc4f6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 30 Oct 2023 13:10:41 -0700
+Subject: dccp: Call security_inet_conn_request() after setting IPv4 addresses.
+
+From: Kuniyuki Iwashima <kuniyu@amazon.com>
+
+[ Upstream commit fa2df45af13091f76b89adb84a28f13818d5d631 ]
+
+Initially, commit 4237c75c0a35 ("[MLSXFRM]: Auto-labeling of child
+sockets") introduced security_inet_conn_request() in some functions
+where reqsk is allocated.  The hook is added just after the allocation,
+so reqsk's IPv4 remote address was not initialised then.
+
+However, SELinux/Smack started to read it in netlbl_req_setattr()
+after the cited commits.
+
+This bug was partially fixed by commit 284904aa7946 ("lsm: Relocate
+the IPv4 security_inet_conn_request() hooks").
+
+This patch fixes the last bug in DCCPv4.
+
+Fixes: 389fb800ac8b ("netlabel: Label incoming TCP connections correctly in SELinux")
+Fixes: 07feee8f812f ("netlabel: Cleanup the Smack/NetLabel code to fix incoming TCP connections")
+Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
+Acked-by: Paul Moore <paul@paul-moore.com>
+Signed-off-by: Paolo Abeni <pabeni@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/dccp/ipv4.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
+index 249beb41ff89d..944cc34f707d9 100644
+--- a/net/dccp/ipv4.c
++++ b/net/dccp/ipv4.c
+@@ -611,9 +611,6 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
+       if (dccp_parse_options(sk, dreq, skb))
+               goto drop_and_free;
+-      if (security_inet_conn_request(sk, skb, req))
+-              goto drop_and_free;
+-
+       ireq = inet_rsk(req);
+       sk_rcv_saddr_set(req_to_sk(req), ip_hdr(skb)->daddr);
+       sk_daddr_set(req_to_sk(req), ip_hdr(skb)->saddr);
+@@ -621,6 +618,9 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
+       ireq->ireq_family = AF_INET;
+       ireq->ir_iif = sk->sk_bound_dev_if;
++      if (security_inet_conn_request(sk, skb, req))
++              goto drop_and_free;
++
+       /*
+        * Step 3: Process LISTEN state
+        *
+-- 
+2.42.0
+
diff --git a/queue-5.4/dccp-tcp-call-security_inet_conn_request-after-setti.patch b/queue-5.4/dccp-tcp-call-security_inet_conn_request-after-setti.patch
new file mode 100644 (file)
index 0000000..569af44
--- /dev/null
@@ -0,0 +1,85 @@
+From 8e5342f21473e015deb2551a5ec6c270f5aa778a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 30 Oct 2023 13:10:42 -0700
+Subject: dccp/tcp: Call security_inet_conn_request() after setting IPv6
+ addresses.
+
+From: Kuniyuki Iwashima <kuniyu@amazon.com>
+
+[ Upstream commit 23be1e0e2a83a8543214d2599a31d9a2185a796b ]
+
+Initially, commit 4237c75c0a35 ("[MLSXFRM]: Auto-labeling of child
+sockets") introduced security_inet_conn_request() in some functions
+where reqsk is allocated.  The hook is added just after the allocation,
+so reqsk's IPv6 remote address was not initialised then.
+
+However, SELinux/Smack started to read it in netlbl_req_setattr()
+after commit e1adea927080 ("calipso: Allow request sockets to be
+relabelled by the lsm.").
+
+Commit 284904aa7946 ("lsm: Relocate the IPv4 security_inet_conn_request()
+hooks") fixed that kind of issue only in TCPv4 because IPv6 labeling was
+not supported at that time.  Finally, the same issue was introduced again
+in IPv6.
+
+Let's apply the same fix on DCCPv6 and TCPv6.
+
+Fixes: e1adea927080 ("calipso: Allow request sockets to be relabelled by the lsm.")
+Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
+Acked-by: Paul Moore <paul@paul-moore.com>
+Signed-off-by: Paolo Abeni <pabeni@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/dccp/ipv6.c       | 6 +++---
+ net/ipv6/syncookies.c | 7 ++++---
+ 2 files changed, 7 insertions(+), 6 deletions(-)
+
+diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
+index a7e3939022534..c3a378ef95aa4 100644
+--- a/net/dccp/ipv6.c
++++ b/net/dccp/ipv6.c
+@@ -349,15 +349,15 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
+       if (dccp_parse_options(sk, dreq, skb))
+               goto drop_and_free;
+-      if (security_inet_conn_request(sk, skb, req))
+-              goto drop_and_free;
+-
+       ireq = inet_rsk(req);
+       ireq->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr;
+       ireq->ir_v6_loc_addr = ipv6_hdr(skb)->daddr;
+       ireq->ireq_family = AF_INET6;
+       ireq->ir_mark = inet_request_mark(sk, skb);
++      if (security_inet_conn_request(sk, skb, req))
++              goto drop_and_free;
++
+       if (ipv6_opt_accepted(sk, skb, IP6CB(skb)) ||
+           np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo ||
+           np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) {
+diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c
+index 7e55505465949..8c3beffbaf06c 100644
+--- a/net/ipv6/syncookies.c
++++ b/net/ipv6/syncookies.c
+@@ -180,14 +180,15 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
+       treq->af_specific = &tcp_request_sock_ipv6_ops;
+       treq->tfo_listener = false;
+-      if (security_inet_conn_request(sk, skb, req))
+-              goto out_free;
+-
+       req->mss = mss;
+       ireq->ir_rmt_port = th->source;
+       ireq->ir_num = ntohs(th->dest);
+       ireq->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr;
+       ireq->ir_v6_loc_addr = ipv6_hdr(skb)->daddr;
++
++      if (security_inet_conn_request(sk, skb, req))
++              goto out_free;
++
+       if (ipv6_opt_accepted(sk, skb, &TCP_SKB_CB(skb)->header.h6) ||
+           np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo ||
+           np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) {
+-- 
+2.42.0
+
diff --git a/queue-5.4/fix-termination-state-for-idr_for_each_entry_ul.patch b/queue-5.4/fix-termination-state-for-idr_for_each_entry_ul.patch
new file mode 100644 (file)
index 0000000..1db973e
--- /dev/null
@@ -0,0 +1,64 @@
+From 33a2fe2f81244038e34e01da274ecf84517825a4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 24 Oct 2023 09:53:33 +1100
+Subject: Fix termination state for idr_for_each_entry_ul()
+
+From: NeilBrown <neilb@suse.de>
+
+[ Upstream commit e8ae8ad479e2d037daa33756e5e72850a7bd37a9 ]
+
+The comment for idr_for_each_entry_ul() states
+
+  after normal termination @entry is left with the value NULL
+
+This is not correct in the case where UINT_MAX has an entry in the idr.
+In that case @entry will be non-NULL after termination.
+No current code depends on the documentation being correct, but to
+save future code we should fix it.
+
+Also fix idr_for_each_entry_continue_ul().  While this is not documented
+as leaving @entry as NULL, the mellanox driver appears to depend on
+it doing so.  So make that explicit in the documentation as well as in
+the code.
+
+Fixes: e33d2b74d805 ("idr: fix overflow case for idr_for_each_entry_ul()")
+Cc: Matthew Wilcox <willy@infradead.org>
+Cc: Chris Mi <chrism@mellanox.com>
+Cc: Cong Wang <xiyou.wangcong@gmail.com>
+Signed-off-by: NeilBrown <neilb@suse.de>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/linux/idr.h | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/include/linux/idr.h b/include/linux/idr.h
+index ac6e946b6767b..bbfd934cab226 100644
+--- a/include/linux/idr.h
++++ b/include/linux/idr.h
+@@ -200,7 +200,7 @@ static inline void idr_preload_end(void)
+  */
+ #define idr_for_each_entry_ul(idr, entry, tmp, id)                    \
+       for (tmp = 0, id = 0;                                           \
+-           tmp <= id && ((entry) = idr_get_next_ul(idr, &(id))) != NULL; \
++           ((entry) = tmp <= id ? idr_get_next_ul(idr, &(id)) : NULL) != NULL; \
+            tmp = id, ++id)
+ /**
+@@ -224,10 +224,12 @@ static inline void idr_preload_end(void)
+  * @id: Entry ID.
+  *
+  * Continue to iterate over entries, continuing after the current position.
++ * After normal termination @entry is left with the value NULL.  This
++ * is convenient for a "not found" value.
+  */
+ #define idr_for_each_entry_continue_ul(idr, entry, tmp, id)           \
+       for (tmp = id;                                                  \
+-           tmp <= id && ((entry) = idr_get_next_ul(idr, &(id))) != NULL; \
++           ((entry) = tmp <= id ? idr_get_next_ul(idr, &(id)) : NULL) != NULL; \
+            tmp = id, ++id)
+ /*
+-- 
+2.42.0
+
diff --git a/queue-5.4/inet-shrink-struct-flowi_common.patch b/queue-5.4/inet-shrink-struct-flowi_common.patch
new file mode 100644 (file)
index 0000000..071c36e
--- /dev/null
@@ -0,0 +1,44 @@
+From f8faad188b9d8f46cb05f7db2a35969757a0c8e6 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 25 Oct 2023 14:10:37 +0000
+Subject: inet: shrink struct flowi_common
+
+From: Eric Dumazet <edumazet@google.com>
+
+[ Upstream commit 1726483b79a72e0150734d5367e4a0238bf8fcff ]
+
+I am looking at syzbot reports triggering kernel stack overflows
+involving a cascade of ipvlan devices.
+
+We can save 8 bytes in struct flowi_common.
+
+This patch alone will not fix the issue, but is a start.
+
+Fixes: 24ba14406c5c ("route: Add multipath_hash in flowi_common to make user-define hash")
+Signed-off-by: Eric Dumazet <edumazet@google.com>
+Cc: wenxu <wenxu@ucloud.cn>
+Reviewed-by: David Ahern <dsahern@kernel.org>
+Link: https://lore.kernel.org/r/20231025141037.3448203-1-edumazet@google.com
+Signed-off-by: Paolo Abeni <pabeni@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/net/flow.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/net/flow.h b/include/net/flow.h
+index d058e63fb59a3..21e781c74ac51 100644
+--- a/include/net/flow.h
++++ b/include/net/flow.h
+@@ -39,8 +39,8 @@ struct flowi_common {
+ #define FLOWI_FLAG_SKIP_NH_OIF                0x04
+       __u32   flowic_secid;
+       kuid_t  flowic_uid;
+-      struct flowi_tunnel flowic_tun_key;
+       __u32           flowic_multipath_hash;
++      struct flowi_tunnel flowic_tun_key;
+ };
+ union flowi_uli {
+-- 
+2.42.0
+
diff --git a/queue-5.4/input-synaptics-rmi4-fix-use-after-free-in-rmi_unreg.patch b/queue-5.4/input-synaptics-rmi4-fix-use-after-free-in-rmi_unreg.patch
new file mode 100644 (file)
index 0000000..dca6e39
--- /dev/null
@@ -0,0 +1,43 @@
+From 6e28cf3088a5e502fa50dd51a88051edcb595f86 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 29 Oct 2023 02:53:36 +0000
+Subject: Input: synaptics-rmi4 - fix use after free in
+ rmi_unregister_function()
+
+From: Dan Carpenter <dan.carpenter@linaro.org>
+
+[ Upstream commit eb988e46da2e4eae89f5337e047ce372fe33d5b1 ]
+
+The put_device() calls rmi_release_function() which frees "fn" so the
+dereference on the next line "fn->num_of_irqs" is a use after free.
+Move the put_device() to the end to fix this.
+
+Fixes: 24d28e4f1271 ("Input: synaptics-rmi4 - convert irq distribution to irq_domain")
+Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
+Link: https://lore.kernel.org/r/706efd36-7561-42f3-adfa-dd1d0bd4f5a1@moroto.mountain
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/input/rmi4/rmi_bus.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
+index af706a583656e..1e3aaff310c91 100644
+--- a/drivers/input/rmi4/rmi_bus.c
++++ b/drivers/input/rmi4/rmi_bus.c
+@@ -276,11 +276,11 @@ void rmi_unregister_function(struct rmi_function *fn)
+       device_del(&fn->dev);
+       of_node_put(fn->dev.of_node);
+-      put_device(&fn->dev);
+       for (i = 0; i < fn->num_of_irqs; i++)
+               irq_dispose_mapping(fn->irq[i]);
++      put_device(&fn->dev);
+ }
+ /**
+-- 
+2.42.0
+
diff --git a/queue-5.4/llc-verify-mac-len-before-reading-mac-header.patch b/queue-5.4/llc-verify-mac-len-before-reading-mac-header.patch
new file mode 100644 (file)
index 0000000..b257ef2
--- /dev/null
@@ -0,0 +1,113 @@
+From c405ffe3c48cc383d71f0e7749bb416b869b5dd8 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 25 Oct 2023 19:42:38 -0400
+Subject: llc: verify mac len before reading mac header
+
+From: Willem de Bruijn <willemb@google.com>
+
+[ Upstream commit 7b3ba18703a63f6fd487183b9262b08e5632da1b ]
+
+LLC reads the mac header with eth_hdr without verifying that the skb
+has an Ethernet header.
+
+Syzbot was able to enter llc_rcv on a tun device. Tun can insert
+packets without mac len and with user configurable skb->protocol
+(passing a tun_pi header when not configuring IFF_NO_PI).
+
+    BUG: KMSAN: uninit-value in llc_station_ac_send_test_r net/llc/llc_station.c:81 [inline]
+    BUG: KMSAN: uninit-value in llc_station_rcv+0x6fb/0x1290 net/llc/llc_station.c:111
+    llc_station_ac_send_test_r net/llc/llc_station.c:81 [inline]
+    llc_station_rcv+0x6fb/0x1290 net/llc/llc_station.c:111
+    llc_rcv+0xc5d/0x14a0 net/llc/llc_input.c:218
+    __netif_receive_skb_one_core net/core/dev.c:5523 [inline]
+    __netif_receive_skb+0x1a6/0x5a0 net/core/dev.c:5637
+    netif_receive_skb_internal net/core/dev.c:5723 [inline]
+    netif_receive_skb+0x58/0x660 net/core/dev.c:5782
+    tun_rx_batched+0x3ee/0x980 drivers/net/tun.c:1555
+    tun_get_user+0x54c5/0x69c0 drivers/net/tun.c:2002
+
+Add a mac_len test before all three eth_hdr(skb) calls under net/llc.
+
+There are further uses in include/net/llc_pdu.h. All these are
+protected by a test skb->protocol == ETH_P_802_2. Which does not
+protect against this tun scenario.
+
+But the mac_len test added in this patch in llc_fixup_skb will
+indirectly protect those too. That is called from llc_rcv before any
+other LLC code.
+
+It is tempting to just add a blanket mac_len check in llc_rcv, but
+not sure whether that could break valid LLC paths that do not assume
+an Ethernet header. 802.2 LLC may be used on top of non-802.3
+protocols in principle. The below referenced commit shows that used
+to, on top of Token Ring.
+
+At least one of the three eth_hdr uses goes back to before the start
+of git history. But the one that syzbot exercises is introduced in
+this commit. That commit is old enough (2008), that effectively all
+stable kernels should receive this.
+
+Fixes: f83f1768f833 ("[LLC]: skb allocation size for responses")
+Reported-by: syzbot+a8c7be6dee0de1b669cc@syzkaller.appspotmail.com
+Signed-off-by: Willem de Bruijn <willemb@google.com>
+Link: https://lore.kernel.org/r/20231025234251.3796495-1-willemdebruijn.kernel@gmail.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/llc/llc_input.c   | 10 ++++++++--
+ net/llc/llc_s_ac.c    |  3 +++
+ net/llc/llc_station.c |  3 +++
+ 3 files changed, 14 insertions(+), 2 deletions(-)
+
+diff --git a/net/llc/llc_input.c b/net/llc/llc_input.c
+index f9e801cc50f5e..f4fb309185ced 100644
+--- a/net/llc/llc_input.c
++++ b/net/llc/llc_input.c
+@@ -127,8 +127,14 @@ static inline int llc_fixup_skb(struct sk_buff *skb)
+       skb->transport_header += llc_len;
+       skb_pull(skb, llc_len);
+       if (skb->protocol == htons(ETH_P_802_2)) {
+-              __be16 pdulen = eth_hdr(skb)->h_proto;
+-              s32 data_size = ntohs(pdulen) - llc_len;
++              __be16 pdulen;
++              s32 data_size;
++
++              if (skb->mac_len < ETH_HLEN)
++                      return 0;
++
++              pdulen = eth_hdr(skb)->h_proto;
++              data_size = ntohs(pdulen) - llc_len;
+               if (data_size < 0 ||
+                   !pskb_may_pull(skb, data_size))
+diff --git a/net/llc/llc_s_ac.c b/net/llc/llc_s_ac.c
+index 9fa3342c7a829..df26557a02448 100644
+--- a/net/llc/llc_s_ac.c
++++ b/net/llc/llc_s_ac.c
+@@ -153,6 +153,9 @@ int llc_sap_action_send_test_r(struct llc_sap *sap, struct sk_buff *skb)
+       int rc = 1;
+       u32 data_size;
++      if (skb->mac_len < ETH_HLEN)
++              return 1;
++
+       llc_pdu_decode_sa(skb, mac_da);
+       llc_pdu_decode_da(skb, mac_sa);
+       llc_pdu_decode_ssap(skb, &dsap);
+diff --git a/net/llc/llc_station.c b/net/llc/llc_station.c
+index c29170e767a8c..64e2c67e16ba3 100644
+--- a/net/llc/llc_station.c
++++ b/net/llc/llc_station.c
+@@ -77,6 +77,9 @@ static int llc_station_ac_send_test_r(struct sk_buff *skb)
+       u32 data_size;
+       struct sk_buff *nskb;
++      if (skb->mac_len < ETH_HLEN)
++              goto out;
++
+       /* The test request command is type U (llc_len = 3) */
+       data_size = ntohs(eth_hdr(skb)->h_proto) - 3;
+       nskb = llc_alloc_frame(NULL, skb->dev, LLC_PDU_TYPE_U, data_size);
+-- 
+2.42.0
+
diff --git a/queue-5.4/net-r8169-disable-multicast-filter-for-rtl8168h-and-.patch b/queue-5.4/net-r8169-disable-multicast-filter-for-rtl8168h-and-.patch
new file mode 100644 (file)
index 0000000..3ccb4b5
--- /dev/null
@@ -0,0 +1,43 @@
+From b400c0e497f7ae01e11b9f415fc2db3519874aaf Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 30 Oct 2023 16:50:14 -0400
+Subject: net: r8169: Disable multicast filter for RTL8168H and RTL8107E
+
+From: Patrick Thompson <ptf@google.com>
+
+[ Upstream commit efa5f1311c4998e9e6317c52bc5ee93b3a0f36df ]
+
+RTL8168H and RTL8107E ethernet adapters erroneously filter unicast
+eapol packets unless allmulti is enabled. These devices correspond to
+RTL_GIGA_MAC_VER_46 and VER_48. Add an exception for VER_46 and VER_48
+in the same way that VER_35 has an exception.
+
+Fixes: 6e1d0b898818 ("r8169:add support for RTL8168H and RTL8107E")
+Signed-off-by: Patrick Thompson <ptf@google.com>
+Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
+Reviewed-by: Heiner Kallweit <hkallweit1@gmail.com>
+Link: https://lore.kernel.org/r/20231030205031.177855-1-ptf@google.com
+Signed-off-by: Paolo Abeni <pabeni@redhat.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/realtek/r8169_main.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
+index a5100a552fd0a..d5dba2f04de09 100644
+--- a/drivers/net/ethernet/realtek/r8169_main.c
++++ b/drivers/net/ethernet/realtek/r8169_main.c
+@@ -4290,7 +4290,9 @@ static void rtl_set_rx_mode(struct net_device *dev)
+               rx_mode |= AcceptAllPhys;
+       } else if (netdev_mc_count(dev) > MC_FILTER_LIMIT ||
+                  dev->flags & IFF_ALLMULTI ||
+-                 tp->mac_version == RTL_GIGA_MAC_VER_35) {
++                 tp->mac_version == RTL_GIGA_MAC_VER_35 ||
++                 tp->mac_version == RTL_GIGA_MAC_VER_46 ||
++                 tp->mac_version == RTL_GIGA_MAC_VER_48) {
+               /* accept all multicasts */
+       } else if (netdev_mc_empty(dev)) {
+               rx_mode &= ~AcceptMulticast;
+-- 
+2.42.0
+
diff --git a/queue-5.4/net-smc-fix-dangling-sock-under-state-smc_appfinclos.patch b/queue-5.4/net-smc-fix-dangling-sock-under-state-smc_appfinclos.patch
new file mode 100644 (file)
index 0000000..222b28f
--- /dev/null
@@ -0,0 +1,111 @@
+From dba702324ca095d05e0e44ceb23b0dacce0bfb20 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 3 Nov 2023 14:07:38 +0800
+Subject: net/smc: fix dangling sock under state SMC_APPFINCLOSEWAIT
+
+From: D. Wythe <alibuda@linux.alibaba.com>
+
+[ Upstream commit 5211c9729484c923f8d2e06bd29f9322cc42bb8f ]
+
+Considering scenario:
+
+                               smc_cdc_rx_handler
+__smc_release
+                               sock_set_flag
+smc_close_active()
+sock_set_flag
+
+__set_bit(DEAD)                        __set_bit(DONE)
+
+Dues to __set_bit is not atomic, the DEAD or DONE might be lost.
+if the DEAD flag lost, the state SMC_CLOSED  will be never be reached
+in smc_close_passive_work:
+
+if (sock_flag(sk, SOCK_DEAD) &&
+       smc_close_sent_any_close(conn)) {
+       sk->sk_state = SMC_CLOSED;
+} else {
+       /* just shutdown, but not yet closed locally */
+       sk->sk_state = SMC_APPFINCLOSEWAIT;
+}
+
+Replace sock_set_flags or __set_bit to set_bit will fix this problem.
+Since set_bit is atomic.
+
+Fixes: b38d732477e4 ("smc: socket closing and linkgroup cleanup")
+Signed-off-by: D. Wythe <alibuda@linux.alibaba.com>
+Reviewed-by: Dust Li <dust.li@linux.alibaba.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/smc/af_smc.c    | 4 ++--
+ net/smc/smc.h       | 5 +++++
+ net/smc/smc_cdc.c   | 2 +-
+ net/smc/smc_close.c | 2 +-
+ 4 files changed, 9 insertions(+), 4 deletions(-)
+
+diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
+index b398d72a7bc39..e070b0e2a30c5 100644
+--- a/net/smc/af_smc.c
++++ b/net/smc/af_smc.c
+@@ -136,7 +136,7 @@ static int __smc_release(struct smc_sock *smc)
+       if (!smc->use_fallback) {
+               rc = smc_close_active(smc);
+-              sock_set_flag(sk, SOCK_DEAD);
++              smc_sock_set_flag(sk, SOCK_DEAD);
+               sk->sk_shutdown |= SHUTDOWN_MASK;
+       } else {
+               if (sk->sk_state != SMC_CLOSED) {
+@@ -928,7 +928,7 @@ static int smc_clcsock_accept(struct smc_sock *lsmc, struct smc_sock **new_smc)
+               if (new_clcsock)
+                       sock_release(new_clcsock);
+               new_sk->sk_state = SMC_CLOSED;
+-              sock_set_flag(new_sk, SOCK_DEAD);
++              smc_sock_set_flag(new_sk, SOCK_DEAD);
+               sock_put(new_sk); /* final */
+               *new_smc = NULL;
+               goto out;
+diff --git a/net/smc/smc.h b/net/smc/smc.h
+index 878313f8d6c17..8c46eaf014a75 100644
+--- a/net/smc/smc.h
++++ b/net/smc/smc.h
+@@ -265,4 +265,9 @@ static inline bool using_ipsec(struct smc_sock *smc)
+ struct sock *smc_accept_dequeue(struct sock *parent, struct socket *new_sock);
+ void smc_close_non_accepted(struct sock *sk);
++static inline void smc_sock_set_flag(struct sock *sk, enum sock_flags flag)
++{
++      set_bit(flag, &sk->sk_flags);
++}
++
+ #endif        /* __SMC_H */
+diff --git a/net/smc/smc_cdc.c b/net/smc/smc_cdc.c
+index d0b0f4c865b40..68e1155126cf0 100644
+--- a/net/smc/smc_cdc.c
++++ b/net/smc/smc_cdc.c
+@@ -298,7 +298,7 @@ static void smc_cdc_msg_recv_action(struct smc_sock *smc,
+               smc->sk.sk_shutdown |= RCV_SHUTDOWN;
+               if (smc->clcsock && smc->clcsock->sk)
+                       smc->clcsock->sk->sk_shutdown |= RCV_SHUTDOWN;
+-              sock_set_flag(&smc->sk, SOCK_DONE);
++              smc_sock_set_flag(&smc->sk, SOCK_DONE);
+               sock_hold(&smc->sk); /* sock_put in close_work */
+               if (!schedule_work(&conn->close_work))
+                       sock_put(&smc->sk);
+diff --git a/net/smc/smc_close.c b/net/smc/smc_close.c
+index 543948d970c52..a704234c1a2ba 100644
+--- a/net/smc/smc_close.c
++++ b/net/smc/smc_close.c
+@@ -164,7 +164,7 @@ static void smc_close_active_abort(struct smc_sock *smc)
+               break;
+       }
+-      sock_set_flag(sk, SOCK_DEAD);
++      smc_sock_set_flag(sk, SOCK_DEAD);
+       sk->sk_state_change(sk);
+ }
+-- 
+2.42.0
+
diff --git a/queue-5.4/net-stmmac-xgmac-enable-support-for-multiple-flexibl.patch b/queue-5.4/net-stmmac-xgmac-enable-support-for-multiple-flexibl.patch
new file mode 100644 (file)
index 0000000..61fa8c6
--- /dev/null
@@ -0,0 +1,68 @@
+From cd1a3ee0d7ad13b54a9272d34a95d6a6916181c4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 31 Oct 2023 10:27:29 +0800
+Subject: net: stmmac: xgmac: Enable support for multiple Flexible PPS outputs
+
+From: Furong Xu <0x1207@gmail.com>
+
+[ Upstream commit db456d90a4c1b43b6251fa4348c8adc59b583274 ]
+
+From XGMAC Core 3.20 and later, each Flexible PPS has individual PPSEN bit
+to select Fixed mode or Flexible mode. The PPSEN must be set, or it stays
+in Fixed PPS mode by default.
+XGMAC Core prior 3.20, only PPSEN0(bit 4) is writable. PPSEN{1,2,3} are
+read-only reserved, and they are already in Flexible mode by default, our
+new code always set PPSEN{1,2,3} do not make things worse ;-)
+
+Fixes: 95eaf3cd0a90 ("net: stmmac: dwxgmac: Add Flexible PPS support")
+Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
+Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
+Signed-off-by: Furong Xu <0x1207@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h     |  2 +-
+ .../net/ethernet/stmicro/stmmac/dwxgmac2_core.c    | 14 +++++++++++++-
+ 2 files changed, 14 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h
+index ff751ab3d7658..5efb9cf99b525 100644
+--- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h
++++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h
+@@ -212,7 +212,7 @@
+       ((val) << XGMAC_PPS_MINIDX(x))
+ #define XGMAC_PPSCMD_START            0x2
+ #define XGMAC_PPSCMD_STOP             0x5
+-#define XGMAC_PPSEN0                  BIT(4)
++#define XGMAC_PPSENx(x)                       BIT(4 + (x) * 8)
+ #define XGMAC_PPSx_TARGET_TIME_SEC(x) (0x00000d80 + (x) * 0x10)
+ #define XGMAC_PPSx_TARGET_TIME_NSEC(x)        (0x00000d84 + (x) * 0x10)
+ #define XGMAC_TRGTBUSY0                       BIT(31)
+diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
+index 070bd7d1ae4ca..06fe2f185e0b3 100644
+--- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
++++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
+@@ -1101,7 +1101,19 @@ static int dwxgmac2_flex_pps_config(void __iomem *ioaddr, int index,
+       val |= XGMAC_PPSCMDx(index, XGMAC_PPSCMD_START);
+       val |= XGMAC_TRGTMODSELx(index, XGMAC_PPSCMD_START);
+-      val |= XGMAC_PPSEN0;
++
++      /* XGMAC Core has 4 PPS outputs at most.
++       *
++       * Prior XGMAC Core 3.20, Fixed mode or Flexible mode are selectable for
++       * PPS0 only via PPSEN0. PPS{1,2,3} are in Flexible mode by default,
++       * and can not be switched to Fixed mode, since PPSEN{1,2,3} are
++       * read-only reserved to 0.
++       * But we always set PPSEN{1,2,3} do not make things worse ;-)
++       *
++       * From XGMAC Core 3.20 and later, PPSEN{0,1,2,3} are writable and must
++       * be set, or the PPS outputs stay in Fixed PPS mode by default.
++       */
++      val |= XGMAC_PPSENx(index);
+       writel(cfg->start.tv_sec, ioaddr + XGMAC_PPSx_TARGET_TIME_SEC(index));
+-- 
+2.42.0
+
diff --git a/queue-5.4/netfilter-nat-fix-ipv6-nat-redirect-with-mapped-and-.patch b/queue-5.4/netfilter-nat-fix-ipv6-nat-redirect-with-mapped-and-.patch
new file mode 100644 (file)
index 0000000..cf48388
--- /dev/null
@@ -0,0 +1,97 @@
+From 0937c4da68b49a3a54537a46c6c15a145b91b6e3 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 8 Nov 2023 13:18:53 +0100
+Subject: netfilter: nat: fix ipv6 nat redirect with mapped and scoped
+ addresses
+
+From: Florian Westphal <fw@strlen.de>
+
+[ Upstream commit 80abbe8a8263106fe45a4f293b92b5c74cc9cc8a ]
+
+The ipv6 redirect target was derived from the ipv4 one, i.e. its
+identical to a 'dnat' with the first (primary) address assigned to the
+network interface.  The code has been moved around to make it usable
+from nf_tables too, but its still the same as it was back when this
+was added in 2012.
+
+IPv6, however, has different types of addresses, if the 'wrong' address
+comes first the redirection does not work.
+
+In Daniels case, the addresses are:
+  inet6 ::ffff:192 ...
+  inet6 2a01: ...
+
+... so the function attempts to redirect to the mapped address.
+
+Add more checks before the address is deemed correct:
+1. If the packets' daddr is scoped, search for a scoped address too
+2. skip tentative addresses
+3. skip mapped addresses
+
+Use the first address that appears to match our needs.
+
+Reported-by: Daniel Huhardeaux <tech@tootai.net>
+Closes: https://lore.kernel.org/netfilter/71be06b8-6aa0-4cf9-9e0b-e2839b01b22f@tootai.net/
+Fixes: 115e23ac78f8 ("netfilter: ip6tables: add REDIRECT target")
+Signed-off-by: Florian Westphal <fw@strlen.de>
+Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/netfilter/nf_nat_redirect.c | 27 ++++++++++++++++++++++++++-
+ 1 file changed, 26 insertions(+), 1 deletion(-)
+
+diff --git a/net/netfilter/nf_nat_redirect.c b/net/netfilter/nf_nat_redirect.c
+index 6616ba5d0b049..5b37487d9d11f 100644
+--- a/net/netfilter/nf_nat_redirect.c
++++ b/net/netfilter/nf_nat_redirect.c
+@@ -80,6 +80,26 @@ EXPORT_SYMBOL_GPL(nf_nat_redirect_ipv4);
+ static const struct in6_addr loopback_addr = IN6ADDR_LOOPBACK_INIT;
++static bool nf_nat_redirect_ipv6_usable(const struct inet6_ifaddr *ifa, unsigned int scope)
++{
++      unsigned int ifa_addr_type = ipv6_addr_type(&ifa->addr);
++
++      if (ifa_addr_type & IPV6_ADDR_MAPPED)
++              return false;
++
++      if ((ifa->flags & IFA_F_TENTATIVE) && (!(ifa->flags & IFA_F_OPTIMISTIC)))
++              return false;
++
++      if (scope) {
++              unsigned int ifa_scope = ifa_addr_type & IPV6_ADDR_SCOPE_MASK;
++
++              if (!(scope & ifa_scope))
++                      return false;
++      }
++
++      return true;
++}
++
+ unsigned int
+ nf_nat_redirect_ipv6(struct sk_buff *skb, const struct nf_nat_range2 *range,
+                    unsigned int hooknum)
+@@ -89,14 +109,19 @@ nf_nat_redirect_ipv6(struct sk_buff *skb, const struct nf_nat_range2 *range,
+       if (hooknum == NF_INET_LOCAL_OUT) {
+               newdst.in6 = loopback_addr;
+       } else {
++              unsigned int scope = ipv6_addr_scope(&ipv6_hdr(skb)->daddr);
+               struct inet6_dev *idev;
+-              struct inet6_ifaddr *ifa;
+               bool addr = false;
+               idev = __in6_dev_get(skb->dev);
+               if (idev != NULL) {
++                      const struct inet6_ifaddr *ifa;
++
+                       read_lock_bh(&idev->lock);
+                       list_for_each_entry(ifa, &idev->addr_list, if_list) {
++                              if (!nf_nat_redirect_ipv6_usable(ifa, scope))
++                                      continue;
++
+                               newdst.in6 = ifa->addr;
+                               addr = true;
+                               break;
+-- 
+2.42.0
+
diff --git a/queue-5.4/netfilter-nft_redir-use-struct-nf_nat_range2-through.patch b/queue-5.4/netfilter-nft_redir-use-struct-nf_nat_range2-through.patch
new file mode 100644 (file)
index 0000000..d1b90c1
--- /dev/null
@@ -0,0 +1,372 @@
+From c9de15e6fedb39463c8b43d639b7e00f7a9ba6ed Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 15 Mar 2023 21:48:01 +0000
+Subject: netfilter: nft_redir: use `struct nf_nat_range2` throughout and
+ deduplicate eval call-backs
+
+From: Jeremy Sowden <jeremy@azazel.net>
+
+[ Upstream commit 6f56ad1b92328997e1b1792047099df6f8d7acb5 ]
+
+`nf_nat_redirect_ipv4` takes a `struct nf_nat_ipv4_multi_range_compat`,
+but converts it internally to a `struct nf_nat_range2`.  Change the
+function to take the latter, factor out the code now shared with
+`nf_nat_redirect_ipv6`, move the conversion to the xt_REDIRECT module,
+and update the ipv4 range initialization in the nft_redir module.
+
+Replace a bare hex constant for 127.0.0.1 with a macro.
+
+Remove `WARN_ON`.  `nf_nat_setup_info` calls `nf_ct_is_confirmed`:
+
+       /* Can't setup nat info for confirmed ct. */
+       if (nf_ct_is_confirmed(ct))
+               return NF_ACCEPT;
+
+This means that `ct` cannot be null or the kernel will crash, and
+implies that `ctinfo` is `IP_CT_NEW` or `IP_CT_RELATED`.
+
+nft_redir has separate ipv4 and ipv6 call-backs which share much of
+their code, and an inet one switch containing a switch that calls one of
+the others based on the family of the packet.  Merge the ipv4 and ipv6
+ones into the inet one in order to get rid of the duplicate code.
+
+Const-qualify the `priv` pointer since we don't need to write through
+it.
+
+Assign `priv->flags` to the range instead of OR-ing it in.
+
+Set the `NF_NAT_RANGE_PROTO_SPECIFIED` flag once during init, rather
+than on every eval.
+
+Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
+Signed-off-by: Florian Westphal <fw@strlen.de>
+Stable-dep-of: 80abbe8a8263 ("netfilter: nat: fix ipv6 nat redirect with mapped and scoped addresses")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/net/netfilter/nf_nat_redirect.h |  3 +-
+ net/netfilter/nf_nat_redirect.c         | 71 ++++++++++-----------
+ net/netfilter/nft_redir.c               | 84 +++++++++----------------
+ net/netfilter/xt_REDIRECT.c             | 10 ++-
+ 4 files changed, 72 insertions(+), 96 deletions(-)
+
+diff --git a/include/net/netfilter/nf_nat_redirect.h b/include/net/netfilter/nf_nat_redirect.h
+index 2418653a66db1..279380de904c8 100644
+--- a/include/net/netfilter/nf_nat_redirect.h
++++ b/include/net/netfilter/nf_nat_redirect.h
+@@ -6,8 +6,7 @@
+ #include <uapi/linux/netfilter/nf_nat.h>
+ unsigned int
+-nf_nat_redirect_ipv4(struct sk_buff *skb,
+-                   const struct nf_nat_ipv4_multi_range_compat *mr,
++nf_nat_redirect_ipv4(struct sk_buff *skb, const struct nf_nat_range2 *range,
+                    unsigned int hooknum);
+ unsigned int
+ nf_nat_redirect_ipv6(struct sk_buff *skb, const struct nf_nat_range2 *range,
+diff --git a/net/netfilter/nf_nat_redirect.c b/net/netfilter/nf_nat_redirect.c
+index f91579c821e9a..6616ba5d0b049 100644
+--- a/net/netfilter/nf_nat_redirect.c
++++ b/net/netfilter/nf_nat_redirect.c
+@@ -10,6 +10,7 @@
+ #include <linux/if.h>
+ #include <linux/inetdevice.h>
++#include <linux/in.h>
+ #include <linux/ip.h>
+ #include <linux/kernel.h>
+ #include <linux/netdevice.h>
+@@ -24,54 +25,56 @@
+ #include <net/netfilter/nf_nat.h>
+ #include <net/netfilter/nf_nat_redirect.h>
++static unsigned int
++nf_nat_redirect(struct sk_buff *skb, const struct nf_nat_range2 *range,
++              const union nf_inet_addr *newdst)
++{
++      struct nf_nat_range2 newrange;
++      enum ip_conntrack_info ctinfo;
++      struct nf_conn *ct;
++
++      ct = nf_ct_get(skb, &ctinfo);
++
++      memset(&newrange, 0, sizeof(newrange));
++
++      newrange.flags          = range->flags | NF_NAT_RANGE_MAP_IPS;
++      newrange.min_addr       = *newdst;
++      newrange.max_addr       = *newdst;
++      newrange.min_proto      = range->min_proto;
++      newrange.max_proto      = range->max_proto;
++
++      return nf_nat_setup_info(ct, &newrange, NF_NAT_MANIP_DST);
++}
++
+ unsigned int
+-nf_nat_redirect_ipv4(struct sk_buff *skb,
+-                   const struct nf_nat_ipv4_multi_range_compat *mr,
++nf_nat_redirect_ipv4(struct sk_buff *skb, const struct nf_nat_range2 *range,
+                    unsigned int hooknum)
+ {
+-      struct nf_conn *ct;
+-      enum ip_conntrack_info ctinfo;
+-      __be32 newdst;
+-      struct nf_nat_range2 newrange;
++      union nf_inet_addr newdst = {};
+       WARN_ON(hooknum != NF_INET_PRE_ROUTING &&
+               hooknum != NF_INET_LOCAL_OUT);
+-      ct = nf_ct_get(skb, &ctinfo);
+-      WARN_ON(!(ct && (ctinfo == IP_CT_NEW || ctinfo == IP_CT_RELATED)));
+-
+       /* Local packets: make them go to loopback */
+       if (hooknum == NF_INET_LOCAL_OUT) {
+-              newdst = htonl(0x7F000001);
++              newdst.ip = htonl(INADDR_LOOPBACK);
+       } else {
+               const struct in_device *indev;
+-              newdst = 0;
+-
+               indev = __in_dev_get_rcu(skb->dev);
+               if (indev) {
+                       const struct in_ifaddr *ifa;
+                       ifa = rcu_dereference(indev->ifa_list);
+                       if (ifa)
+-                              newdst = ifa->ifa_local;
++                              newdst.ip = ifa->ifa_local;
+               }
+-              if (!newdst)
++              if (!newdst.ip)
+                       return NF_DROP;
+       }
+-      /* Transfer from original range. */
+-      memset(&newrange.min_addr, 0, sizeof(newrange.min_addr));
+-      memset(&newrange.max_addr, 0, sizeof(newrange.max_addr));
+-      newrange.flags       = mr->range[0].flags | NF_NAT_RANGE_MAP_IPS;
+-      newrange.min_addr.ip = newdst;
+-      newrange.max_addr.ip = newdst;
+-      newrange.min_proto   = mr->range[0].min;
+-      newrange.max_proto   = mr->range[0].max;
+-
+-      /* Hand modified range to generic setup. */
+-      return nf_nat_setup_info(ct, &newrange, NF_NAT_MANIP_DST);
++      return nf_nat_redirect(skb, range, &newdst);
+ }
+ EXPORT_SYMBOL_GPL(nf_nat_redirect_ipv4);
+@@ -81,14 +84,10 @@ unsigned int
+ nf_nat_redirect_ipv6(struct sk_buff *skb, const struct nf_nat_range2 *range,
+                    unsigned int hooknum)
+ {
+-      struct nf_nat_range2 newrange;
+-      struct in6_addr newdst;
+-      enum ip_conntrack_info ctinfo;
+-      struct nf_conn *ct;
++      union nf_inet_addr newdst = {};
+-      ct = nf_ct_get(skb, &ctinfo);
+       if (hooknum == NF_INET_LOCAL_OUT) {
+-              newdst = loopback_addr;
++              newdst.in6 = loopback_addr;
+       } else {
+               struct inet6_dev *idev;
+               struct inet6_ifaddr *ifa;
+@@ -98,7 +97,7 @@ nf_nat_redirect_ipv6(struct sk_buff *skb, const struct nf_nat_range2 *range,
+               if (idev != NULL) {
+                       read_lock_bh(&idev->lock);
+                       list_for_each_entry(ifa, &idev->addr_list, if_list) {
+-                              newdst = ifa->addr;
++                              newdst.in6 = ifa->addr;
+                               addr = true;
+                               break;
+                       }
+@@ -109,12 +108,6 @@ nf_nat_redirect_ipv6(struct sk_buff *skb, const struct nf_nat_range2 *range,
+                       return NF_DROP;
+       }
+-      newrange.flags          = range->flags | NF_NAT_RANGE_MAP_IPS;
+-      newrange.min_addr.in6   = newdst;
+-      newrange.max_addr.in6   = newdst;
+-      newrange.min_proto      = range->min_proto;
+-      newrange.max_proto      = range->max_proto;
+-
+-      return nf_nat_setup_info(ct, &newrange, NF_NAT_MANIP_DST);
++      return nf_nat_redirect(skb, range, &newdst);
+ }
+ EXPORT_SYMBOL_GPL(nf_nat_redirect_ipv6);
+diff --git a/net/netfilter/nft_redir.c b/net/netfilter/nft_redir.c
+index 81a191eb5c368..7179dada57570 100644
+--- a/net/netfilter/nft_redir.c
++++ b/net/netfilter/nft_redir.c
+@@ -64,6 +64,8 @@ static int nft_redir_init(const struct nft_ctx *ctx,
+               } else {
+                       priv->sreg_proto_max = priv->sreg_proto_min;
+               }
++
++              priv->flags |= NF_NAT_RANGE_PROTO_SPECIFIED;
+       }
+       if (tb[NFTA_REDIR_FLAGS]) {
+@@ -98,25 +100,37 @@ static int nft_redir_dump(struct sk_buff *skb, const struct nft_expr *expr)
+       return -1;
+ }
+-static void nft_redir_ipv4_eval(const struct nft_expr *expr,
+-                              struct nft_regs *regs,
+-                              const struct nft_pktinfo *pkt)
++static void nft_redir_eval(const struct nft_expr *expr,
++                         struct nft_regs *regs,
++                         const struct nft_pktinfo *pkt)
+ {
+-      struct nft_redir *priv = nft_expr_priv(expr);
+-      struct nf_nat_ipv4_multi_range_compat mr;
++      const struct nft_redir *priv = nft_expr_priv(expr);
++      struct nf_nat_range2 range;
+-      memset(&mr, 0, sizeof(mr));
++      memset(&range, 0, sizeof(range));
++      range.flags = priv->flags;
+       if (priv->sreg_proto_min) {
+-              mr.range[0].min.all = (__force __be16)nft_reg_load16(
+-                      &regs->data[priv->sreg_proto_min]);
+-              mr.range[0].max.all = (__force __be16)nft_reg_load16(
+-                      &regs->data[priv->sreg_proto_max]);
+-              mr.range[0].flags |= NF_NAT_RANGE_PROTO_SPECIFIED;
++              range.min_proto.all = (__force __be16)
++                      nft_reg_load16(&regs->data[priv->sreg_proto_min]);
++              range.max_proto.all = (__force __be16)
++                      nft_reg_load16(&regs->data[priv->sreg_proto_max]);
+       }
+-      mr.range[0].flags |= priv->flags;
+-
+-      regs->verdict.code = nf_nat_redirect_ipv4(pkt->skb, &mr, nft_hook(pkt));
++      switch (nft_pf(pkt)) {
++      case NFPROTO_IPV4:
++              regs->verdict.code = nf_nat_redirect_ipv4(pkt->skb, &range,
++                                                        nft_hook(pkt));
++              break;
++#ifdef CONFIG_NF_TABLES_IPV6
++      case NFPROTO_IPV6:
++              regs->verdict.code = nf_nat_redirect_ipv6(pkt->skb, &range,
++                                                        nft_hook(pkt));
++              break;
++#endif
++      default:
++              WARN_ON_ONCE(1);
++              break;
++      }
+ }
+ static void
+@@ -129,7 +143,7 @@ static struct nft_expr_type nft_redir_ipv4_type;
+ static const struct nft_expr_ops nft_redir_ipv4_ops = {
+       .type           = &nft_redir_ipv4_type,
+       .size           = NFT_EXPR_SIZE(sizeof(struct nft_redir)),
+-      .eval           = nft_redir_ipv4_eval,
++      .eval           = nft_redir_eval,
+       .init           = nft_redir_init,
+       .destroy        = nft_redir_ipv4_destroy,
+       .dump           = nft_redir_dump,
+@@ -146,28 +160,6 @@ static struct nft_expr_type nft_redir_ipv4_type __read_mostly = {
+ };
+ #ifdef CONFIG_NF_TABLES_IPV6
+-static void nft_redir_ipv6_eval(const struct nft_expr *expr,
+-                              struct nft_regs *regs,
+-                              const struct nft_pktinfo *pkt)
+-{
+-      struct nft_redir *priv = nft_expr_priv(expr);
+-      struct nf_nat_range2 range;
+-
+-      memset(&range, 0, sizeof(range));
+-      if (priv->sreg_proto_min) {
+-              range.min_proto.all = (__force __be16)nft_reg_load16(
+-                      &regs->data[priv->sreg_proto_min]);
+-              range.max_proto.all = (__force __be16)nft_reg_load16(
+-                      &regs->data[priv->sreg_proto_max]);
+-              range.flags |= NF_NAT_RANGE_PROTO_SPECIFIED;
+-      }
+-
+-      range.flags |= priv->flags;
+-
+-      regs->verdict.code =
+-              nf_nat_redirect_ipv6(pkt->skb, &range, nft_hook(pkt));
+-}
+-
+ static void
+ nft_redir_ipv6_destroy(const struct nft_ctx *ctx, const struct nft_expr *expr)
+ {
+@@ -178,7 +170,7 @@ static struct nft_expr_type nft_redir_ipv6_type;
+ static const struct nft_expr_ops nft_redir_ipv6_ops = {
+       .type           = &nft_redir_ipv6_type,
+       .size           = NFT_EXPR_SIZE(sizeof(struct nft_redir)),
+-      .eval           = nft_redir_ipv6_eval,
++      .eval           = nft_redir_eval,
+       .init           = nft_redir_init,
+       .destroy        = nft_redir_ipv6_destroy,
+       .dump           = nft_redir_dump,
+@@ -196,20 +188,6 @@ static struct nft_expr_type nft_redir_ipv6_type __read_mostly = {
+ #endif
+ #ifdef CONFIG_NF_TABLES_INET
+-static void nft_redir_inet_eval(const struct nft_expr *expr,
+-                              struct nft_regs *regs,
+-                              const struct nft_pktinfo *pkt)
+-{
+-      switch (nft_pf(pkt)) {
+-      case NFPROTO_IPV4:
+-              return nft_redir_ipv4_eval(expr, regs, pkt);
+-      case NFPROTO_IPV6:
+-              return nft_redir_ipv6_eval(expr, regs, pkt);
+-      }
+-
+-      WARN_ON_ONCE(1);
+-}
+-
+ static void
+ nft_redir_inet_destroy(const struct nft_ctx *ctx, const struct nft_expr *expr)
+ {
+@@ -220,7 +198,7 @@ static struct nft_expr_type nft_redir_inet_type;
+ static const struct nft_expr_ops nft_redir_inet_ops = {
+       .type           = &nft_redir_inet_type,
+       .size           = NFT_EXPR_SIZE(sizeof(struct nft_redir)),
+-      .eval           = nft_redir_inet_eval,
++      .eval           = nft_redir_eval,
+       .init           = nft_redir_init,
+       .destroy        = nft_redir_inet_destroy,
+       .dump           = nft_redir_dump,
+diff --git a/net/netfilter/xt_REDIRECT.c b/net/netfilter/xt_REDIRECT.c
+index 353ca7801251a..ff66b56a3f97d 100644
+--- a/net/netfilter/xt_REDIRECT.c
++++ b/net/netfilter/xt_REDIRECT.c
+@@ -46,7 +46,6 @@ static void redirect_tg_destroy(const struct xt_tgdtor_param *par)
+       nf_ct_netns_put(par->net, par->family);
+ }
+-/* FIXME: Take multiple ranges --RR */
+ static int redirect_tg4_check(const struct xt_tgchk_param *par)
+ {
+       const struct nf_nat_ipv4_multi_range_compat *mr = par->targinfo;
+@@ -65,7 +64,14 @@ static int redirect_tg4_check(const struct xt_tgchk_param *par)
+ static unsigned int
+ redirect_tg4(struct sk_buff *skb, const struct xt_action_param *par)
+ {
+-      return nf_nat_redirect_ipv4(skb, par->targinfo, xt_hooknum(par));
++      const struct nf_nat_ipv4_multi_range_compat *mr = par->targinfo;
++      struct nf_nat_range2 range = {
++              .flags       = mr->range[0].flags,
++              .min_proto   = mr->range[0].min,
++              .max_proto   = mr->range[0].max,
++      };
++
++      return nf_nat_redirect_ipv4(skb, &range, xt_hooknum(par));
+ }
+ static struct xt_target redirect_tg_reg[] __read_mostly = {
+-- 
+2.42.0
+
diff --git a/queue-5.4/netfilter-xt_recent-fix-increase-ipv6-literal-buffer.patch b/queue-5.4/netfilter-xt_recent-fix-increase-ipv6-literal-buffer.patch
new file mode 100644 (file)
index 0000000..2ff2379
--- /dev/null
@@ -0,0 +1,49 @@
+From 08252484d7c8a8bf2ec2e4cae70263b6c86d5502 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 5 Nov 2023 11:56:00 -0800
+Subject: netfilter: xt_recent: fix (increase) ipv6 literal buffer length
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Maciej Żenczykowski <zenczykowski@gmail.com>
+
+[ Upstream commit 7b308feb4fd2d1c06919445c65c8fbf8e9fd1781 ]
+
+in6_pton() supports 'low-32-bit dot-decimal representation'
+(this is useful with DNS64/NAT64 networks for example):
+
+  # echo +aaaa:bbbb:cccc:dddd:eeee:ffff:1.2.3.4 > /proc/self/net/xt_recent/DEFAULT
+  # cat /proc/self/net/xt_recent/DEFAULT
+  src=aaaa:bbbb:cccc:dddd:eeee:ffff:0102:0304 ttl: 0 last_seen: 9733848829 oldest_pkt: 1 9733848829
+
+but the provided buffer is too short:
+
+  # echo +aaaa:bbbb:cccc:dddd:eeee:ffff:255.255.255.255 > /proc/self/net/xt_recent/DEFAULT
+  -bash: echo: write error: Invalid argument
+
+Fixes: 079aa88fe717 ("netfilter: xt_recent: IPv6 support")
+Signed-off-by: Maciej Żenczykowski <zenczykowski@gmail.com>
+Reviewed-by: Simon Horman <horms@kernel.org>
+Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/netfilter/xt_recent.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
+index 3469b60736103..6fc0deb11aff2 100644
+--- a/net/netfilter/xt_recent.c
++++ b/net/netfilter/xt_recent.c
+@@ -561,7 +561,7 @@ recent_mt_proc_write(struct file *file, const char __user *input,
+ {
+       struct recent_table *t = PDE_DATA(file_inode(file));
+       struct recent_entry *e;
+-      char buf[sizeof("+b335:1d35:1e55:dead:c0de:1715:5afe:c0de")];
++      char buf[sizeof("+b335:1d35:1e55:dead:c0de:1715:255.255.255.255")];
+       const char *c = buf;
+       union nf_inet_addr addr = {};
+       u_int16_t family;
+-- 
+2.42.0
+
diff --git a/queue-5.4/pwm-brcmstb-utilize-appropriate-clock-apis-in-suspen.patch b/queue-5.4/pwm-brcmstb-utilize-appropriate-clock-apis-in-suspen.patch
new file mode 100644 (file)
index 0000000..e898f11
--- /dev/null
@@ -0,0 +1,51 @@
+From 9b244d198b6a4361b35ebe9a2faedd1694d011e7 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 4 Oct 2023 10:54:14 -0700
+Subject: pwm: brcmstb: Utilize appropriate clock APIs in suspend/resume
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Florian Fainelli <florian.fainelli@broadcom.com>
+
+[ Upstream commit e9bc4411548aaa738905d37851a0146c16b3bb21 ]
+
+The suspend/resume functions currently utilize
+clk_disable()/clk_enable() respectively which may be no-ops with certain
+clock providers such as SCMI. Fix this to use clk_disable_unprepare()
+and clk_prepare_enable() respectively as we should.
+
+Fixes: 3a9f5957020f ("pwm: Add Broadcom BCM7038 PWM controller support")
+Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
+Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
+Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/pwm/pwm-brcmstb.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/pwm/pwm-brcmstb.c b/drivers/pwm/pwm-brcmstb.c
+index fea612c45f200..fd8479cd67715 100644
+--- a/drivers/pwm/pwm-brcmstb.c
++++ b/drivers/pwm/pwm-brcmstb.c
+@@ -298,7 +298,7 @@ static int brcmstb_pwm_suspend(struct device *dev)
+ {
+       struct brcmstb_pwm *p = dev_get_drvdata(dev);
+-      clk_disable(p->clk);
++      clk_disable_unprepare(p->clk);
+       return 0;
+ }
+@@ -307,7 +307,7 @@ static int brcmstb_pwm_resume(struct device *dev)
+ {
+       struct brcmstb_pwm *p = dev_get_drvdata(dev);
+-      clk_enable(p->clk);
++      clk_prepare_enable(p->clk);
+       return 0;
+ }
+-- 
+2.42.0
+
diff --git a/queue-5.4/pwm-sti-avoid-conditional-gotos.patch b/queue-5.4/pwm-sti-avoid-conditional-gotos.patch
new file mode 100644 (file)
index 0000000..f12415a
--- /dev/null
@@ -0,0 +1,93 @@
+From 70bc93d1ea25f1c27cb1fed59b3cc8afa71b372f Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 11 Nov 2020 19:24:29 +0100
+Subject: pwm: sti: Avoid conditional gotos
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Thierry Reding <thierry.reding@gmail.com>
+
+[ Upstream commit fd3ae02bb66f091e55f363d32eca7b4039977bf5 ]
+
+Using gotos for conditional code complicates this code significantly.
+Convert the code to simple conditional blocks to increase readability.
+
+Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
+Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
+Acked-by: Lee Jones <lee.jones@linaro.org>
+Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
+Stable-dep-of: 2d6812b41e0d ("pwm: sti: Reduce number of allocations and drop usage of chip_data")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/pwm/pwm-sti.c | 48 ++++++++++++++++++++-----------------------
+ 1 file changed, 22 insertions(+), 26 deletions(-)
+
+diff --git a/drivers/pwm/pwm-sti.c b/drivers/pwm/pwm-sti.c
+index 1508616d794cd..973f76856a508 100644
+--- a/drivers/pwm/pwm-sti.c
++++ b/drivers/pwm/pwm-sti.c
+@@ -593,38 +593,34 @@ static int sti_pwm_probe(struct platform_device *pdev)
+       if (ret)
+               return ret;
+-      if (!cdata->pwm_num_devs)
+-              goto skip_pwm;
+-
+-      pc->pwm_clk = of_clk_get_by_name(dev->of_node, "pwm");
+-      if (IS_ERR(pc->pwm_clk)) {
+-              dev_err(dev, "failed to get PWM clock\n");
+-              return PTR_ERR(pc->pwm_clk);
+-      }
++      if (cdata->pwm_num_devs) {
++              pc->pwm_clk = of_clk_get_by_name(dev->of_node, "pwm");
++              if (IS_ERR(pc->pwm_clk)) {
++                      dev_err(dev, "failed to get PWM clock\n");
++                      return PTR_ERR(pc->pwm_clk);
++              }
+-      ret = clk_prepare(pc->pwm_clk);
+-      if (ret) {
+-              dev_err(dev, "failed to prepare clock\n");
+-              return ret;
++              ret = clk_prepare(pc->pwm_clk);
++              if (ret) {
++                      dev_err(dev, "failed to prepare clock\n");
++                      return ret;
++              }
+       }
+-skip_pwm:
+-      if (!cdata->cpt_num_devs)
+-              goto skip_cpt;
+-
+-      pc->cpt_clk = of_clk_get_by_name(dev->of_node, "capture");
+-      if (IS_ERR(pc->cpt_clk)) {
+-              dev_err(dev, "failed to get PWM capture clock\n");
+-              return PTR_ERR(pc->cpt_clk);
+-      }
++      if (cdata->cpt_num_devs) {
++              pc->cpt_clk = of_clk_get_by_name(dev->of_node, "capture");
++              if (IS_ERR(pc->cpt_clk)) {
++                      dev_err(dev, "failed to get PWM capture clock\n");
++                      return PTR_ERR(pc->cpt_clk);
++              }
+-      ret = clk_prepare(pc->cpt_clk);
+-      if (ret) {
+-              dev_err(dev, "failed to prepare clock\n");
+-              return ret;
++              ret = clk_prepare(pc->cpt_clk);
++              if (ret) {
++                      dev_err(dev, "failed to prepare clock\n");
++                      return ret;
++              }
+       }
+-skip_cpt:
+       pc->chip.dev = dev;
+       pc->chip.ops = &sti_pwm_ops;
+       pc->chip.base = -1;
+-- 
+2.42.0
+
diff --git a/queue-5.4/pwm-sti-reduce-number-of-allocations-and-drop-usage-.patch b/queue-5.4/pwm-sti-reduce-number-of-allocations-and-drop-usage-.patch
new file mode 100644 (file)
index 0000000..e2373f0
--- /dev/null
@@ -0,0 +1,116 @@
+From acc11701f6259fb4058bd600a585cb102143d0fb Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 5 Jul 2023 10:06:48 +0200
+Subject: pwm: sti: Reduce number of allocations and drop usage of chip_data
+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>
+
+[ Upstream commit 2d6812b41e0d832919d72c72ebddf361df53ba1b ]
+
+Instead of using one allocation per capture channel, use a single one. Also
+store it in driver data instead of chip data.
+
+This has several advantages:
+
+ - driver data isn't cleared when pwm_put() is called
+ - Reduces memory fragmentation
+
+Also register the pwm chip only after the per capture channel data is
+initialized as the capture callback relies on this initialization and it
+might be called even before pwmchip_add() returns.
+
+It would be still better to have struct sti_pwm_compat_data and the
+per-channel data struct sti_cpt_ddata in a single memory chunk, but that's
+not easily possible because the number of capture channels isn't known yet
+when the driver data struct is allocated.
+
+Fixes: e926b12c611c ("pwm: Clear chip_data in pwm_put()")
+Reported-by: George Stark <gnstark@sberdevices.ru>
+Fixes: c97267ae831d ("pwm: sti: Add PWM capture callback")
+Link: https://lore.kernel.org/r/20230705080650.2353391-7-u.kleine-koenig@pengutronix.de
+Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
+Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/pwm/pwm-sti.c | 29 ++++++++++++++---------------
+ 1 file changed, 14 insertions(+), 15 deletions(-)
+
+diff --git a/drivers/pwm/pwm-sti.c b/drivers/pwm/pwm-sti.c
+index 973f76856a508..9b2174adab3db 100644
+--- a/drivers/pwm/pwm-sti.c
++++ b/drivers/pwm/pwm-sti.c
+@@ -79,6 +79,7 @@ struct sti_pwm_compat_data {
+       unsigned int cpt_num_devs;
+       unsigned int max_pwm_cnt;
+       unsigned int max_prescale;
++      struct sti_cpt_ddata *ddata;
+ };
+ struct sti_pwm_chip {
+@@ -314,7 +315,7 @@ static int sti_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm,
+ {
+       struct sti_pwm_chip *pc = to_sti_pwmchip(chip);
+       struct sti_pwm_compat_data *cdata = pc->cdata;
+-      struct sti_cpt_ddata *ddata = pwm_get_chip_data(pwm);
++      struct sti_cpt_ddata *ddata = &cdata->ddata[pwm->hwpwm];
+       struct device *dev = pc->dev;
+       unsigned int effective_ticks;
+       unsigned long long high, low;
+@@ -417,7 +418,7 @@ static irqreturn_t sti_pwm_interrupt(int irq, void *data)
+       while (cpt_int_stat) {
+               devicenum = ffs(cpt_int_stat) - 1;
+-              ddata = pwm_get_chip_data(&pc->chip.pwms[devicenum]);
++              ddata = &pc->cdata->ddata[devicenum];
+               /*
+                * Capture input:
+@@ -619,6 +620,10 @@ static int sti_pwm_probe(struct platform_device *pdev)
+                       dev_err(dev, "failed to prepare clock\n");
+                       return ret;
+               }
++
++              cdata->ddata = devm_kzalloc(dev, cdata->cpt_num_devs * sizeof(*cdata->ddata), GFP_KERNEL);
++              if (!cdata->ddata)
++                      return -ENOMEM;
+       }
+       pc->chip.dev = dev;
+@@ -626,24 +631,18 @@ static int sti_pwm_probe(struct platform_device *pdev)
+       pc->chip.base = -1;
+       pc->chip.npwm = pc->cdata->pwm_num_devs;
+-      ret = pwmchip_add(&pc->chip);
+-      if (ret < 0) {
+-              clk_unprepare(pc->pwm_clk);
+-              clk_unprepare(pc->cpt_clk);
+-              return ret;
+-      }
+-
+       for (i = 0; i < cdata->cpt_num_devs; i++) {
+-              struct sti_cpt_ddata *ddata;
+-
+-              ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
+-              if (!ddata)
+-                      return -ENOMEM;
++              struct sti_cpt_ddata *ddata = &cdata->ddata[i];
+               init_waitqueue_head(&ddata->wait);
+               mutex_init(&ddata->lock);
++      }
+-              pwm_set_chip_data(&pc->chip.pwms[i], ddata);
++      ret = pwmchip_add(&pc->chip);
++      if (ret < 0) {
++              clk_unprepare(pc->pwm_clk);
++              clk_unprepare(pc->cpt_clk);
++              return ret;
+       }
+       platform_set_drvdata(pdev, pc);
+-- 
+2.42.0
+
diff --git a/queue-5.4/r8169-respect-userspace-disabling-iff_multicast.patch b/queue-5.4/r8169-respect-userspace-disabling-iff_multicast.patch
new file mode 100644 (file)
index 0000000..d1d5a30
--- /dev/null
@@ -0,0 +1,42 @@
+From a9b2139f58dd8394121d2a522df50f1acdbc24cc Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 5 Nov 2023 23:43:36 +0100
+Subject: r8169: respect userspace disabling IFF_MULTICAST
+
+From: Heiner Kallweit <hkallweit1@gmail.com>
+
+[ Upstream commit 8999ce4cfc87e61b4143ec2e7b93d8e92e11fa7f ]
+
+So far we ignore the setting of IFF_MULTICAST. Fix this and clear bit
+AcceptMulticast if IFF_MULTICAST isn't set.
+
+Note: Based on the implementations I've seen it doesn't seem to be 100% clear
+what a driver is supposed to do if IFF_ALLMULTI is set but IFF_MULTICAST
+is not. This patch is based on the understanding that IFF_MULTICAST has
+precedence.
+
+Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
+Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
+Link: https://lore.kernel.org/r/4a57ba02-d52d-4369-9f14-3565e6c1f7dc@gmail.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/realtek/r8169_main.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
+index d5dba2f04de09..28e2cd9c386a1 100644
+--- a/drivers/net/ethernet/realtek/r8169_main.c
++++ b/drivers/net/ethernet/realtek/r8169_main.c
+@@ -4288,6 +4288,8 @@ static void rtl_set_rx_mode(struct net_device *dev)
+               /* Unconditionally log net taps. */
+               netif_notice(tp, link, dev, "Promiscuous mode enabled\n");
+               rx_mode |= AcceptAllPhys;
++      } else if (!(dev->flags & IFF_MULTICAST)) {
++              rx_mode &= ~AcceptMulticast;
+       } else if (netdev_mc_count(dev) > MC_FILTER_LIMIT ||
+                  dev->flags & IFF_ALLMULTI ||
+                  tp->mac_version == RTL_GIGA_MAC_VER_35 ||
+-- 
+2.42.0
+
index 592f3c86d768b2156b44fc82ea58b393acdc9f2b..334d6bd756f13bbc71f4ea38d29bdd4b91e49f45 100644 (file)
@@ -105,3 +105,21 @@ media-bttv-fix-use-after-free-error-due-to-btv-timeo.patch
 media-s3c-camif-avoid-inappropriate-kfree.patch
 media-dvb-usb-v2-af9035-fix-missing-unlock.patch
 regmap-prevent-noinc-writes-from-clobbering-cache.patch
+pwm-sti-avoid-conditional-gotos.patch
+pwm-sti-reduce-number-of-allocations-and-drop-usage-.patch
+pwm-brcmstb-utilize-appropriate-clock-apis-in-suspen.patch
+input-synaptics-rmi4-fix-use-after-free-in-rmi_unreg.patch
+llc-verify-mac-len-before-reading-mac-header.patch
+tipc-change-nla_policy-for-bearer-related-names-to-n.patch
+inet-shrink-struct-flowi_common.patch
+dccp-call-security_inet_conn_request-after-setting-i.patch
+dccp-tcp-call-security_inet_conn_request-after-setti.patch
+net-r8169-disable-multicast-filter-for-rtl8168h-and-.patch
+fix-termination-state-for-idr_for_each_entry_ul.patch
+net-stmmac-xgmac-enable-support-for-multiple-flexibl.patch
+net-smc-fix-dangling-sock-under-state-smc_appfinclos.patch
+tg3-power-down-device-only-on-system_power_off.patch
+r8169-respect-userspace-disabling-iff_multicast.patch
+netfilter-xt_recent-fix-increase-ipv6-literal-buffer.patch
+netfilter-nft_redir-use-struct-nf_nat_range2-through.patch
+netfilter-nat-fix-ipv6-nat-redirect-with-mapped-and-.patch
diff --git a/queue-5.4/tg3-power-down-device-only-on-system_power_off.patch b/queue-5.4/tg3-power-down-device-only-on-system_power_off.patch
new file mode 100644 (file)
index 0000000..fab2b6c
--- /dev/null
@@ -0,0 +1,46 @@
+From 21bc0e2c3582954ed130915e0034d89d8eb40156 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 3 Nov 2023 13:50:29 +0200
+Subject: tg3: power down device only on SYSTEM_POWER_OFF
+
+From: George Shuklin <george.shuklin@gmail.com>
+
+[ Upstream commit 9fc3bc7643341dc5be7d269f3d3dbe441d8d7ac3 ]
+
+Dell R650xs servers hangs on reboot if tg3 driver calls
+tg3_power_down.
+
+This happens only if network adapters (BCM5720 for R650xs) were
+initialized using SNP (e.g. by booting ipxe.efi).
+
+The actual problem is on Dell side, but this fix allows servers
+to come back alive after reboot.
+
+Signed-off-by: George Shuklin <george.shuklin@gmail.com>
+Fixes: 2ca1c94ce0b6 ("tg3: Disable tg3 device on system reboot to avoid triggering AER")
+Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
+Reviewed-by: Michael Chan <michael.chan@broadcom.com>
+Link: https://lore.kernel.org/r/20231103115029.83273-1-george.shuklin@gmail.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/ethernet/broadcom/tg3.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
+index b16517d162cfd..90bfaea6d6292 100644
+--- a/drivers/net/ethernet/broadcom/tg3.c
++++ b/drivers/net/ethernet/broadcom/tg3.c
+@@ -18164,7 +18164,8 @@ static void tg3_shutdown(struct pci_dev *pdev)
+       if (netif_running(dev))
+               dev_close(dev);
+-      tg3_power_down(tp);
++      if (system_state == SYSTEM_POWER_OFF)
++              tg3_power_down(tp);
+       rtnl_unlock();
+-- 
+2.42.0
+
diff --git a/queue-5.4/tipc-change-nla_policy-for-bearer-related-names-to-n.patch b/queue-5.4/tipc-change-nla_policy-for-bearer-related-names-to-n.patch
new file mode 100644 (file)
index 0000000..6a827ca
--- /dev/null
@@ -0,0 +1,111 @@
+From 2d61a3fe122fa7465422a0a4345a08b738f76bd3 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 30 Oct 2023 16:55:40 +0900
+Subject: tipc: Change nla_policy for bearer-related names to NLA_NUL_STRING
+
+From: Shigeru Yoshida <syoshida@redhat.com>
+
+[ Upstream commit 19b3f72a41a8751e26bffc093bb7e1cef29ad579 ]
+
+syzbot reported the following uninit-value access issue [1]:
+
+=====================================================
+BUG: KMSAN: uninit-value in strlen lib/string.c:418 [inline]
+BUG: KMSAN: uninit-value in strstr+0xb8/0x2f0 lib/string.c:756
+ strlen lib/string.c:418 [inline]
+ strstr+0xb8/0x2f0 lib/string.c:756
+ tipc_nl_node_reset_link_stats+0x3ea/0xb50 net/tipc/node.c:2595
+ genl_family_rcv_msg_doit net/netlink/genetlink.c:971 [inline]
+ genl_family_rcv_msg net/netlink/genetlink.c:1051 [inline]
+ genl_rcv_msg+0x11ec/0x1290 net/netlink/genetlink.c:1066
+ netlink_rcv_skb+0x371/0x650 net/netlink/af_netlink.c:2545
+ genl_rcv+0x40/0x60 net/netlink/genetlink.c:1075
+ netlink_unicast_kernel net/netlink/af_netlink.c:1342 [inline]
+ netlink_unicast+0xf47/0x1250 net/netlink/af_netlink.c:1368
+ netlink_sendmsg+0x1238/0x13d0 net/netlink/af_netlink.c:1910
+ sock_sendmsg_nosec net/socket.c:730 [inline]
+ sock_sendmsg net/socket.c:753 [inline]
+ ____sys_sendmsg+0x9c2/0xd60 net/socket.c:2541
+ ___sys_sendmsg+0x28d/0x3c0 net/socket.c:2595
+ __sys_sendmsg net/socket.c:2624 [inline]
+ __do_sys_sendmsg net/socket.c:2633 [inline]
+ __se_sys_sendmsg net/socket.c:2631 [inline]
+ __x64_sys_sendmsg+0x307/0x490 net/socket.c:2631
+ do_syscall_x64 arch/x86/entry/common.c:50 [inline]
+ do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
+ entry_SYSCALL_64_after_hwframe+0x63/0xcd
+
+Uninit was created at:
+ slab_post_alloc_hook+0x12f/0xb70 mm/slab.h:767
+ slab_alloc_node mm/slub.c:3478 [inline]
+ kmem_cache_alloc_node+0x577/0xa80 mm/slub.c:3523
+ kmalloc_reserve+0x13d/0x4a0 net/core/skbuff.c:559
+ __alloc_skb+0x318/0x740 net/core/skbuff.c:650
+ alloc_skb include/linux/skbuff.h:1286 [inline]
+ netlink_alloc_large_skb net/netlink/af_netlink.c:1214 [inline]
+ netlink_sendmsg+0xb34/0x13d0 net/netlink/af_netlink.c:1885
+ sock_sendmsg_nosec net/socket.c:730 [inline]
+ sock_sendmsg net/socket.c:753 [inline]
+ ____sys_sendmsg+0x9c2/0xd60 net/socket.c:2541
+ ___sys_sendmsg+0x28d/0x3c0 net/socket.c:2595
+ __sys_sendmsg net/socket.c:2624 [inline]
+ __do_sys_sendmsg net/socket.c:2633 [inline]
+ __se_sys_sendmsg net/socket.c:2631 [inline]
+ __x64_sys_sendmsg+0x307/0x490 net/socket.c:2631
+ do_syscall_x64 arch/x86/entry/common.c:50 [inline]
+ do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
+ entry_SYSCALL_64_after_hwframe+0x63/0xcd
+
+TIPC bearer-related names including link names must be null-terminated
+strings. If a link name which is not null-terminated is passed through
+netlink, strstr() and similar functions can cause buffer overrun. This
+causes the above issue.
+
+This patch changes the nla_policy for bearer-related names from NLA_STRING
+to NLA_NUL_STRING. This resolves the issue by ensuring that only
+null-terminated strings are accepted as bearer-related names.
+
+syzbot reported similar uninit-value issue related to bearer names [2]. The
+root cause of this issue is that a non-null-terminated bearer name was
+passed. This patch also resolved this issue.
+
+Fixes: 7be57fc69184 ("tipc: add link get/dump to new netlink api")
+Fixes: 0655f6a8635b ("tipc: add bearer disable/enable to new netlink api")
+Reported-and-tested-by: syzbot+5138ca807af9d2b42574@syzkaller.appspotmail.com
+Closes: https://syzkaller.appspot.com/bug?extid=5138ca807af9d2b42574 [1]
+Reported-and-tested-by: syzbot+9425c47dccbcb4c17d51@syzkaller.appspotmail.com
+Closes: https://syzkaller.appspot.com/bug?extid=9425c47dccbcb4c17d51 [2]
+Signed-off-by: Shigeru Yoshida <syoshida@redhat.com>
+Reviewed-by: Jiri Pirko <jiri@nvidia.com>
+Link: https://lore.kernel.org/r/20231030075540.3784537-1-syoshida@redhat.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ net/tipc/netlink.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/net/tipc/netlink.c b/net/tipc/netlink.c
+index e9bbf4a00881a..5c58aff4d4fab 100644
+--- a/net/tipc/netlink.c
++++ b/net/tipc/netlink.c
+@@ -87,7 +87,7 @@ const struct nla_policy tipc_nl_net_policy[TIPC_NLA_NET_MAX + 1] = {
+ const struct nla_policy tipc_nl_link_policy[TIPC_NLA_LINK_MAX + 1] = {
+       [TIPC_NLA_LINK_UNSPEC]          = { .type = NLA_UNSPEC },
+-      [TIPC_NLA_LINK_NAME]            = { .type = NLA_STRING,
++      [TIPC_NLA_LINK_NAME]            = { .type = NLA_NUL_STRING,
+                                           .len = TIPC_MAX_LINK_NAME },
+       [TIPC_NLA_LINK_MTU]             = { .type = NLA_U32 },
+       [TIPC_NLA_LINK_BROADCAST]       = { .type = NLA_FLAG },
+@@ -118,7 +118,7 @@ const struct nla_policy tipc_nl_prop_policy[TIPC_NLA_PROP_MAX + 1] = {
+ const struct nla_policy tipc_nl_bearer_policy[TIPC_NLA_BEARER_MAX + 1]        = {
+       [TIPC_NLA_BEARER_UNSPEC]        = { .type = NLA_UNSPEC },
+-      [TIPC_NLA_BEARER_NAME]          = { .type = NLA_STRING,
++      [TIPC_NLA_BEARER_NAME]          = { .type = NLA_NUL_STRING,
+                                           .len = TIPC_MAX_BEARER_NAME },
+       [TIPC_NLA_BEARER_PROP]          = { .type = NLA_NESTED },
+       [TIPC_NLA_BEARER_DOMAIN]        = { .type = NLA_U32 }
+-- 
+2.42.0
+