From: David Lebrun Date: Tue, 18 Apr 2017 15:59:49 +0000 (+0200) Subject: ipv6: sr: fix out-of-bounds access in SRH validation X-Git-Tag: Ubuntu-4.10.0-22.24~107 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=a62574c774ad34dbde9df72128687ade979a7d02;p=mirror_ubuntu-zesty-kernel.git ipv6: sr: fix out-of-bounds access in SRH validation BugLink: http://bugs.launchpad.net/bugs/1688499 [ 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 Cc: Andrey Konovalov Signed-off-by: David Lebrun Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Signed-off-by: Stefan Bader Signed-off-by: Thadeu Lima de Souza Cascardo --- 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;