lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20220829114507.GA2348@debian>
Date:   Mon, 29 Aug 2022 13:45:20 +0200
From:   Richard Gobert <richardbgobert@...il.com>
To:     davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
        pabeni@...hat.com, corbet@....net, yoshfuji@...ux-ipv6.org,
        dsahern@...nel.org, alex.aring@...il.com,
        stefan@...enfreihafen.org, pablo@...filter.org,
        kadlec@...filter.org, fw@...len.de, kafai@...com,
        netdev@...r.kernel.org, linux-doc@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-wpan@...r.kernel.org,
        netfilter-devel@...r.kernel.org, coreteam@...filter.org
Subject: [PATCH 1/4] net-next: frags: move inetpeer from ip4 to inet

Move frags-related inetpeer logic from ip4 to inet. This allows us to
access peer information inside inet_frag logic.

Signed-off-by: Richard Gobert <richardbgobert@...il.com>
---
 include/net/inet_frag.h  |  1 +
 net/ipv4/inet_fragment.c | 11 ++++++++++-
 net/ipv4/ip_fragment.c   | 19 +++----------------
 3 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h
index 0b0876610553..05d95fad8a1a 100644
--- a/include/net/inet_frag.h
+++ b/include/net/inet_frag.h
@@ -98,6 +98,7 @@ struct inet_frag_queue {
 	__u8			flags;
 	u16			max_size;
 	struct fqdir		*fqdir;
+	struct inet_peer	*peer;
 	struct rcu_head		rcu;
 };
 
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
index c9f9ac5013a7..c3ec1dbe7081 100644
--- a/net/ipv4/inet_fragment.c
+++ b/net/ipv4/inet_fragment.c
@@ -23,6 +23,7 @@
 #include <net/inet_ecn.h>
 #include <net/ip.h>
 #include <net/ipv6.h>
+#include <net/inetpeer.h>
 
 /* Use skb->cb to track consecutive/adjacent fragments coming at
  * the end of the queue. Nodes in the rb-tree queue will
@@ -282,6 +283,14 @@ unsigned int inet_frag_rbtree_purge(struct rb_root *root)
 }
 EXPORT_SYMBOL(inet_frag_rbtree_purge);
 
+void inet_frag_free(struct inet_frag_queue *q)
+{
+	if (q->peer)
+		inet_putpeer(q->peer);
+
+	call_rcu(&q->rcu, inet_frag_destroy_rcu);
+}
+
 void inet_frag_destroy(struct inet_frag_queue *q)
 {
 	struct fqdir *fqdir;
@@ -297,7 +306,7 @@ void inet_frag_destroy(struct inet_frag_queue *q)
 	sum_truesize = inet_frag_rbtree_purge(&q->rb_fragments);
 	sum = sum_truesize + f->qsize;
 
-	call_rcu(&q->rcu, inet_frag_destroy_rcu);
+	inet_frag_free(q);
 
 	sub_frag_mem_limit(fqdir, sum);
 }
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index fb153569889e..d0c22c41cf26 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -65,7 +65,6 @@ struct ipq {
 	u16		max_df_size; /* largest frag with DF set seen */
 	int             iif;
 	unsigned int    rid;
-	struct inet_peer *peer;
 };
 
 static u8 ip4_frag_ecn(u8 tos)
@@ -88,21 +87,9 @@ static void ip4_frag_init(struct inet_frag_queue *q, const void *a)
 
 	q->key.v4 = *key;
 	qp->ecn = 0;
-	qp->peer = q->fqdir->max_dist ?
-		inet_getpeer_v4(net->ipv4.peers, key->saddr, key->vif, 1) :
-		NULL;
+	q->peer = inet_getpeer_v4(net->ipv4.peers, key->saddr, key->vif, 1);
 }
 
-static void ip4_frag_free(struct inet_frag_queue *q)
-{
-	struct ipq *qp;
-
-	qp = container_of(q, struct ipq, q);
-	if (qp->peer)
-		inet_putpeer(qp->peer);
-}
-
-
 /* Destruction primitives. */
 
 static void ipq_put(struct ipq *ipq)
@@ -224,7 +211,7 @@ static struct ipq *ip_find(struct net *net, struct iphdr *iph,
 /* Is the fragment too far ahead to be part of ipq? */
 static int ip_frag_too_far(struct ipq *qp)
 {
-	struct inet_peer *peer = qp->peer;
+	struct inet_peer *peer = qp->q.peer;
 	unsigned int max = qp->q.fqdir->max_dist;
 	unsigned int start, end;
 
@@ -741,7 +728,7 @@ static const struct rhashtable_params ip4_rhash_params = {
 void __init ipfrag_init(void)
 {
 	ip4_frags.constructor = ip4_frag_init;
-	ip4_frags.destructor = ip4_frag_free;
+	ip4_frags.destructor = NULL;
 	ip4_frags.qsize = sizeof(struct ipq);
 	ip4_frags.frag_expire = ip_expire;
 	ip4_frags.frags_cache_name = ip_frag_cache_name;
-- 
2.36.1

Powered by blists - more mailing lists