git: 5b64694c8a55 - stable/13 - Fix setting static entries for arp/ndp.
Alexander V. Chernikov
melifaro at FreeBSD.org
Wed Mar 10 22:27:55 UTC 2021
The branch stable/13 has been updated by melifaro:
URL: https://cgit.FreeBSD.org/src/commit/?id=5b64694c8a5576d3fa77822da214b7bc49e5cdec
commit 5b64694c8a5576d3fa77822da214b7bc49e5cdec
Author: Alexander V. Chernikov <melifaro at FreeBSD.org>
AuthorDate: 2021-02-20 18:21:52 +0000
Commit: Alexander V. Chernikov <melifaro at FreeBSD.org>
CommitDate: 2021-03-10 21:48:30 +0000
Fix setting static entries for arp/ndp.
rtsock message validation changes committed in 2fe5a79425c7
did not take llinfo messages into account.
Add a special validation case for RTA_GATEWAY llinfo messages.
(cherry picked from commit e5b394f2d0d94f190c9da2346fd22d7c6fb14730)
---
sys/net/if_llatbl.c | 1 +
sys/net/rtsock.c | 26 ++++++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/sys/net/if_llatbl.c b/sys/net/if_llatbl.c
index 97a8e3e9ccc1..7225869a07d0 100644
--- a/sys/net/if_llatbl.c
+++ b/sys/net/if_llatbl.c
@@ -693,6 +693,7 @@ lla_rt_output(struct rt_msghdr *rtm, struct rt_addrinfo *info)
if (dl == NULL || dl->sdl_family != AF_LINK)
return (EINVAL);
+ /* XXX: should be ntohs() */
ifp = ifnet_byindex(dl->sdl_index);
if (ifp == NULL) {
log(LOG_INFO, "%s: invalid ifp (sdl_index %d)\n",
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 939e628f0f62..09d31f8f8076 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1265,11 +1265,37 @@ fill_sockaddr_inet6(struct sockaddr_in6 *sin6, const struct in6_addr *addr6,
}
#endif
+/*
+ * Checks if gateway is suitable for lltable operations.
+ * Lltable code requires AF_LINK gateway with ifindex
+ * and mac address specified.
+ * Returns 0 on success.
+ */
+static int
+cleanup_xaddrs_lladdr(struct rt_addrinfo *info)
+{
+ struct sockaddr_dl *sdl = (struct sockaddr_dl *)info->rti_info[RTAX_GATEWAY];
+
+ if (sdl->sdl_family != AF_LINK)
+ return (EINVAL);
+
+ if (sdl->sdl_index == 0)
+ return (EINVAL);
+
+ if (offsetof(struct sockaddr_dl, sdl_data) + sdl->sdl_nlen + sdl->sdl_alen > sdl->sdl_len)
+ return (EINVAL);
+
+ return (0);
+}
+
static int
cleanup_xaddrs_gateway(struct rt_addrinfo *info)
{
struct sockaddr *gw = info->rti_info[RTAX_GATEWAY];
+ if (info->rti_flags & RTF_LLDATA)
+ return (cleanup_xaddrs_lladdr(info));
+
switch (gw->sa_family) {
#ifdef INET
case AF_INET:
More information about the dev-commits-src-all
mailing list