netfilter: nf_nat: fix crash in nf_nat_csum
Subsystems (2)
PATCH 1/1 netfilter: nf_nat: fix crash in nf_nat_csum
Fix crash in nf_nat_csum when mangling packets
in OUTPUT hook where skb->dev is not defined, it is set later before POSTROUTING. Problem happens for CHECKSUM_NONE. We can check device from rt but using CHECKSUM_PARTIAL should be safe (skb_checksum_help).
---
net/ipv4/netfilter/nf_nat_helper.c renamed from linux/net/ipv4/netfilter/nf_nat_helper.c +1 -1
@@ -160,7 +160,7 @@ static void nf_nat_csum(struct sk_buff *if (skb->ip_summed !=CHECKSUM_PARTIAL ) {if (!(rt->rt_flags &RTCF_LOCAL ) && - skb->dev->features &NETIF_F_V4_CSUM ) { + (!skb->dev || skb->dev->features &NETIF_F_V4_CSUM )) { skb->ip_summed =CHECKSUM_PARTIAL ; skb->csum_start =skb_headroom (skb) + skb_network_offset(skb) +
Quoted 6 lines · Julian Anastasov
Fix crash in
nf_nat_csumwhen mangling packets
in OUTPUT hook whereskb->devis not defined, it is set later before POSTROUTING. Problem happens forCHECKSUM_NONE. We can check device from rt but usingCHECKSUM_PARTIALshould be safe (skb_checksum_help).
We don't call helpers in LOCAL_OUT, how can this happen?
Quoted 17 lines
Signed-off-by Julian Anastasov <[email protected]>---
diff -urp
v2.6.39/linux/net/ipv4/netfilter/nf_nat_helper.clinux/net/ipv4/netfilter/nf_nat_helper.cnet/ipv4/netfilter/nf_nat_helper.c renamed from linux/net/ipv4/netfilter/nf_nat_helper.c +1
-1@@ -160,7 +160,7 @@ static void nf_nat_csum(struct sk_buff *if (skb->ip_summed !=CHECKSUM_PARTIAL ) {if (!(rt->rt_flags &RTCF_LOCAL ) && - skb->dev->features &NETIF_F_V4_CSUM ) { + (!skb->dev || skb->dev->features &NETIF_F_V4_CSUM )) { skb->ip_summed =CHECKSUM_PARTIAL ; skb->csum_start =skb_headroom (skb) + skb_network_offset(skb) +
Hello,
Quoted 9 lines · Patrick McHardy
Quoted 6 lines · Julian Anastasov
Fix crash in
nf_nat_csumwhen mangling packets
in OUTPUT hook whereskb->devis not defined, it is set later before POSTROUTING. Problem happens forCHECKSUM_NONE. We can check device from rt but usingCHECKSUM_PARTIALshould be safe (skb_checksum_help).We don't call helpers in
LOCAL_OUT, how can this happen?
I think, this happened with IPVS only in OUTPUT hook:tcp_snat_handler -> ip_vs_ftp_out -> nf_nat_mangle_tcp_packet -> nf_nat_csum. This is again PASV FTP via loopback.
Quoted 5 lines
Quoted 5 lines
diff -urp
v2.6.39/linux/net/ipv4/netfilter/nf_nat_helper.clinux/net/ipv4/netfilter/nf_nat_helper.cnet/ipv4/netfilter/nf_nat_helper.c renamed from linux/net/ipv4/netfilter/nf_nat_helper.c +0
-0@@ -160,7 +160,7 @@ static void nf_nat_csum(struct sk_buff *
Quoted 8 lines
net/ipv4/netfilter/nf_nat_helper.c static void nf_nat_csum(struct sk_buff * · line 166
Quoted 8 lines
net/ipv4/netfilter/nf_nat_helper.c renamed from linux/net/ipv4/netfilter/nf_nat_helper.c +1
-1if (skb->ip_summed !=CHECKSUM_PARTIAL ) {if (!(rt->rt_flags &RTCF_LOCAL ) && - skb->dev->features &NETIF_F_V4_CSUM ) { + (!skb->dev || skb->dev->features &NETIF_F_V4_CSUM )) { skb->ip_summed =CHECKSUM_PARTIAL ; skb->csum_start =skb_headroom (skb) + skb_network_offset(skb) +
Regards
--
Julian Anastasov <[email protected]>
Quoted 13 lines · Julian Anastasov
Hello,
Quoted 8 lines · Patrick McHardy
Quoted 6 lines · Julian Anastasov
Fix crash in
nf_nat_csumwhen mangling packets
in OUTPUT hook whereskb->devis not defined, it is set later before POSTROUTING. Problem happens forCHECKSUM_NONE. We can check device from rt but usingCHECKSUM_PARTIALshould be safe (skb_checksum_help).
Quoted 5 lines
Quoted 1 line
We don't call helpers in
LOCAL_OUT, how can this happen?I think, this happened with IPVS only in OUTPUT hook:
tcp_snat_handler->ip_vs_ftp_out->nf_nat_mangle_tcp_packet->nf_nat_csum. This is again PASV FTP via loopback.
I see, thanks. I'll add a comment and will apply this tommorrow.
Quoted 14 lines · Patrick McHardy
Quoted 13 lines · Julian Anastasov
Hello,
Quoted 8 lines · Patrick McHardy
Quoted 6 lines · Julian Anastasov
Fix crash in
nf_nat_csumwhen mangling packets
in OUTPUT hook whereskb->devis not defined, it is set later before POSTROUTING. Problem happens forCHECKSUM_NONE. We can check device from rt but usingCHECKSUM_PARTIALshould be safe (skb_checksum_help).
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
We don't call helpers in
LOCAL_OUT, how can this happen?I think, this happened with IPVS only in OUTPUT hook:
tcp_snat_handler->ip_vs_ftp_out->nf_nat_mangle_tcp_packet->nf_nat_csum. This is again PASV FTP via loopback.I see, thanks. I'll add a comment and will apply this tommorrow.
I must have overlooked the message, just noticed that this patch is already applied,