git: 5f7bea295283 - main - iflib: fix regression with new pfil(9) KPI

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Tue, 28 Feb 2023 16:58:29 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=5f7bea2952830ae60d4b65dafdc8411ac9d991f0

commit 5f7bea2952830ae60d4b65dafdc8411ac9d991f0
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2023-02-28 16:56:20 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2023-02-28 16:56:20 +0000

    iflib: fix regression with new pfil(9) KPI
    
    Do not pass the pointer to our valid mbuf to pfil(9).  Pass an
    uninitialized one only.  This was unsafe with the old KPI, too,
    but for some reason didn't fail.
    
    Fixes:  caf32b260ad46b17a4c1a8ce6383e37ac489f023
---
 sys/net/iflib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/net/iflib.c b/sys/net/iflib.c
index 39f3ccea4317..807ada5eb754 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -2713,7 +2713,6 @@ rxd_frag_to_sd(iflib_rxq_t rxq, if_rxd_frag_t irf, bool unload, if_rxsd_t sd,
 	cidx = irf->irf_idx;
 	fl = &rxq->ifr_fl[flid];
 	sd->ifsd_fl = fl;
-	m = fl->ifl_sds.ifsd_m[cidx];
 	sd->ifsd_cl = &fl->ifl_sds.ifsd_cl[cidx];
 	fl->ifl_credits--;
 #if MEMORY_LOGGING
@@ -2754,12 +2753,14 @@ rxd_frag_to_sd(iflib_rxq_t rxq, if_rxd_frag_t irf, bool unload, if_rxsd_t sd,
 			 * Filter said it was OK, so receive like
 			 * normal
 			 */
+			m = fl->ifl_sds.ifsd_m[cidx];
 			fl->ifl_sds.ifsd_m[cidx] = NULL;
 			break;
 		default:
 			MPASS(0);
 		}
 	} else {
+		m = fl->ifl_sds.ifsd_m[cidx];
 		fl->ifl_sds.ifsd_m[cidx] = NULL;
 		if (pf_rv != NULL)
 			*pf_rv = PFIL_PASS;