netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] br_netfilter: Drop dst references before setting.
@ 2022-08-19 18:34 Harsh Modi
  2022-08-23  1:56 ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Harsh Modi @ 2022-08-19 18:34 UTC (permalink / raw)
  To: netdev; +Cc: harshmodi, sdf

It is possible that there is already a dst allocated. If it is not
released, it will be leaked. This is similar to what is done in
bpf_set_tunnel_key().

Signed-off-by: Harsh Modi <harshmodi@google.com>
---
 net/bridge/br_netfilter_hooks.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/bridge/br_netfilter_hooks.c b/net/bridge/br_netfilter_hooks.c
index ff4779036649..f20f4373ff40 100644
--- a/net/bridge/br_netfilter_hooks.c
+++ b/net/bridge/br_netfilter_hooks.c
@@ -384,6 +384,7 @@ static int br_nf_pre_routing_finish(struct net *net, struct sock *sk, struct sk_
 				/* - Bridged-and-DNAT'ed traffic doesn't
 				 *   require ip_forwarding. */
 				if (rt->dst.dev == dev) {
+					skb_dst_drop(skb);
 					skb_dst_set(skb, &rt->dst);
 					goto bridged_dnat;
 				}
@@ -413,6 +414,7 @@ static int br_nf_pre_routing_finish(struct net *net, struct sock *sk, struct sk_
 			kfree_skb(skb);
 			return 0;
 		}
+		skb_dst_drop(skb);
 		skb_dst_set_noref(skb, &rt->dst);
 	}
 
-- 
2.37.1.595.g718a3a8f04-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-23  2:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-19 18:34 [PATCH] br_netfilter: Drop dst references before setting Harsh Modi
2022-08-23  1:56 ` Jakub Kicinski
2022-08-23  2:35   ` Harsh Modi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).