public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ipvs: Keep skb->sk when allocating headroom on tunnel xmit
@ 2014-11-05  0:37 Calvin Owens
  2014-11-05  9:21 ` Julian Anastasov
  0 siblings, 1 reply; 5+ messages in thread
From: Calvin Owens @ 2014-11-05  0:37 UTC (permalink / raw)
  To: Simon Horman, Julian Anastasov, Wensong Zhang
  Cc: lvs-devel, linux-kernel, netdev, agartrell, kernel-team,
	Calvin Owens

ip_vs_prepare_tunneled_skb() ignores ->sk when allocating a new
skb, either unconditionally setting ->sk to NULL or allowing
the uninitialized ->sk from a newly allocated skb to leak through
to the caller.

This patch properly copies ->sk and increments its reference count.

Signed-off-by: Calvin Owens <calvinowens@fb.com>
---
 net/netfilter/ipvs/ip_vs_xmit.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
index 437a366..bd90bf8 100644
--- a/net/netfilter/ipvs/ip_vs_xmit.c
+++ b/net/netfilter/ipvs/ip_vs_xmit.c
@@ -846,6 +846,8 @@ ip_vs_prepare_tunneled_skb(struct sk_buff *skb, int skb_af,
 		new_skb = skb_realloc_headroom(skb, max_headroom);
 		if (!new_skb)
 			goto error;
+		if (skb->sk)
+			skb_set_owner_w(new_skb, skb->sk);
 		consume_skb(skb);
 		skb = new_skb;
 	}
-- 
2.1.1


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

* Re: [PATCH] ipvs: Keep skb->sk when allocating headroom on tunnel xmit
  2014-11-05  0:37 [PATCH] ipvs: Keep skb->sk when allocating headroom on tunnel xmit Calvin Owens
@ 2014-11-05  9:21 ` Julian Anastasov
  2014-11-07 22:12   ` Calvin Owens
  0 siblings, 1 reply; 5+ messages in thread
From: Julian Anastasov @ 2014-11-05  9:21 UTC (permalink / raw)
  To: Calvin Owens
  Cc: Simon Horman, Wensong Zhang, lvs-devel, linux-kernel, netdev,
	agartrell, kernel-team


	Hello,

On Tue, 4 Nov 2014, Calvin Owens wrote:

> ip_vs_prepare_tunneled_skb() ignores ->sk when allocating a new
> skb, either unconditionally setting ->sk to NULL or allowing
> the uninitialized ->sk from a newly allocated skb to leak through
> to the caller.
> 
> This patch properly copies ->sk and increments its reference count.
> 
> Signed-off-by: Calvin Owens <calvinowens@fb.com>

	Good catch. Please, extend your patch to
fix also the second place that has such error,
ip_vs_tunnel_xmit_v6. This call is missing from long time,
it was not needed. But commits that allow skb->sk (local
clients) already need it, eg.

- f2428ed5e7bc89c7 ("ipvs: load balance ipv6 connections from a local
process"), 2.6.28
- 4856c84c1358b798 ("ipvs: load balance IPv4 connections from a local 
process"), 2.6.28

> ---
>  net/netfilter/ipvs/ip_vs_xmit.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
> index 437a366..bd90bf8 100644
> --- a/net/netfilter/ipvs/ip_vs_xmit.c
> +++ b/net/netfilter/ipvs/ip_vs_xmit.c
> @@ -846,6 +846,8 @@ ip_vs_prepare_tunneled_skb(struct sk_buff *skb, int skb_af,
>  		new_skb = skb_realloc_headroom(skb, max_headroom);
>  		if (!new_skb)
>  			goto error;
> +		if (skb->sk)
> +			skb_set_owner_w(new_skb, skb->sk);
>  		consume_skb(skb);
>  		skb = new_skb;
>  	}

Regards

--
Julian Anastasov <ja@ssi.bg>

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

* Re: [PATCH] ipvs: Keep skb->sk when allocating headroom on tunnel xmit
  2014-11-05  9:21 ` Julian Anastasov
@ 2014-11-07 22:12   ` Calvin Owens
  2014-11-08  6:16     ` Julian Anastasov
  0 siblings, 1 reply; 5+ messages in thread
From: Calvin Owens @ 2014-11-07 22:12 UTC (permalink / raw)
  To: Julian Anastasov
  Cc: Simon Horman, Wensong Zhang, lvs-devel, linux-kernel, netdev,
	agartrell, kernel-team

On 11/05/2014 01:21 AM, Julian Anastasov wrote:
>
> 	Hello,
>
> On Tue, 4 Nov 2014, Calvin Owens wrote:
>
>> ip_vs_prepare_tunneled_skb() ignores ->sk when allocating a new
>> skb, either unconditionally setting ->sk to NULL or allowing
>> the uninitialized ->sk from a newly allocated skb to leak through
>> to the caller.
>>
>> This patch properly copies ->sk and increments its reference count.
>>
>> Signed-off-by: Calvin Owens <calvinowens@fb.com>
>
> 	Good catch. Please, extend your patch to
> fix also the second place that has such error,
> ip_vs_tunnel_xmit_v6. This call is missing from long time,
> it was not needed. But commits that allow skb->sk (local
> clients) already need it, eg.

I'm not sure where exactly you mean: ip_vs_tunnel_xmit_v6() calls
ip_vs_prepare_tunneled_skb() to do the allocation, so this patch covers 
that case.

In older versions of the kernel, ip_vs_tunnel_xmit_v6() does it 
directly, could that be what you're looking at?

> - f2428ed5e7bc89c7 ("ipvs: load balance ipv6 connections from a local
> process"), 2.6.28
> - 4856c84c1358b798 ("ipvs: load balance IPv4 connections from a local
> process"), 2.6.28
>
>> ---
>>   net/netfilter/ipvs/ip_vs_xmit.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
>> index 437a366..bd90bf8 100644
>> --- a/net/netfilter/ipvs/ip_vs_xmit.c
>> +++ b/net/netfilter/ipvs/ip_vs_xmit.c
>> @@ -846,6 +846,8 @@ ip_vs_prepare_tunneled_skb(struct sk_buff *skb, int skb_af,
>>   		new_skb = skb_realloc_headroom(skb, max_headroom);
>>   		if (!new_skb)
>>   			goto error;
>> +		if (skb->sk)
>> +			skb_set_owner_w(new_skb, skb->sk);
>>   		consume_skb(skb);
>>   		skb = new_skb;
>>   	}
>
> Regards
>
> --
> Julian Anastasov <ja@ssi.bg>
>

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

* Re: [PATCH] ipvs: Keep skb->sk when allocating headroom on tunnel xmit
  2014-11-07 22:12   ` Calvin Owens
@ 2014-11-08  6:16     ` Julian Anastasov
  2014-11-12  2:22       ` Simon Horman
  0 siblings, 1 reply; 5+ messages in thread
From: Julian Anastasov @ 2014-11-08  6:16 UTC (permalink / raw)
  To: Calvin Owens
  Cc: Simon Horman, Wensong Zhang, lvs-devel, linux-kernel, netdev,
	agartrell, kernel-team


	Hello,

On Fri, 7 Nov 2014, Calvin Owens wrote:

> On 11/05/2014 01:21 AM, Julian Anastasov wrote:
> >
> >  Hello,
> >
> > On Tue, 4 Nov 2014, Calvin Owens wrote:
> >
> > > ip_vs_prepare_tunneled_skb() ignores ->sk when allocating a new
> > > skb, either unconditionally setting ->sk to NULL or allowing
> > > the uninitialized ->sk from a newly allocated skb to leak through
> > > to the caller.
> > >
> > > This patch properly copies ->sk and increments its reference count.
> > >
> > > Signed-off-by: Calvin Owens <calvinowens@fb.com>
> >
> > 	Good catch. Please, extend your patch to
> > fix also the second place that has such error,
> > ip_vs_tunnel_xmit_v6. This call is missing from long time,
> > it was not needed. But commits that allow skb->sk (local
> > clients) already need it, eg.
> 
> I'm not sure where exactly you mean: ip_vs_tunnel_xmit_v6() calls
> ip_vs_prepare_tunneled_skb() to do the allocation, so this patch covers that
> case.
> 
> In older versions of the kernel, ip_vs_tunnel_xmit_v6() does it directly,
> could that be what you're looking at?

	Sorry, it seems I was checking old branch.

	Simon, please apply.

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

> > - f2428ed5e7bc89c7 ("ipvs: load balance ipv6 connections from a local
> > process"), 2.6.28
> > - 4856c84c1358b798 ("ipvs: load balance IPv4 connections from a local
> > process"), 2.6.28
> >
> > > ---
> > >   net/netfilter/ipvs/ip_vs_xmit.c | 2 ++
> > >   1 file changed, 2 insertions(+)
> > >
> > > diff --git a/net/netfilter/ipvs/ip_vs_xmit.c
> > > b/net/netfilter/ipvs/ip_vs_xmit.c
> > > index 437a366..bd90bf8 100644
> > > --- a/net/netfilter/ipvs/ip_vs_xmit.c
> > > +++ b/net/netfilter/ipvs/ip_vs_xmit.c
> > > @@ -846,6 +846,8 @@ ip_vs_prepare_tunneled_skb(struct sk_buff *skb, int
> > > skb_af,
> > >     new_skb = skb_realloc_headroom(skb, max_headroom);
> > >     if (!new_skb)
> > >   			goto error;
> > > +		if (skb->sk)
> > > +			skb_set_owner_w(new_skb, skb->sk);
> > >     consume_skb(skb);
> > >     skb = new_skb;
> > >    }

Regards

--
Julian Anastasov <ja@ssi.bg>

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

* Re: [PATCH] ipvs: Keep skb->sk when allocating headroom on tunnel xmit
  2014-11-08  6:16     ` Julian Anastasov
@ 2014-11-12  2:22       ` Simon Horman
  0 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2014-11-12  2:22 UTC (permalink / raw)
  To: Julian Anastasov
  Cc: Calvin Owens, Wensong Zhang, lvs-devel, linux-kernel, netdev,
	agartrell, kernel-team

On Sat, Nov 08, 2014 at 08:16:58AM +0200, Julian Anastasov wrote:
> 
> 	Hello,
> 
> On Fri, 7 Nov 2014, Calvin Owens wrote:
> 
> > On 11/05/2014 01:21 AM, Julian Anastasov wrote:
> > >
> > >  Hello,
> > >
> > > On Tue, 4 Nov 2014, Calvin Owens wrote:
> > >
> > > > ip_vs_prepare_tunneled_skb() ignores ->sk when allocating a new
> > > > skb, either unconditionally setting ->sk to NULL or allowing
> > > > the uninitialized ->sk from a newly allocated skb to leak through
> > > > to the caller.
> > > >
> > > > This patch properly copies ->sk and increments its reference count.
> > > >
> > > > Signed-off-by: Calvin Owens <calvinowens@fb.com>
> > >
> > > 	Good catch. Please, extend your patch to
> > > fix also the second place that has such error,
> > > ip_vs_tunnel_xmit_v6. This call is missing from long time,
> > > it was not needed. But commits that allow skb->sk (local
> > > clients) already need it, eg.
> > 
> > I'm not sure where exactly you mean: ip_vs_tunnel_xmit_v6() calls
> > ip_vs_prepare_tunneled_skb() to do the allocation, so this patch covers that
> > case.
> > 
> > In older versions of the kernel, ip_vs_tunnel_xmit_v6() does it directly,
> > could that be what you're looking at?
> 
> 	Sorry, it seems I was checking old branch.
> 
> 	Simon, please apply.
> 
> Acked-by: Julian Anastasov <ja@ssi.bg>

Thanks, done.

> > > - f2428ed5e7bc89c7 ("ipvs: load balance ipv6 connections from a local
> > > process"), 2.6.28
> > > - 4856c84c1358b798 ("ipvs: load balance IPv4 connections from a local
> > > process"), 2.6.28
> > >
> > > > ---
> > > >   net/netfilter/ipvs/ip_vs_xmit.c | 2 ++
> > > >   1 file changed, 2 insertions(+)
> > > >
> > > > diff --git a/net/netfilter/ipvs/ip_vs_xmit.c
> > > > b/net/netfilter/ipvs/ip_vs_xmit.c
> > > > index 437a366..bd90bf8 100644
> > > > --- a/net/netfilter/ipvs/ip_vs_xmit.c
> > > > +++ b/net/netfilter/ipvs/ip_vs_xmit.c
> > > > @@ -846,6 +846,8 @@ ip_vs_prepare_tunneled_skb(struct sk_buff *skb, int
> > > > skb_af,
> > > >     new_skb = skb_realloc_headroom(skb, max_headroom);
> > > >     if (!new_skb)
> > > >   			goto error;
> > > > +		if (skb->sk)
> > > > +			skb_set_owner_w(new_skb, skb->sk);
> > > >     consume_skb(skb);
> > > >     skb = new_skb;
> > > >    }
> 
> Regards
> 
> --
> Julian Anastasov <ja@ssi.bg>
> 

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

end of thread, other threads:[~2014-11-12  2:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-05  0:37 [PATCH] ipvs: Keep skb->sk when allocating headroom on tunnel xmit Calvin Owens
2014-11-05  9:21 ` Julian Anastasov
2014-11-07 22:12   ` Calvin Owens
2014-11-08  6:16     ` Julian Anastasov
2014-11-12  2:22       ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox