From: William Tu Date: Tue, 12 May 2020 17:36:23 +0000 (-0700) Subject: erspan: Check IFLA_GRE_ERSPAN_VER is set. X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=51fa960d3b5163b1af22efdebcabfccc5d615ad6;p=linux.git erspan: Check IFLA_GRE_ERSPAN_VER is set. Add a check to make sure the IFLA_GRE_ERSPAN_VER is provided by users. Fixes: f989d546a2d5 ("erspan: Add type I version 0 support.") Cc: Eric Dumazet Signed-off-by: William Tu Reviewed-by: Eric Dumazet Signed-off-by: David S. Miller --- diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index e29cd48674d7e..0ce9b91ff55c0 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -1087,7 +1087,8 @@ static int erspan_validate(struct nlattr *tb[], struct nlattr *data[], if (ret) return ret; - if (nla_get_u8(data[IFLA_GRE_ERSPAN_VER]) == 0) + if (data[IFLA_GRE_ERSPAN_VER] && + nla_get_u8(data[IFLA_GRE_ERSPAN_VER]) == 0) return 0; /* ERSPAN type II/III should only have GRE sequence and key flag */