[SRU][F][PATCH 1/2] net: make sock_inuse_add() available
Massimiliano Pellizzer
massimiliano.pellizzer at canonical.com
Thu May 1 16:01:01 UTC 2025
From: Eric Dumazet <edumazet at google.com>
MPTCP hard codes it, let us instead provide this helper.
Signed-off-by: Eric Dumazet <edumazet at google.com>
Signed-off-by: David S. Miller <davem at davemloft.net>
(backported from commit d477eb9004845cb2dc92ad5eed79a437738a868a)
[mpellizzer: context adjusted due to missing commit:
- 2021-11-15 2a12ae5d433d net: inline sock_prot_inuse_add()
and missing file net/mptcp/subflow.c]
CVE-2024-53168
Signed-off-by: Massimiliano Pellizzer <massimiliano.pellizzer at canonical.com>
---
include/net/sock.h | 10 ++++++++++
net/core/sock.c | 10 ----------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/include/net/sock.h b/include/net/sock.h
index ba5b53201dc5f..dc6d763dfdcc5 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1353,6 +1353,12 @@ proto_memory_pressure(struct proto *prot)
#ifdef CONFIG_PROC_FS
/* Called with local bh disabled */
void sock_prot_inuse_add(struct net *net, struct proto *prot, int inc);
+
+static inline void sock_inuse_add(const struct net *net, int val)
+{
+ this_cpu_add(*net->core.sock_inuse, val);
+}
+
int sock_prot_inuse_get(struct net *net, struct proto *proto);
int sock_inuse_get(struct net *net);
#else
@@ -1360,6 +1366,10 @@ static inline void sock_prot_inuse_add(struct net *net, struct proto *prot,
int inc)
{
}
+
+static inline void sock_inuse_add(const struct net *net, int val)
+{
+}
#endif
diff --git a/net/core/sock.c b/net/core/sock.c
index a318a5ed67f5d..ffa317851982e 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -141,8 +141,6 @@
static DEFINE_MUTEX(proto_list_mutex);
static LIST_HEAD(proto_list);
-static void sock_inuse_add(struct net *net, int val);
-
/**
* sk_ns_capable - General socket capability test
* @sk: Socket to use a capability on or through
@@ -3313,11 +3311,6 @@ int sock_prot_inuse_get(struct net *net, struct proto *prot)
}
EXPORT_SYMBOL_GPL(sock_prot_inuse_get);
-static void sock_inuse_add(struct net *net, int val)
-{
- this_cpu_add(*net->core.sock_inuse, val);
-}
-
int sock_inuse_get(struct net *net)
{
int cpu, res = 0;
@@ -3396,9 +3389,6 @@ static inline void release_proto_idx(struct proto *prot)
{
}
-static void sock_inuse_add(struct net *net, int val)
-{
-}
#endif
static void tw_prot_cleanup(struct timewait_sock_ops *twsk_prot)
--
2.43.0
More information about the kernel-team
mailing list