]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fix up backport of queue-6.6/udp-deal-with-race-between-udp-socket-address-change...
authorSasha Levin <sashal@kernel.org>
Sun, 2 Feb 2025 15:08:14 +0000 (10:08 -0500)
committerSasha Levin <sashal@kernel.org>
Sun, 2 Feb 2025 15:08:14 +0000 (10:08 -0500)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-6.6/ipv6-udp-constify-struct-net-parameter-of-socket-loo.patch [new file with mode: 0644]
queue-6.6/series
queue-6.6/udp-constify-struct-net-parameter-of-socket-lookups.patch [new file with mode: 0644]

diff --git a/queue-6.6/ipv6-udp-constify-struct-net-parameter-of-socket-loo.patch b/queue-6.6/ipv6-udp-constify-struct-net-parameter-of-socket-loo.patch
new file mode 100644 (file)
index 0000000..9e8361f
--- /dev/null
@@ -0,0 +1,99 @@
+From 8d29ccb3f84fea85dbcb5f8c2f01fa2bfd91b9b5 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 2 Aug 2024 13:40:29 +0000
+Subject: ipv6: udp: constify 'struct net' parameter of socket lookups
+
+From: Eric Dumazet <edumazet@google.com>
+
+[ Upstream commit 87d973e8ddeeddf1777e6689df86d5d369cbcbb3 ]
+
+Following helpers do not touch their 'struct net' argument.
+
+- udp6_lib_lookup()
+- __udp6_lib_lookup()
+
+Signed-off-by: Eric Dumazet <edumazet@google.com>
+Reviewed-by: Simon Horman <horms@kernel.org>
+Link: https://patch.msgid.link/20240802134029.3748005-6-edumazet@google.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/net/ipv6_stubs.h | 2 +-
+ include/net/udp.h        | 4 ++--
+ net/ipv6/udp.c           | 8 ++++----
+ 3 files changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/include/net/ipv6_stubs.h b/include/net/ipv6_stubs.h
+index 21da31e1dff5d..705d3fbc79b95 100644
+--- a/include/net/ipv6_stubs.h
++++ b/include/net/ipv6_stubs.h
+@@ -76,7 +76,7 @@ extern const struct ipv6_stub *ipv6_stub __read_mostly;
+ struct ipv6_bpf_stub {
+       int (*inet6_bind)(struct sock *sk, struct sockaddr *uaddr, int addr_len,
+                         u32 flags);
+-      struct sock *(*udp6_lib_lookup)(struct net *net,
++      struct sock *(*udp6_lib_lookup)(const struct net *net,
+                                    const struct in6_addr *saddr, __be16 sport,
+                                    const struct in6_addr *daddr, __be16 dport,
+                                    int dif, int sdif, struct udp_table *tbl,
+diff --git a/include/net/udp.h b/include/net/udp.h
+index 488a6d2babccf..471bff463d7db 100644
+--- a/include/net/udp.h
++++ b/include/net/udp.h
+@@ -303,11 +303,11 @@ struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport,
+                              struct udp_table *tbl, struct sk_buff *skb);
+ struct sock *udp4_lib_lookup_skb(const struct sk_buff *skb,
+                                __be16 sport, __be16 dport);
+-struct sock *udp6_lib_lookup(struct net *net,
++struct sock *udp6_lib_lookup(const struct net *net,
+                            const struct in6_addr *saddr, __be16 sport,
+                            const struct in6_addr *daddr, __be16 dport,
+                            int dif);
+-struct sock *__udp6_lib_lookup(struct net *net,
++struct sock *__udp6_lib_lookup(const struct net *net,
+                              const struct in6_addr *saddr, __be16 sport,
+                              const struct in6_addr *daddr, __be16 dport,
+                              int dif, int sdif, struct udp_table *tbl,
+diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
+index 954afe6ba883e..a67bbb3bde954 100644
+--- a/net/ipv6/udp.c
++++ b/net/ipv6/udp.c
+@@ -117,7 +117,7 @@ void udp_v6_rehash(struct sock *sk)
+       udp_lib_rehash(sk, new_hash);
+ }
+-static int compute_score(struct sock *sk, struct net *net,
++static int compute_score(struct sock *sk, const struct net *net,
+                        const struct in6_addr *saddr, __be16 sport,
+                        const struct in6_addr *daddr, unsigned short hnum,
+                        int dif, int sdif)
+@@ -163,7 +163,7 @@ static int compute_score(struct sock *sk, struct net *net,
+ }
+ /* called with rcu_read_lock() */
+-static struct sock *udp6_lib_lookup2(struct net *net,
++static struct sock *udp6_lib_lookup2(const struct net *net,
+               const struct in6_addr *saddr, __be16 sport,
+               const struct in6_addr *daddr, unsigned int hnum,
+               int dif, int sdif, struct udp_hslot *hslot2,
+@@ -220,7 +220,7 @@ static struct sock *udp6_lib_lookup2(struct net *net,
+ }
+ /* rcu_read_lock() must be held */
+-struct sock *__udp6_lib_lookup(struct net *net,
++struct sock *__udp6_lib_lookup(const struct net *net,
+                              const struct in6_addr *saddr, __be16 sport,
+                              const struct in6_addr *daddr, __be16 dport,
+                              int dif, int sdif, struct udp_table *udptable,
+@@ -303,7 +303,7 @@ struct sock *udp6_lib_lookup_skb(const struct sk_buff *skb,
+  * Does increment socket refcount.
+  */
+ #if IS_ENABLED(CONFIG_NF_TPROXY_IPV6) || IS_ENABLED(CONFIG_NF_SOCKET_IPV6)
+-struct sock *udp6_lib_lookup(struct net *net, const struct in6_addr *saddr, __be16 sport,
++struct sock *udp6_lib_lookup(const struct net *net, const struct in6_addr *saddr, __be16 sport,
+                            const struct in6_addr *daddr, __be16 dport, int dif)
+ {
+       struct sock *sk;
+-- 
+2.39.5
+
index 449b2c4ca8dbcb6f4d29131dc4e4843f7b4dae72..60b153954df9cf8eef62497ae30763da84fc1fc0 100644 (file)
@@ -89,6 +89,8 @@ gpio-pca953x-fully-convert-to-device-managed-resourc.patch
 gpio-pca953x-log-an-error-when-failing-to-get-the-re.patch
 cpufreq-qcom-fix-qcom_cpufreq_hw_recalc_rate-to-quer.patch
 cpufreq-qcom-implement-clk_ops-determine_rate-for-qc.patch
+ipv6-udp-constify-struct-net-parameter-of-socket-loo.patch
+udp-constify-struct-net-parameter-of-socket-lookups.patch
 udp-deal-with-race-between-udp-socket-address-change.patch
 clk-imx8mp-fix-clkout1-2-support.patch
 team-prevent-adding-a-device-which-is-already-a-team.patch
diff --git a/queue-6.6/udp-constify-struct-net-parameter-of-socket-lookups.patch b/queue-6.6/udp-constify-struct-net-parameter-of-socket-lookups.patch
new file mode 100644 (file)
index 0000000..d67a26c
--- /dev/null
@@ -0,0 +1,104 @@
+From ab43f971dcd74cc99a84d546a638ad6d14866816 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 2 Aug 2024 13:40:27 +0000
+Subject: udp: constify 'struct net' parameter of socket lookups
+
+From: Eric Dumazet <edumazet@google.com>
+
+[ Upstream commit b9abcbb1239cd782f76532397a7c45458de9a73e ]
+
+Following helpers do not touch their 'struct net' argument.
+
+- udp_sk_bound_dev_eq()
+- udp4_lib_lookup()
+- __udp4_lib_lookup()
+
+Signed-off-by: Eric Dumazet <edumazet@google.com>
+Reviewed-by: Simon Horman <horms@kernel.org>
+Link: https://patch.msgid.link/20240802134029.3748005-4-edumazet@google.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ include/net/udp.h | 10 ++++++----
+ net/ipv4/udp.c    |  8 ++++----
+ 2 files changed, 10 insertions(+), 8 deletions(-)
+
+diff --git a/include/net/udp.h b/include/net/udp.h
+index 471bff463d7db..92f7ed547abc7 100644
+--- a/include/net/udp.h
++++ b/include/net/udp.h
+@@ -79,7 +79,8 @@ struct udp_table {
+ extern struct udp_table udp_table;
+ void udp_table_init(struct udp_table *, const char *);
+ static inline struct udp_hslot *udp_hashslot(struct udp_table *table,
+-                                           struct net *net, unsigned int num)
++                                           const struct net *net,
++                                           unsigned int num)
+ {
+       return &table->hash[udp_hashfn(net, num, table->mask)];
+ }
+@@ -245,7 +246,7 @@ static inline int udp_rqueue_get(struct sock *sk)
+       return sk_rmem_alloc_get(sk) - READ_ONCE(udp_sk(sk)->forward_deficit);
+ }
+-static inline bool udp_sk_bound_dev_eq(struct net *net, int bound_dev_if,
++static inline bool udp_sk_bound_dev_eq(const struct net *net, int bound_dev_if,
+                                      int dif, int sdif)
+ {
+ #if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV)
+@@ -296,9 +297,10 @@ int udp_lib_getsockopt(struct sock *sk, int level, int optname,
+ int udp_lib_setsockopt(struct sock *sk, int level, int optname,
+                      sockptr_t optval, unsigned int optlen,
+                      int (*push_pending_frames)(struct sock *));
+-struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport,
++struct sock *udp4_lib_lookup(const struct net *net, __be32 saddr, __be16 sport,
+                            __be32 daddr, __be16 dport, int dif);
+-struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport,
++struct sock *__udp4_lib_lookup(const struct net *net, __be32 saddr,
++                             __be16 sport,
+                              __be32 daddr, __be16 dport, int dif, int sdif,
+                              struct udp_table *tbl, struct sk_buff *skb);
+ struct sock *udp4_lib_lookup_skb(const struct sk_buff *skb,
+diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
+index 2e4e535603948..7bb0587c78874 100644
+--- a/net/ipv4/udp.c
++++ b/net/ipv4/udp.c
+@@ -365,7 +365,7 @@ int udp_v4_get_port(struct sock *sk, unsigned short snum)
+       return udp_lib_get_port(sk, snum, hash2_nulladdr);
+ }
+-static int compute_score(struct sock *sk, struct net *net,
++static int compute_score(struct sock *sk, const struct net *net,
+                        __be32 saddr, __be16 sport,
+                        __be32 daddr, unsigned short hnum,
+                        int dif, int sdif)
+@@ -422,7 +422,7 @@ u32 udp_ehashfn(const struct net *net, const __be32 laddr, const __u16 lport,
+ }
+ /* called with rcu_read_lock() */
+-static struct sock *udp4_lib_lookup2(struct net *net,
++static struct sock *udp4_lib_lookup2(const struct net *net,
+                                    __be32 saddr, __be16 sport,
+                                    __be32 daddr, unsigned int hnum,
+                                    int dif, int sdif,
+@@ -482,7 +482,7 @@ static struct sock *udp4_lib_lookup2(struct net *net,
+ /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
+  * harder than this. -DaveM
+  */
+-struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr,
++struct sock *__udp4_lib_lookup(const struct net *net, __be32 saddr,
+               __be16 sport, __be32 daddr, __be16 dport, int dif,
+               int sdif, struct udp_table *udptable, struct sk_buff *skb)
+ {
+@@ -563,7 +563,7 @@ struct sock *udp4_lib_lookup_skb(const struct sk_buff *skb,
+  * Does increment socket refcount.
+  */
+ #if IS_ENABLED(CONFIG_NF_TPROXY_IPV4) || IS_ENABLED(CONFIG_NF_SOCKET_IPV4)
+-struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport,
++struct sock *udp4_lib_lookup(const struct net *net, __be32 saddr, __be16 sport,
+                            __be32 daddr, __be16 dport, int dif)
+ {
+       struct sock *sk;
+-- 
+2.39.5
+