mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Stringer <joestringer@nicira.com>
To: netdev@vger.kernel.org, pshelar@nicira.com
Cc: linux-kernel@vger.kernel.org, jesse@nicira.com
Subject: [PATCHv2 3/7] openvswitch: Fix skb leak in ovs_fragment()
Date: Thu,  1 Oct 2015 13:53:26 -0700	[thread overview]
Message-ID: <1443732810-38746-4-git-send-email-joestringer@nicira.com> (raw)
In-Reply-To: <1443732810-38746-1-git-send-email-joestringer@nicira.com>

If ovs_fragment() was unable to fragment the skb due to an L2 header
that exceeds the supported length, skbs would be leaked. Fix the bug.

Fixes: 7f8a436 "openvswitch: Add conntrack action"
Signed-off-by: Joe Stringer <joestringer@nicira.com>
---
v2: Drop if condition, return in success case.
---
 net/openvswitch/actions.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index e23a61c..4cb93f9 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -684,7 +684,7 @@ static void ovs_fragment(struct vport *vport, struct sk_buff *skb, u16 mru,
 {
 	if (skb_network_offset(skb) > MAX_L2_LEN) {
 		OVS_NLERR(1, "L2 header too long to fragment");
-		return;
+		goto err;
 	}
 
 	if (ethertype == htons(ETH_P_IP)) {
@@ -708,8 +708,7 @@ static void ovs_fragment(struct vport *vport, struct sk_buff *skb, u16 mru,
 		struct rt6_info ovs_rt;
 
 		if (!v6ops) {
-			kfree_skb(skb);
-			return;
+			goto err;
 		}
 
 		prepare_frag(vport, skb);
@@ -728,8 +727,12 @@ static void ovs_fragment(struct vport *vport, struct sk_buff *skb, u16 mru,
 		WARN_ONCE(1, "Failed fragment ->%s: eth=%04x, MRU=%d, MTU=%d.",
 			  ovs_vport_name(vport), ntohs(ethertype), mru,
 			  vport->dev->mtu);
-		kfree_skb(skb);
+		goto err;
 	}
+
+	return;
+err:
+	kfree_skb(skb);
 }
 
 static void do_output(struct datapath *dp, struct sk_buff *skb, int out_port,
-- 
2.1.4


  parent reply	other threads:[~2015-10-01 20:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-01 20:53 [PATCHv2 0/7] OVS conntrack fixes for net Joe Stringer
2015-10-01 20:53 ` [PATCHv2 1/7] openvswitch: Rename LABEL->LABELS Joe Stringer
2015-10-01 21:13   ` kbuild test robot
2015-10-01 22:00     ` [PATCHv3] " Joe Stringer
2015-10-01 22:23       ` Pravin Shelar
2015-10-05 13:34       ` David Miller
2015-10-01 20:53 ` [PATCHv2 2/7] openvswitch: Fix typos in CT headers Joe Stringer
2015-10-01 20:53 ` Joe Stringer [this message]
2015-10-01 22:25   ` [PATCHv2 3/7] openvswitch: Fix skb leak in ovs_fragment() Pravin Shelar
2015-10-01 20:53 ` [PATCHv2 4/7] openvswitch: Ensure flow is valid before executing ct Joe Stringer
2015-10-01 20:53 ` [PATCHv2 5/7] openvswitch: Reject ct_state unsupported bits Joe Stringer
2015-10-01 20:53 ` [PATCHv2 6/7] openvswitch: Extend ct_state match field to 32 bits Joe Stringer
2015-10-01 20:53 ` [PATCHv2 7/7] openvswitch: Change CT_ATTR_FLAGS to CT_ATTR_COMMIT Joe Stringer
2015-10-01 22:26   ` Pravin Shelar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1443732810-38746-4-git-send-email-joestringer@nicira.com \
    --to=joestringer@nicira.com \
    --cc=jesse@nicira.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pshelar@nicira.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®