Skip to contentSkip to conversation

FAILED: patch "[PATCH] net: openvswitch: fix skb leak on flow key update failure" failed to apply to 5.10-stable tree

PATCH Applied [email protected] 3 participants 3 messages Aug 5 – Aug 6

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x e1cf066244dad576221b7123a0e5005967f25a20
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026080538-gutless-facebook-638b@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From e1cf066244dad576221b7123a0e5005967f25a20 Mon Sep 17 00:00:00 2001
From: Ilya Maximets <[email protected]>
Date: Mon, 27 Jul 2026 20:18:30 +0200
Subject: [PATCH] net: openvswitch: fix skb leak on flow key update failure
during recirculation

do_execute_actions() returns right away when execute_recirc() fails on the last action as it assumes this function always takes ownership of the skb when 'last' is true. But when the flow key update fails, the function doesn't free the skb and it ends up leaked.

This is a very unlikely scenario as it requires the packet to become unparseable by applying a set of actions on a previously parseable skb, but should be fixed nevertheless.

Reported by Sashiko.

net/openvswitch/actions.c +9 -1
index 513fca6a8e8a..0118fe3b35e4 100644
@@ -1108,6 +1108,10 @@ static int execute_masked_set_action(struct sk_buff *skb,
 	return err;
 }
 
+/* When 'last' is true, recirc() should always consume the 'skb'.
+ * Otherwise, recirc() should keep 'skb' intact regardless what
+ * actions are executed on recirculation.
+ */
 static int execute_recirc(struct datapath *dp, struct sk_buff *skb,
 			  struct sw_flow_key *key,
 			  const struct nlattr *a, bool last)
@@ -1118,8 +1122,12 @@ static int execute_recirc(struct datapath *dp, struct sk_buff *skb,
 		int err;
 
 		err = ovs_flow_key_update(skb, key);
-		if (err)
+		if (err) {
+			if (last)
+				ovs_kfree_skb_reason(skb,
+						     OVS_DROP_ACTION_ERROR);
 			return err;
+		}
 	}
 	BUG_ON(!is_flow_key_valid(key));
 
maintainer
#1 lore raw

PATCH 1/1 net: openvswitch: fix skb leak on flow key update failure during recirculation

[ Upstream commit e1cf066244dad576221b7123a0e5005967f25a20 ]

do_execute_actions() returns right away when execute_recirc() fails on the last action as it assumes this function always takes ownership of the skb when 'last' is true. But when the flow key update fails, the function doesn't free the skb and it ends up leaked.

This is a very unlikely scenario as it requires the packet to become unparseable by applying a set of actions on a previously parseable skb, but should be fixed nevertheless.

Reported by Sashiko.

Fixes 971427f353f3 ("openvswitch: Add recirc and hash action.")
[OVS drop reasons are not available in 5.10, hence plain kfree_skb()]
---
 net/openvswitch/actions.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
net/openvswitch/actions.c +8 -1
index 3b3cc6ea274f..5f9994839bed 100644
@@ -1104,6 +1104,10 @@ static int execute_masked_set_action(struct sk_buff *skb,
 	return err;
 }
 
+/* When 'last' is true, recirc() should always consume the 'skb'.
+ * Otherwise, recirc() should keep 'skb' intact regardless what
+ * actions are executed on recirculation.
+ */
 static int execute_recirc(struct datapath *dp, struct sk_buff *skb,
 			  struct sw_flow_key *key,
 			  const struct nlattr *a, bool last)
@@ -1114,8 +1118,11 @@ static int execute_recirc(struct datapath *dp, struct sk_buff *skb,
 		int err;
 
 		err = ovs_flow_key_update(skb, key);
-		if (err)
+		if (err) {
+			if (last)
+				kfree_skb(skb);
 			return err;
+		}
 	}
 	BUG_ON(!is_flow_key_valid(key));
 
Signature · 1 line
2.55.0
maintainer Applied
#2 lore raw

Re: [PATCH 5.10.y] net: openvswitch: fix skb leak on flow key update failure during recirculation

Quoted 1 line · Ilya Maximets

[OVS drop reasons are not available in 5.10, hence plain kfree_skb()]

Queued for 5.10, thanks.

Signature · 2 lines
Thanks,
Sasha