netfilter: nf_conntrack_sip: guard against missing skb dst
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 netfilter: nf_conntrack_sip: guard against missing skb dst
From: Zhengyang Chen <[email protected]>
set_expected_rtp_rtcp() dereferences skb_dst(skb)->dev when sip_external_media is enabled. The SIP helper can run from tc ingress before routing has attached a dst to the skb, so skb_dst(skb) can be NULL and the helper crashes while parsing SDP media expectations.
Handle a missing skb dst by skipping the same-interface external-media optimization. Still release the routed media dst when one was obtained, and keep the existing expectation setup path unchanged.
--- net/netfilter/nf_conntrack_sip.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_sip.c +5 -2
@@ -956,7 +956,8 @@ static int set_expected_rtp_rtcp(struct sk_buff *skb, unsigned int protoff,return NF_ACCEPT ; saddr = &ct->tuplehash[!dir].tuple.src.u3; }else if (sip_external_media) { -struct net_device *dev =skb_dst (skb)->dev; +struct dst_entry *skbdst =skb_dst (skb); +struct net_device *dev = skbdst ? skbdst->dev :NULL ;struct dst_entry *dst =NULL ;struct flowi fl;
@@ -977,12 +978,14 @@ static int set_expected_rtp_rtcp(struct sk_buff *skb, unsigned int protoff,/* Don't predict any conntracks when media endpoint is reachable * through the same interface as the signalling peer. */ -if (dst) { +if (dst && dev) {bool external_media = (dst->dev == dev);dst_release (dst);if (external_media)return NF_ACCEPT ; + }else if (dst) { +dst_release (dst); } }
Signature · 1 line
2.43.0
Pablo Neira Ayuso
maintainerQuoted 6 lines · Ren Wei
From: Zhengyang Chen <[email protected]>
set_expected_rtp_rtcp()dereferences skb_dst(skb)->dev whensip_external_mediais enabled. The SIP helper can run from tc ingress before routing has attached a dst to the skb, soskb_dst(skb)can be NULL and the helper crashes while parsing SDP media expectations.
If SIP helper can run from tc ingress, then this has not ever worked? Else tc needs to be fixed to set a router to skb before calling the helper.
I don't think this fix belong here.
Quoted 51 lines
Handle a missing skb dst by skipping the same-interface external-media optimization. Still release the routed media dst when one was obtained, and keep the existing expectation setup path unchanged.
Fixes a3419ce3356c ("netfilter: nf_conntrack_sip: add sip_external_media logic")Reported-by Yuan Tan <[email protected]>Reported-by Yifan Wu <[email protected]>Reported-by Juefei Pu <[email protected]>Reported-by Xin Liu <[email protected]>Assisted-by Codex:gpt-5.4Signed-off-by Zhengyang Chen <[email protected]>Signed-off-by Ren Wei <[email protected]>--- net/netfilter/nf_conntrack_sip.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)net/netfilter/nf_conntrack_sip.c +5
-2@@ -956,7 +956,8 @@ static int set_expected_rtp_rtcp(struct sk_buff *skb, unsigned int protoff,return NF_ACCEPT ; saddr = &ct->tuplehash[!dir].tuple.src.u3; }else if (sip_external_media) { -struct net_device *dev =skb_dst (skb)->dev; +struct dst_entry *skbdst =skb_dst (skb); +struct net_device *dev = skbdst ? skbdst->dev :NULL ;struct dst_entry *dst =NULL ;struct flowi fl;@@ -977,12 +978,14 @@ static int set_expected_rtp_rtcp(struct sk_buff *skb, unsigned int protoff,/* Don't predict any conntracks when media endpoint is reachable * through the same interface as the signalling peer. */ -if (dst) { +if (dst && dev) {bool external_media = (dst->dev == dev);dst_release (dst);if (external_media)return NF_ACCEPT ; + }else if (dst) { +dst_release (dst); } }Signature · 1 line
2.43.0
Pablo Neira Ayuso
maintainerQuoted 8 lines · Pablo Neira Ayuso
Quoted 6 lines · Ren Wei
From: Zhengyang Chen <[email protected]>
set_expected_rtp_rtcp()dereferences skb_dst(skb)->dev whensip_external_mediais enabled. The SIP helper can run from tc ingress before routing has attached a dst to the skb, soskb_dst(skb)can be NULL and the helper crashes while parsing SDP media expectations.
Quoted 5 lines
If SIP helper can run from tc ingress, then this has not ever worked? Else tc needs to be fixed to set a router to skb before calling the helper.
I don't think this fix belong here.
Actually, it is the most simple way to fix it here, but I posted a different approach:
https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/
Quoted 5 lines
Quoted 5 lines
Handle a missing skb dst by skipping the same-interface external-media optimization. Still release the routed media dst when one was obtained, and keep the existing expectation setup path unchanged.
Fixes a3419ce3356c ("netfilter: nf_conntrack_sip: add sip_external_media logic")
I am pointing to different Fixes: tag for practical reasons, to highlight this is a dependencies for the tc and ovs subsystems. It seems sip_external_media came _after_ ovs but a bit before tc act_ct, so a3419ce3356c is not precise either.
Quoted 46 lines
Quoted 46 lines
Reported-by Yuan Tan <[email protected]>Reported-by Yifan Wu <[email protected]>Reported-by Juefei Pu <[email protected]>Reported-by Xin Liu <[email protected]>Assisted-by Codex:gpt-5.4Signed-off-by Zhengyang Chen <[email protected]>Signed-off-by Ren Wei <[email protected]>--- net/netfilter/nf_conntrack_sip.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)net/netfilter/nf_conntrack_sip.c +5
-2@@ -956,7 +956,8 @@ static int set_expected_rtp_rtcp(struct sk_buff *skb, unsigned int protoff,return NF_ACCEPT ; saddr = &ct->tuplehash[!dir].tuple.src.u3; }else if (sip_external_media) { -struct net_device *dev =skb_dst (skb)->dev; +struct dst_entry *skbdst =skb_dst (skb); +struct net_device *dev = skbdst ? skbdst->dev :NULL ;struct dst_entry *dst =NULL ;struct flowi fl;@@ -977,12 +978,14 @@ static int set_expected_rtp_rtcp(struct sk_buff *skb, unsigned int protoff,/* Don't predict any conntracks when media endpoint is reachable * through the same interface as the signalling peer. */ -if (dst) { +if (dst && dev) {bool external_media = (dst->dev == dev);dst_release (dst);if (external_media)return NF_ACCEPT ; + }else if (dst) { +dst_release (dst); } }Signature · 1 line
2.43.0
Quoted 20 lines
-----原始邮件-----
发件人: "Pablo Neira Ayuso" <[email protected]>
发送时间:2026-06-26 19:35:05 (星期五)
收件人: "Ren Wei" <[email protected]>
抄送: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected] 主题: Re: [PATCH nf 1/1] netfilter:nf_conntrack_sip: guard against missing skb dstQuoted 12 lines · Pablo Neira Ayuso
Quoted 6 lines · Ren Wei
From: Zhengyang Chen <[email protected]>
set_expected_rtp_rtcp()dereferences skb_dst(skb)->dev whensip_external_mediais enabled. The SIP helper can run from tc ingress before routing has attached a dst to the skb, soskb_dst(skb)can be NULL and the helper crashes while parsing SDP media expectations.If SIP helper can run from tc ingress, then this has not ever worked? Else tc needs to be fixed to set a router to skb before calling the helper.
Quoted 6 lines
Quoted 1 line
I don't think this fix belong here.
Actually, it is the most simple way to fix it here, but I posted a different approach:
https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/
I checked your patch and it addresses the issue.
If that patch moves forward, could the following tags please be considered for our team?
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines
Handle a missing skb dst by skipping the same-interface external-media optimization. Still release the routed media dst when one was obtained, and keep the existing expectation setup path unchanged.
Fixes a3419ce3356c ("netfilter: nf_conntrack_sip: add sip_external_media logic")I am pointing to different Fixes: tag for practical reasons, to highlight this is a dependencies for the tc and ovs subsystems. It seems
sip_external_mediacame _after_ ovs but a bit before tcact_ct, soa3419ce3356cis not precise either.
I used a3419ce3356c because it introduced the sip_external_media branch and the skb_dst() dependency. After checking the affected entry points, the tc/ovs Fixes tags look more suitable for this submission because the crash depends on those helper users.
Quoted 47 lines
Quoted 47 lines
Quoted 47 lines
Reported-by Yuan Tan <[email protected]>Reported-by Yifan Wu <[email protected]>Reported-by Juefei Pu <[email protected]>Reported-by Xin Liu <[email protected]>Assisted-by Codex:gpt-5.4Signed-off-by Zhengyang Chen <[email protected]>Signed-off-by Ren Wei <[email protected]>--- net/netfilter/nf_conntrack_sip.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)net/netfilter/nf_conntrack_sip.c +5
-2@@ -956,7 +956,8 @@ static int set_expected_rtp_rtcp(struct sk_buff *skb, unsigned int protoff,return NF_ACCEPT ; saddr = &ct->tuplehash[!dir].tuple.src.u3; }else if (sip_external_media) { -struct net_device *dev =skb_dst (skb)->dev; +struct dst_entry *skbdst =skb_dst (skb); +struct net_device *dev = skbdst ? skbdst->dev :NULL ;struct dst_entry *dst =NULL ;struct flowi fl;@@ -977,12 +978,14 @@ static int set_expected_rtp_rtcp(struct sk_buff *skb, unsigned int protoff,/* Don't predict any conntracks when media endpoint is reachable * through the same interface as the signalling peer. */ -if (dst) { +if (dst && dev) {bool external_media = (dst->dev == dev);dst_release (dst);if (external_media)return NF_ACCEPT ; + }else if (dst) { +dst_release (dst); } }Signature · 1 line
2.43.0