* [PATCH net] openvswitch: Fix skb leak in IPv6 reassembly.
@ 2016-11-28 23:43 Daniele Di Proietto
2016-11-29 0:22 ` Eric Dumazet
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Daniele Di Proietto @ 2016-11-28 23:43 UTC (permalink / raw)
To: netdev
Cc: Daniele Di Proietto, Florian Westphal, Pravin B Shelar, Joe Stringer
If nf_ct_frag6_gather() returns an error other than -EINPROGRESS, it
means that we still have a reference to the skb. We should free it
before returning from handle_fragments, as stated in the comment above.
Fixes: daaa7d647f81 ("netfilter: ipv6: avoid nf_iterate recursion")
CC: Florian Westphal <fw@strlen.de>
CC: Pravin B Shelar <pshelar@ovn.org>
CC: Joe Stringer <joe@ovn.org>
Signed-off-by: Daniele Di Proietto <diproiettod@ovn.org>
---
net/openvswitch/conntrack.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index 31045ef..fecefa2 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -370,8 +370,11 @@ static int handle_fragments(struct net *net, struct sw_flow_key *key,
skb_orphan(skb);
memset(IP6CB(skb), 0, sizeof(struct inet6_skb_parm));
err = nf_ct_frag6_gather(net, skb, user);
- if (err)
+ if (err) {
+ if (err != -EINPROGRESS)
+ kfree_skb(skb);
return err;
+ }
key->ip.proto = ipv6_hdr(skb)->nexthdr;
ovs_cb.mru = IP6CB(skb)->frag_max_size;
--
2.10.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net] openvswitch: Fix skb leak in IPv6 reassembly.
2016-11-28 23:43 [PATCH net] openvswitch: Fix skb leak in IPv6 reassembly Daniele Di Proietto
@ 2016-11-29 0:22 ` Eric Dumazet
2016-11-29 0:45 ` Florian Westphal
2016-11-29 7:39 ` Pravin Shelar
2016-11-30 16:02 ` David Miller
2 siblings, 1 reply; 7+ messages in thread
From: Eric Dumazet @ 2016-11-29 0:22 UTC (permalink / raw)
To: Daniele Di Proietto
Cc: netdev, Florian Westphal, Pravin B Shelar, Joe Stringer
On Mon, 2016-11-28 at 15:43 -0800, Daniele Di Proietto wrote:
> If nf_ct_frag6_gather() returns an error other than -EINPROGRESS, it
> means that we still have a reference to the skb. We should free it
> before returning from handle_fragments, as stated in the comment above.
>
> Fixes: daaa7d647f81 ("netfilter: ipv6: avoid nf_iterate recursion")
> CC: Florian Westphal <fw@strlen.de>
> CC: Pravin B Shelar <pshelar@ovn.org>
> CC: Joe Stringer <joe@ovn.org>
> Signed-off-by: Daniele Di Proietto <diproiettod@ovn.org>
> ---
> net/openvswitch/conntrack.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
> index 31045ef..fecefa2 100644
> --- a/net/openvswitch/conntrack.c
> +++ b/net/openvswitch/conntrack.c
> @@ -370,8 +370,11 @@ static int handle_fragments(struct net *net, struct sw_flow_key *key,
> skb_orphan(skb);
> memset(IP6CB(skb), 0, sizeof(struct inet6_skb_parm));
> err = nf_ct_frag6_gather(net, skb, user);
> - if (err)
> + if (err) {
> + if (err != -EINPROGRESS)
> + kfree_skb(skb);
> return err;
> + }
>
> key->ip.proto = ipv6_hdr(skb)->nexthdr;
> ovs_cb.mru = IP6CB(skb)->frag_max_size;
Interesting, have you followed the "GPF in eth_header" thread today ?
In a nutshell, we want a complete patch, not something that would solve
part of the problem.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] openvswitch: Fix skb leak in IPv6 reassembly.
2016-11-29 0:22 ` Eric Dumazet
@ 2016-11-29 0:45 ` Florian Westphal
2016-11-29 1:16 ` Joe Stringer
0 siblings, 1 reply; 7+ messages in thread
From: Florian Westphal @ 2016-11-29 0:45 UTC (permalink / raw)
To: Eric Dumazet
Cc: Daniele Di Proietto, netdev, Florian Westphal, Pravin B Shelar,
Joe Stringer
Eric Dumazet <eric.dumazet@gmail.com> wrote:
> On Mon, 2016-11-28 at 15:43 -0800, Daniele Di Proietto wrote:
> > If nf_ct_frag6_gather() returns an error other than -EINPROGRESS, it
> > means that we still have a reference to the skb. We should free it
> > before returning from handle_fragments, as stated in the comment above.
> >
> > Fixes: daaa7d647f81 ("netfilter: ipv6: avoid nf_iterate recursion")
> > CC: Florian Westphal <fw@strlen.de>
> > CC: Pravin B Shelar <pshelar@ovn.org>
> > CC: Joe Stringer <joe@ovn.org>
> > Signed-off-by: Daniele Di Proietto <diproiettod@ovn.org>
> > ---
> > net/openvswitch/conntrack.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
> > index 31045ef..fecefa2 100644
> > --- a/net/openvswitch/conntrack.c
> > +++ b/net/openvswitch/conntrack.c
> > @@ -370,8 +370,11 @@ static int handle_fragments(struct net *net, struct sw_flow_key *key,
> > skb_orphan(skb);
> > memset(IP6CB(skb), 0, sizeof(struct inet6_skb_parm));
> > err = nf_ct_frag6_gather(net, skb, user);
> > - if (err)
> > + if (err) {
> > + if (err != -EINPROGRESS)
> > + kfree_skb(skb);
> > return err;
> > + }
> >
> > key->ip.proto = ipv6_hdr(skb)->nexthdr;
> > ovs_cb.mru = IP6CB(skb)->frag_max_size;
>
> Interesting, have you followed the "GPF in eth_header" thread today ?
>
> In a nutshell, we want a complete patch, not something that would solve
> part of the problem.
I think this patch is fine, intent seems to be to only take fully reassembled
skb, rather than a stray fragment (ovs does NOT seem to call handle_fragments
in case skb is already known to not contain a fragment header, afaics).
I'll send a patch for the GPF in eth_header thing soon.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] openvswitch: Fix skb leak in IPv6 reassembly.
2016-11-29 0:45 ` Florian Westphal
@ 2016-11-29 1:16 ` Joe Stringer
0 siblings, 0 replies; 7+ messages in thread
From: Joe Stringer @ 2016-11-29 1:16 UTC (permalink / raw)
To: Florian Westphal
Cc: Eric Dumazet, Daniele Di Proietto, netdev, Pravin B Shelar
On 28 November 2016 at 16:45, Florian Westphal <fw@strlen.de> wrote:
> Eric Dumazet <eric.dumazet@gmail.com> wrote:
>> On Mon, 2016-11-28 at 15:43 -0800, Daniele Di Proietto wrote:
>> > If nf_ct_frag6_gather() returns an error other than -EINPROGRESS, it
>> > means that we still have a reference to the skb. We should free it
>> > before returning from handle_fragments, as stated in the comment above.
>> >
>> > Fixes: daaa7d647f81 ("netfilter: ipv6: avoid nf_iterate recursion")
>> > CC: Florian Westphal <fw@strlen.de>
>> > CC: Pravin B Shelar <pshelar@ovn.org>
>> > CC: Joe Stringer <joe@ovn.org>
>> > Signed-off-by: Daniele Di Proietto <diproiettod@ovn.org>
>> > ---
>> > net/openvswitch/conntrack.c | 5 ++++-
>> > 1 file changed, 4 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
>> > index 31045ef..fecefa2 100644
>> > --- a/net/openvswitch/conntrack.c
>> > +++ b/net/openvswitch/conntrack.c
>> > @@ -370,8 +370,11 @@ static int handle_fragments(struct net *net, struct sw_flow_key *key,
>> > skb_orphan(skb);
>> > memset(IP6CB(skb), 0, sizeof(struct inet6_skb_parm));
>> > err = nf_ct_frag6_gather(net, skb, user);
>> > - if (err)
>> > + if (err) {
>> > + if (err != -EINPROGRESS)
>> > + kfree_skb(skb);
>> > return err;
>> > + }
>> >
>> > key->ip.proto = ipv6_hdr(skb)->nexthdr;
>> > ovs_cb.mru = IP6CB(skb)->frag_max_size;
>>
>> Interesting, have you followed the "GPF in eth_header" thread today ?
>>
>> In a nutshell, we want a complete patch, not something that would solve
>> part of the problem.
>
> I think this patch is fine, intent seems to be to only take fully reassembled
> skb, rather than a stray fragment (ovs does NOT seem to call handle_fragments
> in case skb is already known to not contain a fragment header, afaics).
Correct, this is used in OVS only for fragmented packets and this
function either morphs the skb into the full skb fragment chain, or
steals/frees the skb.
> I'll send a patch for the GPF in eth_header thing soon.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] openvswitch: Fix skb leak in IPv6 reassembly.
2016-11-28 23:43 [PATCH net] openvswitch: Fix skb leak in IPv6 reassembly Daniele Di Proietto
2016-11-29 0:22 ` Eric Dumazet
@ 2016-11-29 7:39 ` Pravin Shelar
[not found] ` <CAExiqTKTbgOaXLjHMuvne__9hyNLT5kN72fOrEg2CF3VgFg3Cw@mail.gmail.com>
2016-11-30 16:02 ` David Miller
2 siblings, 1 reply; 7+ messages in thread
From: Pravin Shelar @ 2016-11-29 7:39 UTC (permalink / raw)
To: Daniele Di Proietto
Cc: Linux Kernel Network Developers, Florian Westphal, Joe Stringer
On Mon, Nov 28, 2016 at 3:43 PM, Daniele Di Proietto
<diproiettod@ovn.org> wrote:
> If nf_ct_frag6_gather() returns an error other than -EINPROGRESS, it
> means that we still have a reference to the skb. We should free it
> before returning from handle_fragments, as stated in the comment above.
>
> Fixes: daaa7d647f81 ("netfilter: ipv6: avoid nf_iterate recursion")
> CC: Florian Westphal <fw@strlen.de>
> CC: Pravin B Shelar <pshelar@ovn.org>
> CC: Joe Stringer <joe@ovn.org>
> Signed-off-by: Daniele Di Proietto <diproiettod@ovn.org>
> ---
> net/openvswitch/conntrack.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
> index 31045ef..fecefa2 100644
> --- a/net/openvswitch/conntrack.c
> +++ b/net/openvswitch/conntrack.c
> @@ -370,8 +370,11 @@ static int handle_fragments(struct net *net, struct sw_flow_key *key,
> skb_orphan(skb);
> memset(IP6CB(skb), 0, sizeof(struct inet6_skb_parm));
> err = nf_ct_frag6_gather(net, skb, user);
> - if (err)
> + if (err) {
> + if (err != -EINPROGRESS)
> + kfree_skb(skb);
> return err;
> + }
>
This fixes the code. But the patch is adding yet another skb-kfree in
conntrack code. we could simplify it by reusing error handling in
do_execute_actions().
If you think that is too complicated for stable branch, I am fine with
this patch going in as it is.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] openvswitch: Fix skb leak in IPv6 reassembly.
[not found] ` <CAExiqTKTbgOaXLjHMuvne__9hyNLT5kN72fOrEg2CF3VgFg3Cw@mail.gmail.com>
@ 2016-11-29 17:21 ` Pravin Shelar
0 siblings, 0 replies; 7+ messages in thread
From: Pravin Shelar @ 2016-11-29 17:21 UTC (permalink / raw)
To: Daniele Di Proietto
Cc: Linux Kernel Network Developers, Florian Westphal, Joe Stringer
On Tue, Nov 29, 2016 at 12:54 AM, Daniele Di Proietto
<diproiettod@ovn.org> wrote:
>
>
> 2016-11-28 23:39 GMT-08:00 Pravin Shelar <pshelar@ovn.org>:
>>
>> On Mon, Nov 28, 2016 at 3:43 PM, Daniele Di Proietto
>> <diproiettod@ovn.org> wrote:
>> > If nf_ct_frag6_gather() returns an error other than -EINPROGRESS, it
>> > means that we still have a reference to the skb. We should free it
>> > before returning from handle_fragments, as stated in the comment above.
>> >
>> > Fixes: daaa7d647f81 ("netfilter: ipv6: avoid nf_iterate recursion")
>> > CC: Florian Westphal <fw@strlen.de>
>> > CC: Pravin B Shelar <pshelar@ovn.org>
>> > CC: Joe Stringer <joe@ovn.org>
>> > Signed-off-by: Daniele Di Proietto <diproiettod@ovn.org>
>> > ---
>> > net/openvswitch/conntrack.c | 5 ++++-
>> > 1 file changed, 4 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
>> > index 31045ef..fecefa2 100644
>> > --- a/net/openvswitch/conntrack.c
>> > +++ b/net/openvswitch/conntrack.c
>> > @@ -370,8 +370,11 @@ static int handle_fragments(struct net *net, struct
>> > sw_flow_key *key,
>> > skb_orphan(skb);
>> > memset(IP6CB(skb), 0, sizeof(struct inet6_skb_parm));
>> > err = nf_ct_frag6_gather(net, skb, user);
>> > - if (err)
>> > + if (err) {
>> > + if (err != -EINPROGRESS)
>> > + kfree_skb(skb);
>> > return err;
>> > + }
>> >
>>
>> This fixes the code. But the patch is adding yet another skb-kfree in
>> conntrack code. we could simplify it by reusing error handling in
>> do_execute_actions().
>> If you think that is too complicated for stable branch, I am fine with
>> this patch going in as it is.
>
>
> I thought it was simpler to handle this here rather than changing the
> interface of
> handle_fragments() and ovs_ct_execute(). Also this is more similar to the v4
> case,
> where ip_defrag() frees the skb in case of error.
>
> What do you think?
I agree this is simple enough for stable branch. I will check if ct
action error handling could be simplified bit.
Acked-by: Pravin B Shelar <pshelar@ovn.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] openvswitch: Fix skb leak in IPv6 reassembly.
2016-11-28 23:43 [PATCH net] openvswitch: Fix skb leak in IPv6 reassembly Daniele Di Proietto
2016-11-29 0:22 ` Eric Dumazet
2016-11-29 7:39 ` Pravin Shelar
@ 2016-11-30 16:02 ` David Miller
2 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2016-11-30 16:02 UTC (permalink / raw)
To: diproiettod; +Cc: netdev, fw, pshelar, joe
From: Daniele Di Proietto <diproiettod@ovn.org>
Date: Mon, 28 Nov 2016 15:43:53 -0800
> If nf_ct_frag6_gather() returns an error other than -EINPROGRESS, it
> means that we still have a reference to the skb. We should free it
> before returning from handle_fragments, as stated in the comment above.
>
> Fixes: daaa7d647f81 ("netfilter: ipv6: avoid nf_iterate recursion")
> CC: Florian Westphal <fw@strlen.de>
> CC: Pravin B Shelar <pshelar@ovn.org>
> CC: Joe Stringer <joe@ovn.org>
> Signed-off-by: Daniele Di Proietto <diproiettod@ovn.org>
Applied, thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-11-30 16:02 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-28 23:43 [PATCH net] openvswitch: Fix skb leak in IPv6 reassembly Daniele Di Proietto
2016-11-29 0:22 ` Eric Dumazet
2016-11-29 0:45 ` Florian Westphal
2016-11-29 1:16 ` Joe Stringer
2016-11-29 7:39 ` Pravin Shelar
[not found] ` <CAExiqTKTbgOaXLjHMuvne__9hyNLT5kN72fOrEg2CF3VgFg3Cw@mail.gmail.com>
2016-11-29 17:21 ` Pravin Shelar
2016-11-30 16:02 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.