summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorDavid Lebrun <david.lebrun@uclouvain.be>2017-04-18 18:59:49 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-05-03 18:37:40 +0300
commita024074740e75310e7c884bed6f1f6b354936727 (patch)
treee1aa142a58ecdca3310e9d65da964604aa44b795 /net
parent7e793ce3b3e1384a657bdcd74c9404247302893c (diff)
downloadlinux-a024074740e75310e7c884bed6f1f6b354936727.tar.xz
ipv6: sr: fix out-of-bounds access in SRH validation
[ Upstream commit 2f3bb64247b5b083d05ccecad9c2e139bbfdc294 ] This patch fixes an out-of-bounds access in seg6_validate_srh() when the trailing data is less than sizeof(struct sr6_tlv). Reported-by: Andrey Konovalov <andreyknvl@google.com> Cc: Andrey Konovalov <andreyknvl@google.com> Signed-off-by: David Lebrun <david.lebrun@uclouvain.be> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r--net/ipv6/seg6.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/net/ipv6/seg6.c b/net/ipv6/seg6.c
index a855eb325b03..5f44ffed2576 100644
--- a/net/ipv6/seg6.c
+++ b/net/ipv6/seg6.c
@@ -53,6 +53,9 @@ bool seg6_validate_srh(struct ipv6_sr_hdr *srh, int len)
struct sr6_tlv *tlv;
unsigned int tlv_len;
+ if (trailing < sizeof(*tlv))
+ return false;
+
tlv = (struct sr6_tlv *)((unsigned char *)srh + tlv_offset);
tlv_len = sizeof(*tlv) + tlv->len;