Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Sep 2021 21:12:55 GMT
From:      "Alexander V. Chernikov" <melifaro@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 4e97cbba1c79 - stable/13 - lltable: fix crash introduced in c541bd368f86.
Message-ID:  <202109072112.187LCtmw024080@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by melifaro:

URL: https://cgit.FreeBSD.org/src/commit/?id=4e97cbba1c79fc7c2a5ceeccefbea0f71887e915

commit 4e97cbba1c79fc7c2a5ceeccefbea0f71887e915
Author:     Alexander V. Chernikov <melifaro@FreeBSD.org>
AuthorDate: 2021-08-22 08:47:49 +0000
Commit:     Alexander V. Chernikov <melifaro@FreeBSD.org>
CommitDate: 2021-09-07 21:02:58 +0000

    lltable: fix crash introduced in c541bd368f86.
    
    Reported by:    cy
    
    (cherry picked from commit f8c1b1a9296696f70ac209612a00ae0722d07ed9)
---
 sys/netinet6/in6.c     | 7 ++++---
 sys/netinet6/nd6_rtr.c | 5 +++--
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index 142a05ded2b6..d54aba58edb6 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -2323,6 +2323,7 @@ in6_lltable_lookup(struct lltable *llt, u_int flags,
 	const struct sockaddr *l3addr)
 {
 	const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)l3addr;
+	int family = flags >> 16;
 	struct llentry *lle;
 
 	IF_AFDATA_LOCK_ASSERT(llt->llt_ifp);
@@ -2333,13 +2334,13 @@ in6_lltable_lookup(struct lltable *llt, u_int flags,
 	    ("wrong lle request flags: %#x", flags));
 
 	lle = in6_lltable_find_dst(llt, &sin6->sin6_addr);
-	if (lle == NULL)
-		return (NULL);
 
-	int family = flags >> 16;
 	if (__predict_false(family != AF_INET6))
 		lle = llentry_lookup_family(lle, family);
 
+	if (lle == NULL)
+		return (NULL);
+
 	if (flags & LLE_UNLOCKED)
 		return (lle);
 
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
index 2960b6cad951..cec9fccd63c4 100644
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -972,7 +972,7 @@ defrouter_select_fib(int fibnum)
 	TAILQ_FOREACH(dr, &V_nd6_defrouter, dr_entry) {
 		NET_EPOCH_ENTER(et);
 		if (selected_dr == NULL && dr->ifp->if_fib == fibnum &&
-		    (ln = nd6_lookup(&dr->rtaddr, 0, dr->ifp)) &&
+		    (ln = nd6_lookup(&dr->rtaddr, LLE_SF(AF_INET6, 0), dr->ifp)) &&
 		    ND6_IS_LLINFO_PROBREACH(ln)) {
 			selected_dr = dr;
 			defrouter_ref(selected_dr);
@@ -1814,7 +1814,8 @@ find_pfxlist_reachable_router(struct nd_prefix *pr)
 
 	NET_EPOCH_ENTER(et);
 	LIST_FOREACH(pfxrtr, &pr->ndpr_advrtrs, pfr_entry) {
-		ln = nd6_lookup(&pfxrtr->router->rtaddr, 0, pfxrtr->router->ifp);
+		ln = nd6_lookup(&pfxrtr->router->rtaddr, LLE_SF(AF_INET6, 0),
+		    pfxrtr->router->ifp);
 		if (ln == NULL)
 			continue;
 		canreach = ND6_IS_LLINFO_PROBREACH(ln);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202109072112.187LCtmw024080>