* [PATCH] [net:netfilter]: Keep conntrack reference until IPsecv6 policy checks are done
@ 2023-03-02 11:23 Madhu Koriginja
2023-03-02 11:35 ` Florian Westphal
2023-03-02 14:27 ` Paolo Abeni
0 siblings, 2 replies; 6+ messages in thread
From: Madhu Koriginja @ 2023-03-02 11:23 UTC (permalink / raw)
To: gerrit, davem, kuznet, yoshfuji, edumazet, dccp, netdev,
linux-kernel
Cc: vani.namala, Madhu Koriginja
Keep the conntrack reference until policy checks have been performed for
IPsec V6 NAT support. The reference needs to be dropped before a packet is
queued to avoid having the conntrack module unloadable.
Signed-off-by: Madhu Koriginja <madhu.koriginja@nxp.com>
V1-V2: added missing () in ip6_input.c in below condition
if (!(ipprot->flags & INET6_PROTO_NOPOLICY))
---
net/dccp/ipv6.c | 1 +
net/ipv6/ip6_input.c | 14 +++++++-------
net/ipv6/raw.c | 2 +-
net/ipv6/tcp_ipv6.c | 2 ++
net/ipv6/udp.c | 2 ++
5 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 58a401e9cf09..eb503096db6c 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -771,6 +771,7 @@ static int dccp_v6_rcv(struct sk_buff *skb)
if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
goto discard_and_relse;
+ nf_reset(skb);
return __sk_receive_skb(sk, skb, 1, dh->dccph_doff * 4,
refcounted) ? -1 : 0;
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index acf0749ee5bb..10d9c33cbdda 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -374,10 +374,6 @@ static int ip6_input_finish(struct net *net, struct sock *sk, struct sk_buff *sk
/* Only do this once for first final protocol */
have_final = true;
- /* Free reference early: we don't need it any more,
- and it may hold ip_conntrack module loaded
- indefinitely. */
- nf_reset(skb);
skb_postpull_rcsum(skb, skb_network_header(skb),
skb_network_header_len(skb));
@@ -388,9 +384,13 @@ static int ip6_input_finish(struct net *net, struct sock *sk, struct sk_buff *sk
!ipv6_is_mld(skb, nexthdr, skb_network_header_len(skb)))
goto discard;
}
- if (!(ipprot->flags & INET6_PROTO_NOPOLICY) &&
- !xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
- goto discard;
+
+ if (!(ipprot->flags & INET6_PROTO_NOPOLICY)) {
+ if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
+ goto discard;
+
+ nf_reset(skb);
+ }
ret = ipprot->handler(skb);
if (ret > 0) {
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 4856d9320b28..cf68c9418897 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -220,7 +220,6 @@ static bool ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)
/* Not releasing hash table! */
if (clone) {
- nf_reset(clone);
rawv6_rcv(sk, clone);
}
}
@@ -428,6 +427,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
kfree_skb(skb);
return NET_RX_DROP;
}
+ nf_reset(skb);
if (!rp->checksum)
skb->ip_summed = CHECKSUM_UNNECESSARY;
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 9a117a79af65..0bc959cfbea4 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1534,6 +1534,8 @@ static int tcp_v6_rcv(struct sk_buff *skb)
if (tcp_v6_inbound_md5_hash(sk, skb))
goto discard_and_relse;
+ nf_reset(skb);
+
if (tcp_filter(sk, skb))
goto discard_and_relse;
th = (const struct tcphdr *)skb->data;
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 72b2e7809af6..aacb48e977cb 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -567,6 +567,7 @@ static int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
goto drop;
+ nf_reset(skb);
if (static_branch_unlikely(&udpv6_encap_needed_key) && up->encap_type) {
int (*encap_rcv)(struct sock *sk, struct sk_buff *skb);
@@ -860,6 +861,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
goto discard;
+ nf_reset(skb);
if (udp_lib_checksum_complete(skb))
goto csum_error;
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] [net:netfilter]: Keep conntrack reference until IPsecv6 policy checks are done
2023-03-02 11:23 [PATCH] [net:netfilter]: Keep conntrack reference until IPsecv6 policy checks are done Madhu Koriginja
@ 2023-03-02 11:35 ` Florian Westphal
2023-03-02 14:27 ` Paolo Abeni
1 sibling, 0 replies; 6+ messages in thread
From: Florian Westphal @ 2023-03-02 11:35 UTC (permalink / raw)
To: Madhu Koriginja
Cc: gerrit, davem, kuznet, yoshfuji, edumazet, dccp, netdev,
linux-kernel, vani.namala
Madhu Koriginja <madhu.koriginja@nxp.com> wrote:
> Keep the conntrack reference until policy checks have been performed for
> IPsec V6 NAT support. The reference needs to be dropped before a packet is
> queued to avoid having the conntrack module unloadable.
Subject Line should be:
[PATCH net] net: netfilter: Keep conntrack reference until IPsecv6 policy checks are done
or
[PATCH net-next] net: netfilter: Keep ..
see below why net-next makes more sense to me.
> Signed-off-by: Madhu Koriginja <madhu.koriginja@nxp.com>
> V1-V2: added missing () in ip6_input.c in below condition
> if (!(ipprot->flags & INET6_PROTO_NOPOLICY))
This should appear before your signed-off-by, or
> ---
> net/dccp/ipv6.c | 1 +
... here.
I think its fine to place it here because in this case
the mini-changelog doesn't provide any additional context
worth keeping in git.
Paolo, Jakub, David: This is a bug, but its not a regression
either. I would suggest that Madhu resubmits this AFTER
net-next re-opens.
Madhu, if thats the agreed-upon procedure, you may include
Reviewed-by: Florian Westphal <fw@strlen.de>
when you resend this patch as-is.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [net:netfilter]: Keep conntrack reference until IPsecv6 policy checks are done
2023-03-02 11:23 [PATCH] [net:netfilter]: Keep conntrack reference until IPsecv6 policy checks are done Madhu Koriginja
2023-03-02 11:35 ` Florian Westphal
@ 2023-03-02 14:27 ` Paolo Abeni
2023-03-03 9:53 ` [EXT] " Madhu Koriginja
1 sibling, 1 reply; 6+ messages in thread
From: Paolo Abeni @ 2023-03-02 14:27 UTC (permalink / raw)
To: Madhu Koriginja, gerrit, davem, kuznet, yoshfuji, edumazet, dccp,
netdev, linux-kernel
Cc: vani.namala
On Thu, 2023-03-02 at 16:53 +0530, Madhu Koriginja wrote:
> Keep the conntrack reference until policy checks have been performed for
> IPsec V6 NAT support. The reference needs to be dropped before a packet is
> queued to avoid having the conntrack module unloadable.
>
> Signed-off-by: Madhu Koriginja <madhu.koriginja@nxp.com>
> V1-V2: added missing () in ip6_input.c in below condition
> if (!(ipprot->flags & INET6_PROTO_NOPOLICY))
> ---
> net/dccp/ipv6.c | 1 +
> net/ipv6/ip6_input.c | 14 +++++++-------
> net/ipv6/raw.c | 2 +-
> net/ipv6/tcp_ipv6.c | 2 ++
> net/ipv6/udp.c | 2 ++
> 5 files changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
> index 58a401e9cf09..eb503096db6c 100644
> --- a/net/dccp/ipv6.c
> +++ b/net/dccp/ipv6.c
> @@ -771,6 +771,7 @@ static int dccp_v6_rcv(struct sk_buff *skb)
>
> if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
> goto discard_and_relse;
> + nf_reset(skb);
nf_reset() is gone since commit 895b5c9f206e ("netfilter: drop bridge
nf reset from nf_reset"), you should use instead nf_reset_ct(): in the
current form the patch does not apply cleanly (nor build after manual
edit).
Cheers,
Paolo
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [EXT] Re: [PATCH] [net:netfilter]: Keep conntrack reference until IPsecv6 policy checks are done
2023-03-02 14:27 ` Paolo Abeni
@ 2023-03-03 9:53 ` Madhu Koriginja
2023-03-07 6:22 ` Madhu Koriginja
0 siblings, 1 reply; 6+ messages in thread
From: Madhu Koriginja @ 2023-03-03 9:53 UTC (permalink / raw)
To: Paolo Abeni, gerrit@erg.abdn.ac.uk, davem@davemloft.net,
kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org,
edumazet@google.com, dccp@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Vani Namala
Hi Paolo,
I updated the patch with nf_reset_ct change (nf_reset() replaced with nf_reset_ct) to align with the latest kernel code.
Hi All,
I also want to push this change (with nf_reset) in 4.19 LTS kernel, please can you tell me how can I push to that version? Thanks in advance.
Hi Florian,
In patchv3 updated the subject line as you suggested.
Thanks & Regards,
Madhu K
-----Original Message-----
From: Paolo Abeni <pabeni@redhat.com>
Sent: Thursday, March 2, 2023 7:58 PM
To: Madhu Koriginja <madhu.koriginja@nxp.com>; gerrit@erg.abdn.ac.uk; davem@davemloft.net; kuznet@ms2.inr.ac.ru; yoshfuji@linux-ipv6.org; edumazet@google.com; dccp@vger.kernel.org; netdev@vger.kernel.org; linux-kernel@vger.kernel.org
Cc: Vani Namala <vani.namala@nxp.com>
Subject: [EXT] Re: [PATCH] [net:netfilter]: Keep conntrack reference until IPsecv6 policy checks are done
Caution: EXT Email
On Thu, 2023-03-02 at 16:53 +0530, Madhu Koriginja wrote:
> Keep the conntrack reference until policy checks have been performed
> for IPsec V6 NAT support. The reference needs to be dropped before a
> packet is queued to avoid having the conntrack module unloadable.
>
> Signed-off-by: Madhu Koriginja <madhu.koriginja@nxp.com>
> V1-V2: added missing () in ip6_input.c in below condition
> if (!(ipprot->flags & INET6_PROTO_NOPOLICY))
> ---
> net/dccp/ipv6.c | 1 +
> net/ipv6/ip6_input.c | 14 +++++++-------
> net/ipv6/raw.c | 2 +-
> net/ipv6/tcp_ipv6.c | 2 ++
> net/ipv6/udp.c | 2 ++
> 5 files changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index
> 58a401e9cf09..eb503096db6c 100644
> --- a/net/dccp/ipv6.c
> +++ b/net/dccp/ipv6.c
> @@ -771,6 +771,7 @@ static int dccp_v6_rcv(struct sk_buff *skb)
>
> if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
> goto discard_and_relse;
> + nf_reset(skb);
nf_reset() is gone since commit 895b5c9f206e ("netfilter: drop bridge nf reset from nf_reset"), you should use instead nf_reset_ct(): in the current form the patch does not apply cleanly (nor build after manual edit).
Cheers,
Paolo
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [EXT] Re: [PATCH] [net:netfilter]: Keep conntrack reference until IPsecv6 policy checks are done
2023-03-03 9:53 ` [EXT] " Madhu Koriginja
@ 2023-03-07 6:22 ` Madhu Koriginja
0 siblings, 0 replies; 6+ messages in thread
From: Madhu Koriginja @ 2023-03-07 6:22 UTC (permalink / raw)
To: Paolo Abeni, gerrit@erg.abdn.ac.uk, davem@davemloft.net,
kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org,
edumazet@google.com, dccp@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Vani Namala
Hi Florian/Paolo,
As Florian suggested I changed the subject title, due to this patch is pushed in different link. Please find the nf_reset_ct changes patch in the below link
https://lore.kernel.org/lkml/20230303094221.1501961-1-madhu.koriginja@nxp.com/T/
Please can you also suggest me how to push patch on 4.19 LTS kernel.
Thanks & Regards,
Madhu K
-----Original Message-----
From: Madhu Koriginja
Sent: Friday, March 3, 2023 3:23 PM
To: Paolo Abeni <pabeni@redhat.com>; gerrit@erg.abdn.ac.uk; davem@davemloft.net; kuznet@ms2.inr.ac.ru; yoshfuji@linux-ipv6.org; edumazet@google.com; dccp@vger.kernel.org; netdev@vger.kernel.org; linux-kernel@vger.kernel.org
Cc: Vani Namala <vani.namala@nxp.com>
Subject: RE: [EXT] Re: [PATCH] [net:netfilter]: Keep conntrack reference until IPsecv6 policy checks are done
Hi Paolo,
I updated the patch with nf_reset_ct change (nf_reset() replaced with nf_reset_ct) to align with the latest kernel code.
Hi All,
I also want to push this change (with nf_reset) in 4.19 LTS kernel, please can you tell me how can I push to that version? Thanks in advance.
Hi Florian,
In patchv3 updated the subject line as you suggested.
Thanks & Regards,
Madhu K
-----Original Message-----
From: Paolo Abeni <pabeni@redhat.com>
Sent: Thursday, March 2, 2023 7:58 PM
To: Madhu Koriginja <madhu.koriginja@nxp.com>; gerrit@erg.abdn.ac.uk; davem@davemloft.net; kuznet@ms2.inr.ac.ru; yoshfuji@linux-ipv6.org; edumazet@google.com; dccp@vger.kernel.org; netdev@vger.kernel.org; linux-kernel@vger.kernel.org
Cc: Vani Namala <vani.namala@nxp.com>
Subject: [EXT] Re: [PATCH] [net:netfilter]: Keep conntrack reference until IPsecv6 policy checks are done
Caution: EXT Email
On Thu, 2023-03-02 at 16:53 +0530, Madhu Koriginja wrote:
> Keep the conntrack reference until policy checks have been performed
> for IPsec V6 NAT support. The reference needs to be dropped before a
> packet is queued to avoid having the conntrack module unloadable.
>
> Signed-off-by: Madhu Koriginja <madhu.koriginja@nxp.com>
> V1-V2: added missing () in ip6_input.c in below condition
> if (!(ipprot->flags & INET6_PROTO_NOPOLICY))
> ---
> net/dccp/ipv6.c | 1 +
> net/ipv6/ip6_input.c | 14 +++++++-------
> net/ipv6/raw.c | 2 +-
> net/ipv6/tcp_ipv6.c | 2 ++
> net/ipv6/udp.c | 2 ++
> 5 files changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index
> 58a401e9cf09..eb503096db6c 100644
> --- a/net/dccp/ipv6.c
> +++ b/net/dccp/ipv6.c
> @@ -771,6 +771,7 @@ static int dccp_v6_rcv(struct sk_buff *skb)
>
> if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
> goto discard_and_relse;
> + nf_reset(skb);
nf_reset() is gone since commit 895b5c9f206e ("netfilter: drop bridge nf reset from nf_reset"), you should use instead nf_reset_ct(): in the current form the patch does not apply cleanly (nor build after manual edit).
Cheers,
Paolo
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] net : netfilter: Keep conntrack reference until IPsecv6 policy checks are done
@ 2023-03-21 15:58 Madhu Koriginja
0 siblings, 0 replies; 6+ messages in thread
From: Madhu Koriginja @ 2023-03-21 15:58 UTC (permalink / raw)
To: netfilter-devel; +Cc: netdev, vani.namala, Madhu Koriginja
Keep the conntrack reference until policy checks have been performed for
IPsec V6 NAT support. The reference needs to be dropped before a packet is
queued to avoid having the conntrack module unloadable.
Signed-off-by: Madhu Koriginja <madhu.koriginja@nxp.com>
---
net/dccp/ipv6.c | 1 +
net/ipv6/ip6_input.c | 15 ++++++---------
net/ipv6/raw.c | 2 +-
net/ipv6/tcp_ipv6.c | 2 ++
net/ipv6/udp.c | 2 ++
5 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index b9d7c3dd1cb3..c0fd8f5f3b94 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -783,6 +783,7 @@ static int dccp_v6_rcv(struct sk_buff *skb)
if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
goto discard_and_relse;
+ nf_reset_ct(skb);
return __sk_receive_skb(sk, skb, 1, dh->dccph_doff * 4,
refcounted) ? -1 : 0;
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index e1ebf5e42ebe..25249cd3b639 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -404,10 +404,6 @@ void ip6_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int nexthdr,
/* Only do this once for first final protocol */
have_final = true;
- /* Free reference early: we don't need it any more,
- and it may hold ip_conntrack module loaded
- indefinitely. */
- nf_reset_ct(skb);
skb_postpull_rcsum(skb, skb_network_header(skb),
skb_network_header_len(skb));
@@ -430,12 +426,13 @@ void ip6_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int nexthdr,
goto discard;
}
}
- if (!(ipprot->flags & INET6_PROTO_NOPOLICY) &&
- !xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) {
- SKB_DR_SET(reason, XFRM_POLICY);
- goto discard;
+ if (!(ipprot->flags & INET6_PROTO_NOPOLICY)) {
+ if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) {
+ SKB_DR_SET(reason, XFRM_POLICY);
+ goto discard;
+ }
+ nf_reset_ct(skb);
}
-
ret = INDIRECT_CALL_2(ipprot->handler, tcp_v6_rcv, udpv6_rcv,
skb);
if (ret > 0) {
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index bac9ba747bde..b035e049fb65 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -195,7 +195,6 @@ static bool ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)
/* Not releasing hash table! */
if (clone) {
- nf_reset_ct(clone);
rawv6_rcv(sk, clone);
}
}
@@ -391,6 +390,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
kfree_skb_reason(skb, SKB_DROP_REASON_XFRM_POLICY);
return NET_RX_DROP;
}
+ nf_reset_ct(skb);
if (!rp->checksum)
skb->ip_summed = CHECKSUM_UNNECESSARY;
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 1bf93b61aa06..1e747241c771 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1722,6 +1722,8 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb)
if (drop_reason)
goto discard_and_relse;
+ nf_reset_ct(skb);
+
if (tcp_filter(sk, skb)) {
drop_reason = SKB_DROP_REASON_SOCKET_FILTER;
goto discard_and_relse;
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 9fb2f33ee3a7..75900564f42a 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -704,6 +704,7 @@ static int udpv6_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb)
drop_reason = SKB_DROP_REASON_XFRM_POLICY;
goto drop;
}
+ nf_reset_ct(skb);
if (static_branch_unlikely(&udpv6_encap_needed_key) && up->encap_type) {
int (*encap_rcv)(struct sock *sk, struct sk_buff *skb);
@@ -1027,6 +1028,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
goto discard;
+ nf_reset_ct(skb);
if (udp_lib_checksum_complete(skb))
goto csum_error;
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-03-21 15:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-02 11:23 [PATCH] [net:netfilter]: Keep conntrack reference until IPsecv6 policy checks are done Madhu Koriginja
2023-03-02 11:35 ` Florian Westphal
2023-03-02 14:27 ` Paolo Abeni
2023-03-03 9:53 ` [EXT] " Madhu Koriginja
2023-03-07 6:22 ` Madhu Koriginja
-- strict thread matches above, loose matches on Subject: below --
2023-03-21 15:58 [PATCH] net : netfilter: " Madhu Koriginja
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).