naccyde / rpms / iproute

Forked from rpms/iproute 5 months ago
Clone

Blame SOURCES/0039-ip-route-Fix-nexthop-encap-parsing.patch

7e752c
From 06ce7afb4135de6ed92a286793cba5129f17f614 Mon Sep 17 00:00:00 2001
7e752c
From: Phil Sutter <psutter@redhat.com>
7e752c
Date: Mon, 26 Nov 2018 19:11:55 +0100
7e752c
Subject: [PATCH] ip-route: Fix nexthop encap parsing
7e752c
7e752c
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1625358
7e752c
Upstream Status: iproute2.git commit 05d978e0850a6
7e752c
7e752c
commit 05d978e0850a6a3bae1e6c5392d82f7b1496f86a
7e752c
Author: Phil Sutter <phil@nwl.cc>
7e752c
Date:   Tue Nov 13 13:39:04 2018 +0100
7e752c
7e752c
    ip-route: Fix nexthop encap parsing
7e752c
7e752c
    When parsing nexthop parameters, a buffer of 4k bytes is provided. Yet,
7e752c
    in lwt_parse_encap() and some functions called by it, buffer size was
7e752c
    assumed to be 1k despite the actual size was provided. This led to
7e752c
    spurious buffer size errors if the buffer was filled by previous nexthop
7e752c
    parameters to exceed that 1k boundary.
7e752c
7e752c
    Fixes: 1e5293056a02c ("lwtunnel: Add encapsulation support to ip route")
7e752c
    Fixes: 5866bddd9aa9e ("ila: Add support for ILA lwtunnels")
7e752c
    Fixes: ed67f83806538 ("ila: Support for checksum neutral translation")
7e752c
    Fixes: 86905c8f057c0 ("ila: support for configuring identifier and hook types")
7e752c
    Fixes: b15f440e78373 ("lwt: BPF support for LWT")
7e752c
    Signed-off-by: Phil Sutter <phil@nwl.cc>
7e752c
    Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
7e752c
---
7e752c
 ip/iproute_lwtunnel.c | 14 +++++++-------
7e752c
 1 file changed, 7 insertions(+), 7 deletions(-)
7e752c
7e752c
diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
7e752c
index 4ebfaa7..388cd19 100644
7e752c
--- a/ip/iproute_lwtunnel.c
7e752c
+++ b/ip/iproute_lwtunnel.c
7e752c
@@ -851,7 +851,7 @@ static int parse_encap_ila(struct rtattr *rta, size_t len,
7e752c
 
7e752c
 	argc--; argv++;
7e752c
 
7e752c
-	if (rta_addattr64(rta, 1024, ILA_ATTR_LOCATOR, locator))
7e752c
+	if (rta_addattr64(rta, len, ILA_ATTR_LOCATOR, locator))
7e752c
 		return -1;
7e752c
 
7e752c
 	while (argc > 0) {
7e752c
@@ -865,7 +865,7 @@ static int parse_encap_ila(struct rtattr *rta, size_t len,
7e752c
 				invarg("\"csum-mode\" value is invalid\n",
7e752c
 				       *argv);
7e752c
 
7e752c
-			ret = rta_addattr8(rta, 1024, ILA_ATTR_CSUM_MODE,
7e752c
+			ret = rta_addattr8(rta, len, ILA_ATTR_CSUM_MODE,
7e752c
 					   (__u8)csum_mode);
7e752c
 
7e752c
 			argc--; argv++;
7e752c
@@ -879,7 +879,7 @@ static int parse_encap_ila(struct rtattr *rta, size_t len,
7e752c
 				invarg("\"ident-type\" value is invalid\n",
7e752c
 				       *argv);
7e752c
 
7e752c
-			ret = rta_addattr8(rta, 1024, ILA_ATTR_IDENT_TYPE,
7e752c
+			ret = rta_addattr8(rta, len, ILA_ATTR_IDENT_TYPE,
7e752c
 					   (__u8)ident_type);
7e752c
 
7e752c
 			argc--; argv++;
7e752c
@@ -893,7 +893,7 @@ static int parse_encap_ila(struct rtattr *rta, size_t len,
7e752c
 				invarg("\"hook-type\" value is invalid\n",
7e752c
 				       *argv);
7e752c
 
7e752c
-			ret = rta_addattr8(rta, 1024, ILA_ATTR_HOOK_TYPE,
7e752c
+			ret = rta_addattr8(rta, len, ILA_ATTR_HOOK_TYPE,
7e752c
 					   (__u8)hook_type);
7e752c
 
7e752c
 			argc--; argv++;
7e752c
@@ -1016,7 +1016,7 @@ static int parse_encap_bpf(struct rtattr *rta, size_t len, int *argcp,
7e752c
 			if (get_unsigned(&headroom, *argv, 0) || headroom == 0)
7e752c
 				invarg("headroom is invalid\n", *argv);
7e752c
 			if (!headroom_set)
7e752c
-				rta_addattr32(rta, 1024, LWT_BPF_XMIT_HEADROOM,
7e752c
+				rta_addattr32(rta, len, LWT_BPF_XMIT_HEADROOM,
7e752c
 					      headroom);
7e752c
 			headroom_set = 1;
7e752c
 		} else if (strcmp(*argv, "help") == 0) {
7e752c
@@ -1057,7 +1057,7 @@ int lwt_parse_encap(struct rtattr *rta, size_t len, int *argcp, char ***argvp)
7e752c
 		exit(-1);
7e752c
 	}
7e752c
 
7e752c
-	nest = rta_nest(rta, 1024, RTA_ENCAP);
7e752c
+	nest = rta_nest(rta, len, RTA_ENCAP);
7e752c
 	switch (type) {
7e752c
 	case LWTUNNEL_ENCAP_MPLS:
7e752c
 		ret = parse_encap_mpls(rta, len, &argc, &argv);
7e752c
@@ -1090,7 +1090,7 @@ int lwt_parse_encap(struct rtattr *rta, size_t len, int *argcp, char ***argvp)
7e752c
 
7e752c
 	rta_nest_end(rta, nest);
7e752c
 
7e752c
-	ret = rta_addattr16(rta, 1024, RTA_ENCAP_TYPE, type);
7e752c
+	ret = rta_addattr16(rta, len, RTA_ENCAP_TYPE, type);
7e752c
 
7e752c
 	*argcp = argc;
7e752c
 	*argvp = argv;
7e752c
-- 
7e752c
1.8.3.1
7e752c