summaryrefslogtreecommitdiff
path: root/net/ipv4/gre_demux.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2020-03-19 17:01:45 +0300
committerIngo Molnar <mingo@kernel.org>2020-03-19 17:01:45 +0300
commit409e1a31404082ecb85b54bba920a3dd8077c672 (patch)
tree50daa709a2e9c461316122eb7b7850de9eb30f03 /net/ipv4/gre_demux.c
parentfdca7c1496cf05657654b6576143e909fc160a61 (diff)
parentdb5d85ce82487331b06ec0e076b85b5a3968bf53 (diff)
downloadlinux-409e1a31404082ecb85b54bba920a3dd8077c672.tar.xz
Merge branch 'perf/urgent' into perf/core, to pick up fixes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'net/ipv4/gre_demux.c')
-rw-r--r--net/ipv4/gre_demux.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/net/ipv4/gre_demux.c b/net/ipv4/gre_demux.c
index 5fd6e8ed02b5..66fdbfe5447c 100644
--- a/net/ipv4/gre_demux.c
+++ b/net/ipv4/gre_demux.c
@@ -56,7 +56,9 @@ int gre_del_protocol(const struct gre_protocol *proto, u8 version)
}
EXPORT_SYMBOL_GPL(gre_del_protocol);
-/* Fills in tpi and returns header length to be pulled. */
+/* Fills in tpi and returns header length to be pulled.
+ * Note that caller must use pskb_may_pull() before pulling GRE header.
+ */
int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
bool *csum_err, __be16 proto, int nhs)
{
@@ -110,8 +112,14 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
* - When dealing with WCCPv2, Skip extra 4 bytes in GRE header
*/
if (greh->flags == 0 && tpi->proto == htons(ETH_P_WCCP)) {
+ u8 _val, *val;
+
+ val = skb_header_pointer(skb, nhs + hdr_len,
+ sizeof(_val), &_val);
+ if (!val)
+ return -EINVAL;
tpi->proto = proto;
- if ((*(u8 *)options & 0xF0) != 0x40)
+ if ((*val & 0xF0) != 0x40)
hdr_len += 4;
}
tpi->hdr_len = hdr_len;