netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] netfilter: nf_nat: fix crash in nf_nat_csum
@ 2011-05-29 20:42 Julian Anastasov
  2011-06-07 13:07 ` Patrick McHardy
  0 siblings, 1 reply; 5+ messages in thread
From: Julian Anastasov @ 2011-05-29 20:42 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: netfilter-devel


	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).

Signed-off-by: Julian Anastasov <ja@ssi.bg>
---

diff -urp v2.6.39/linux/net/ipv4/netfilter/nf_nat_helper.c linux/net/ipv4/netfilter/nf_nat_helper.c
--- v2.6.39/linux/net/ipv4/netfilter/nf_nat_helper.c	2011-01-06 00:01:22.000000000 +0200
+++ linux/net/ipv4/netfilter/nf_nat_helper.c	2011-05-29 23:14:40.166245897 +0300
@@ -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) +

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

* Re: [PATCH] netfilter: nf_nat: fix crash in nf_nat_csum
  2011-05-29 20:42 [PATCH] netfilter: nf_nat: fix crash in nf_nat_csum Julian Anastasov
@ 2011-06-07 13:07 ` Patrick McHardy
  2011-06-07 20:02   ` Julian Anastasov
  0 siblings, 1 reply; 5+ messages in thread
From: Patrick McHardy @ 2011-06-07 13:07 UTC (permalink / raw)
  To: Julian Anastasov; +Cc: netfilter-devel

On 29.05.2011 22:42, Julian Anastasov wrote:
> 
> 	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).

We don't call helpers in LOCAL_OUT, how can this happen?

> 
> Signed-off-by: Julian Anastasov <ja@ssi.bg>
> ---
> 
> diff -urp v2.6.39/linux/net/ipv4/netfilter/nf_nat_helper.c linux/net/ipv4/netfilter/nf_nat_helper.c
> --- v2.6.39/linux/net/ipv4/netfilter/nf_nat_helper.c	2011-01-06 00:01:22.000000000 +0200
> +++ linux/net/ipv4/netfilter/nf_nat_helper.c	2011-05-29 23:14:40.166245897 +0300
> @@ -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) +
> 


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

* Re: [PATCH] netfilter: nf_nat: fix crash in nf_nat_csum
  2011-06-07 13:07 ` Patrick McHardy
@ 2011-06-07 20:02   ` Julian Anastasov
  2011-06-07 23:01     ` Patrick McHardy
  0 siblings, 1 reply; 5+ messages in thread
From: Julian Anastasov @ 2011-06-07 20:02 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: netfilter-devel


	Hello,

On Tue, 7 Jun 2011, Patrick McHardy wrote:

> On 29.05.2011 22:42, Julian Anastasov wrote:
> > 
> > 	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).
> 
> 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.

> > diff -urp v2.6.39/linux/net/ipv4/netfilter/nf_nat_helper.c linux/net/ipv4/netfilter/nf_nat_helper.c
> > --- v2.6.39/linux/net/ipv4/netfilter/nf_nat_helper.c	2011-01-06 00:01:22.000000000 +0200
> > +++ linux/net/ipv4/netfilter/nf_nat_helper.c	2011-05-29 23:14:40.166245897 +0300
> > @@ -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) +
> > 

Regards

--
Julian Anastasov <ja@ssi.bg>

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

* Re: [PATCH] netfilter: nf_nat: fix crash in nf_nat_csum
  2011-06-07 20:02   ` Julian Anastasov
@ 2011-06-07 23:01     ` Patrick McHardy
  2011-06-08  9:36       ` Patrick McHardy
  0 siblings, 1 reply; 5+ messages in thread
From: Patrick McHardy @ 2011-06-07 23:01 UTC (permalink / raw)
  To: Julian Anastasov; +Cc: netfilter-devel

On 07.06.2011 22:02, Julian Anastasov wrote:
> 
> 	Hello,
> 
> On Tue, 7 Jun 2011, Patrick McHardy wrote:
> 
>> On 29.05.2011 22:42, Julian Anastasov wrote:
>>>
>>> 	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).
>>
>> 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.

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

* Re: [PATCH] netfilter: nf_nat: fix crash in nf_nat_csum
  2011-06-07 23:01     ` Patrick McHardy
@ 2011-06-08  9:36       ` Patrick McHardy
  0 siblings, 0 replies; 5+ messages in thread
From: Patrick McHardy @ 2011-06-08  9:36 UTC (permalink / raw)
  To: Julian Anastasov; +Cc: netfilter-devel

On 08.06.2011 01:01, Patrick McHardy wrote:
> On 07.06.2011 22:02, Julian Anastasov wrote:
>>
>> 	Hello,
>>
>> On Tue, 7 Jun 2011, Patrick McHardy wrote:
>>
>>> On 29.05.2011 22:42, Julian Anastasov wrote:
>>>>
>>>> 	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).
>>>
>>> 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,

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

end of thread, other threads:[~2011-06-08  9:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-29 20:42 [PATCH] netfilter: nf_nat: fix crash in nf_nat_csum Julian Anastasov
2011-06-07 13:07 ` Patrick McHardy
2011-06-07 20:02   ` Julian Anastasov
2011-06-07 23:01     ` Patrick McHardy
2011-06-08  9:36       ` Patrick McHardy

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).