From b83b0767eccfb386406ccb24130b975f1c2b0ee4 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Thu, 21 Feb 2019 14:39:47 +0100 Subject: [PATCH] ip-route: Fix nexthop encap parsing Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1624656 Upstream Status: iproute2.git commit 05d978e0850a6 Conflicts: Some chunks dropped due to missing support for ident-type and hook-type. commit 05d978e0850a6a3bae1e6c5392d82f7b1496f86a Author: Phil Sutter Date: Tue Nov 13 13:39:04 2018 +0100 ip-route: Fix nexthop encap parsing When parsing nexthop parameters, a buffer of 4k bytes is provided. Yet, in lwt_parse_encap() and some functions called by it, buffer size was assumed to be 1k despite the actual size was provided. This led to spurious buffer size errors if the buffer was filled by previous nexthop parameters to exceed that 1k boundary. Fixes: 1e5293056a02c ("lwtunnel: Add encapsulation support to ip route") Fixes: 5866bddd9aa9e ("ila: Add support for ILA lwtunnels") Fixes: ed67f83806538 ("ila: Support for checksum neutral translation") Fixes: 86905c8f057c0 ("ila: support for configuring identifier and hook types") Fixes: b15f440e78373 ("lwt: BPF support for LWT") Signed-off-by: Phil Sutter Signed-off-by: Stephen Hemminger --- ip/iproute_lwtunnel.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c index 1a6891267d2e1..b6f08f073ef02 100644 --- a/ip/iproute_lwtunnel.c +++ b/ip/iproute_lwtunnel.c @@ -343,7 +343,7 @@ static int parse_encap_ila(struct rtattr *rta, size_t len, argc--; argv++; - if (rta_addattr64(rta, 1024, ILA_ATTR_LOCATOR, locator)) + if (rta_addattr64(rta, len, ILA_ATTR_LOCATOR, locator)) return -1; while (argc > 0) { @@ -357,7 +357,7 @@ static int parse_encap_ila(struct rtattr *rta, size_t len, invarg("\"csum-mode\" value is invalid\n", *argv); - ret = rta_addattr8(rta, 1024, ILA_ATTR_CSUM_MODE, + ret = rta_addattr8(rta, len, ILA_ATTR_CSUM_MODE, (__u8)csum_mode); argc--; argv++; @@ -528,7 +528,7 @@ static int parse_encap_bpf(struct rtattr *rta, size_t len, int *argcp, if (get_unsigned(&headroom, *argv, 0) || headroom == 0) invarg("headroom is invalid\n", *argv); if (!headroom_set) - rta_addattr32(rta, 1024, LWT_BPF_XMIT_HEADROOM, + rta_addattr32(rta, len, LWT_BPF_XMIT_HEADROOM, headroom); headroom_set = 1; } else if (strcmp(*argv, "help") == 0) { @@ -569,7 +569,7 @@ int lwt_parse_encap(struct rtattr *rta, size_t len, int *argcp, char ***argvp) exit(-1); } - nest = rta_nest(rta, 1024, RTA_ENCAP); + nest = rta_nest(rta, len, RTA_ENCAP); switch (type) { case LWTUNNEL_ENCAP_MPLS: ret = parse_encap_mpls(rta, len, &argc, &argv); @@ -596,7 +596,7 @@ int lwt_parse_encap(struct rtattr *rta, size_t len, int *argcp, char ***argvp) rta_nest_end(rta, nest); - ret = rta_addattr16(rta, 1024, RTA_ENCAP_TYPE, type); + ret = rta_addattr16(rta, len, RTA_ENCAP_TYPE, type); *argcp = argc; *argvp = argv; -- 2.21.0