aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorRobert Shearman <rshearma@brocade.com>2015-12-10 14:30:48 -0500
committerDavid S. Miller <davem@davemloft.net>2015-12-12 00:43:44 -0500
commita3e948e83a302c63f196512e253067ded6bbc832 (patch)
treeaa6ceb9dafde5d1279b18da1e994f35a38f361a2 /net
parentf1c2ef40c6436f8fa287ff1be2c75c4932180b1f (diff)
mpls: validate L2 via address length
If an L2 via address for an mpls nexthop is specified, the length of the L2 address must match that expected by the output device, otherwise it could access memory beyond the end of the via address buffer in the route. This check was present prior to commit f8efb73c97e2 ("mpls: multipath route support"), but got lost in the refactoring, so add it back, applying it to all nexthops in multipath routes. Fixes: f8efb73c97e2 ("mpls: multipath route support") Signed-off-by: Robert Shearman <rshearma@brocade.com> Acked-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/mpls/af_mpls.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index c70d750148b6..3be29cb1f658 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -534,6 +534,10 @@ static int mpls_nh_assign_dev(struct net *net, struct mpls_route *rt,
534 if (!mpls_dev_get(dev)) 534 if (!mpls_dev_get(dev))
535 goto errout; 535 goto errout;
536 536
537 if ((nh->nh_via_table == NEIGH_LINK_TABLE) &&
538 (dev->addr_len != nh->nh_via_alen))
539 goto errout;
540
537 RCU_INIT_POINTER(nh->nh_dev, dev); 541 RCU_INIT_POINTER(nh->nh_dev, dev);
538 542
539 return 0; 543 return 0;