From: David Ahern <dsahern@kernel.org> Date: 2021-12-31 00:36:48
Add length checks for attributes within a multipath route (attributes
within RTA_MULTIPATH). Motivated by the syzbot report in patch 1 and
then expanded to other attributes as noted by Ido.
David Ahern (5):
ipv4: Check attribute length for RTA_GATEWAY in multipath route
ipv4: Check attribute length for RTA_FLOW in multipath route
ipv6: Check attribute length for RTA_GATEWAY in multipath route
ipv6: Check attribute length for RTA_GATEWAY when deleting multipath
route
lwtunnel: Validate RTA_ENCAP_TYPE attribute is at least 2 bytes
net/core/lwtunnel.c | 4 ++++
net/ipv4/fib_semantics.c | 49 +++++++++++++++++++++++++++++++++++-----
net/ipv6/route.c | 31 +++++++++++++++++++++++--
3 files changed, 76 insertions(+), 8 deletions(-)
--
2.24.3 (Apple Git-128)
From: David Ahern <dsahern@kernel.org> Date: 2021-12-31 00:36:45
Commit referenced in the Fixes tag used nla_memcpy for RTA_GATEWAY as
does the current nla_get_in6_addr. nla_memcpy protects against accessing
memory greater than what is in the attribute, but there is no check
requiring the attribute to have an IPv6 address. Add it.
Fixes: 51ebd3181572 ("ipv6: add support of equal cost multipath (ECMP)")
Signed-off-by: David Ahern <dsahern@kernel.org>
Cc: Nicolas Dichtel <redacted>
---
net/ipv6/route.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
From: David Ahern <dsahern@kernel.org> Date: 2021-12-31 00:36:47
Make sure RTA_FLOW is at least 4B before using.
Fixes: 4e902c57417c ("[IPv4]: FIB configuration using struct fib_config")
Signed-off-by: David Ahern <dsahern@kernel.org>
---
net/ipv4/fib_semantics.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
@@ -662,6 +662,19 @@ static int fib_count_nexthops(struct rtnexthop *rtnh, int remaining,returnnhs;}+staticintfib_gw_from_attr(__be32*gw,structnlattr*nla,+structnetlink_ext_ack*extack)+{+if(nla_len(nla)<sizeof(*gw)){+NL_SET_ERR_MSG(extack,"Invalid IPv4 address in RTA_GATEWAY");+return-EINVAL;+}++*gw=nla_get_in_addr(nla);++return0;+}+/* only called when fib_nh is integrated into fib_info */staticintfib_get_nhs(structfib_info*fi,structrtnexthop*rtnh,intremaining,structfib_config*cfg,
From: David Ahern <dsahern@kernel.org> Date: 2021-12-31 00:36:49
lwtunnel_valid_encap_type_attr is used to validate encap attributes
within a multipath route. Add length validation checking to the type.
lwtunnel_valid_encap_type_attr is called converting attributes to
fib{6,}_config struct which means it is used before fib_get_nhs,
ip6_route_multipath_add, and ip6_route_multipath_del - other
locations that use rtnh_ok and then nla_get_u16 on RTA_ENCAP_TYPE
attribute.
Fixes: 9ed59592e3e3 ("lwtunnel: fix autoload of lwt modules")
Signed-off-by: David Ahern <dsahern@kernel.org>
---
net/core/lwtunnel.c | 4 ++++
net/ipv4/fib_semantics.c | 3 +++
net/ipv6/route.c | 4 ++++
3 files changed, 11 insertions(+)
Hello:
This series was applied to netdev/net.git (master)
by David S. Miller [off-list ref]:
On Thu, 30 Dec 2021 17:36:30 -0700 you wrote:
Add length checks for attributes within a multipath route (attributes
within RTA_MULTIPATH). Motivated by the syzbot report in patch 1 and
then expanded to other attributes as noted by Ido.
David Ahern (5):
ipv4: Check attribute length for RTA_GATEWAY in multipath route
ipv4: Check attribute length for RTA_FLOW in multipath route
ipv6: Check attribute length for RTA_GATEWAY in multipath route
ipv6: Check attribute length for RTA_GATEWAY when deleting multipath
route
lwtunnel: Validate RTA_ENCAP_TYPE attribute is at least 2 bytes
[...]
From: Nicolas Dichtel <hidden> Date: 2021-12-31 15:31:43
Le 31/12/2021 à 01:36, David Ahern a écrit :
Commit referenced in the Fixes tag used nla_memcpy for RTA_GATEWAY as
does the current nla_get_in6_addr. nla_memcpy protects against accessing
memory greater than what is in the attribute, but there is no check
requiring the attribute to have an IPv6 address. Add it.
Fixes: 51ebd3181572 ("ipv6: add support of equal cost multipath (ECMP)")
Signed-off-by: David Ahern <dsahern@kernel.org>
Cc: Nicolas Dichtel <redacted>
---
net/ipv6/route.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
[snip]
quoted hunk
@@ -5264,7 +5277,13 @@ static int ip6_route_multipath_add(struct fib6_config *cfg, nla = nla_find(attrs, attrlen, RTA_GATEWAY); if (nla) {- r_cfg.fc_gateway = nla_get_in6_addr(nla);+ int ret;++ ret = fib6_gw_from_attr(&r_cfg.fc_gateway, nla,+ extack);+ if (ret)+ return ret;
From: David Ahern <hidden> Date: 2022-01-02 16:45:16
On 12/31/21 8:30 AM, Nicolas Dichtel wrote:
Le 31/12/2021 à 01:36, David Ahern a écrit :
quoted
Commit referenced in the Fixes tag used nla_memcpy for RTA_GATEWAY as
does the current nla_get_in6_addr. nla_memcpy protects against accessing
memory greater than what is in the attribute, but there is no check
requiring the attribute to have an IPv6 address. Add it.
Fixes: 51ebd3181572 ("ipv6: add support of equal cost multipath (ECMP)")
Signed-off-by: David Ahern <dsahern@kernel.org>
Cc: Nicolas Dichtel <redacted>
---
net/ipv6/route.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
[snip]
quoted
@@ -5264,7 +5277,13 @@ static int ip6_route_multipath_add(struct fib6_config *cfg, nla = nla_find(attrs, attrlen, RTA_GATEWAY); if (nla) {- r_cfg.fc_gateway = nla_get_in6_addr(nla);+ int ret;++ ret = fib6_gw_from_attr(&r_cfg.fc_gateway, nla,+ extack);+ if (ret)+ return ret;