summaryrefslogtreecommitdiffstats
path: root/net/openvswitch
diff options
context:
space:
mode:
authorDavide Caratti <dcaratti@redhat.com>2020-12-03 10:46:06 +0100
committerJakub Kicinski <kuba@kernel.org>2020-12-03 11:13:29 -0800
commit43c13605bad44b8abbc9776d6e63f62ccb7a47d6 (patch)
treee271b28912c57b1c6d2f232ed4db22b9539a10da /net/openvswitch
parent13de4ed9e3a9ccbe54d05f7d5c773f69ecaf6c64 (diff)
downloadlinux-stable-43c13605bad44b8abbc9776d6e63f62ccb7a47d6.tar.gz
linux-stable-43c13605bad44b8abbc9776d6e63f62ccb7a47d6.tar.bz2
linux-stable-43c13605bad44b8abbc9776d6e63f62ccb7a47d6.zip
net: openvswitch: ensure LSE is pullable before reading it
when openvswitch is configured to mangle the LSE, the current value is read from the packet dereferencing 4 bytes at mpls_hdr(): ensure that the label is contained in the skb "linear" area. Found by code inspection. Fixes: d27cf5c59a12 ("net: core: add MPLS update core helper and use in OvS") Signed-off-by: Davide Caratti <dcaratti@redhat.com> Link: https://lore.kernel.org/r/aa099f245d93218b84b5c056b67b6058ccf81a66.1606987185.git.dcaratti@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/openvswitch')
-rw-r--r--net/openvswitch/actions.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 5829a020b81c..c3a664871cb5 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -199,6 +199,9 @@ static int set_mpls(struct sk_buff *skb, struct sw_flow_key *flow_key,
__be32 lse;
int err;
+ if (!pskb_may_pull(skb, skb_network_offset(skb) + MPLS_HLEN))
+ return -ENOMEM;
+
stack = mpls_hdr(skb);
lse = OVS_MASKED(stack->label_stack_entry, *mpls_lse, *mask);
err = skb_mpls_update_lse(skb, lse);