git: 9ae078121d3f - stable/13 - fib_dxr: set fib_data field in struct dxr_aux early enough

From: Marko Zec <zec_at_FreeBSD.org>
Date: Tue, 14 May 2024 20:39:33 UTC
The branch stable/13 has been updated by zec:

URL: https://cgit.FreeBSD.org/src/commit/?id=9ae078121d3f70d8cd8c537fa16daf302ff5ee21

commit 9ae078121d3f70d8cd8c537fa16daf302ff5ee21
Author:     Marko Zec <zec@FreeBSD.org>
AuthorDate: 2024-05-07 15:44:09 +0000
Commit:     Marko Zec <zec@FreeBSD.org>
CommitDate: 2024-05-14 20:36:20 +0000

    fib_dxr: set fib_data field in struct dxr_aux early enough
    
    Previously it was possible for dxr_build() to return with da->fd
    unset in case of range_tbl or x_tbl malloc() failures.  This
    may have led to NULL ptr dereferencing in dxr_change_rib_batch().
    
    MFC after:      1 week
    
    PR:             278422
---
 sys/netinet/in_fib_dxr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/netinet/in_fib_dxr.c b/sys/netinet/in_fib_dxr.c
index 91f3bafdb47d..82245ecf6e66 100644
--- a/sys/netinet/in_fib_dxr.c
+++ b/sys/netinet/in_fib_dxr.c
@@ -882,6 +882,7 @@ dxr_build(struct dxr *dxr)
 		}
 		dxr->aux = da;
 		da->fibnum = dxr->fibnum;
+		da->fd = dxr->fd;
 		da->refcnt = 1;
 		LIST_INIT(&da->all_chunks);
 		LIST_INIT(&da->all_trie);
@@ -918,7 +919,6 @@ dxr_build(struct dxr *dxr)
 		trie_rebuild = 1;
 	}
 #endif
-	da->fd = dxr->fd;
 
 	microuptime(&t0);