From: Davide Caratti <dcaratti@redhat.com>
To: Pravin B Shelar <pshelar@ovn.org>,
Jakub Kicinski <kuba@kernel.org>,
John Hurley <john.hurley@netronome.com>
Cc: gnault@redhat.com, marcelo.leitner@gmail.com, netdev@vger.kernel.org
Subject: [PATCH net] net: openvswitch: ensure LSE is pullable before reading it
Date: Thu, 3 Dec 2020 10:46:06 +0100 [thread overview]
Message-ID: <aa099f245d93218b84b5c056b67b6058ccf81a66.1606987185.git.dcaratti@redhat.com> (raw)
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>
---
net/openvswitch/actions.c | 3 +++
1 file changed, 3 insertions(+)
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);
--
2.28.0
next reply other threads:[~2020-12-03 9:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-03 9:46 Davide Caratti [this message]
2020-12-03 19:20 ` [PATCH net] net: openvswitch: ensure LSE is pullable before reading it patchwork-bot+netdevbpf
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=aa099f245d93218b84b5c056b67b6058ccf81a66.1606987185.git.dcaratti@redhat.com \
--to=dcaratti@redhat.com \
--cc=gnault@redhat.com \
--cc=john.hurley@netronome.com \
--cc=kuba@kernel.org \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pshelar@ovn.org \
/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;
as well as URLs for NNTP newsgroup(s).