git: d0e92d89a9f0 - stable/14 - ipfilter: fix inverted range check on the lookup iterator unit

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Mon, 26 Oct 2026 19:46:47 UTC
The branch stable/14 has been updated by markj:

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

commit d0e92d89a9f03b0045b6eba086338a220485c381
Author:     Andrew Griffiths <andrew@calif.io>
AuthorDate: 2026-09-06 20:44:35 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-10-26 14:12:15 +0000

    ipfilter: fix inverted range check on the lookup iterator unit
    
    ipf_lookup_iterate() validates iter.ili_unit with
    
      if (iter.ili_unit < IPL_LOGALL && iter.ili_unit > IPL_LOGMAX)
    
    or alternatively,
    
      if (iter.ili_unit < -1 && iter.ili_unit > 7)
    
    ipf_lookup_add(), ipf_lookup_delete(), ipf_lookup_stats()
    ipf_lookup_flush() validate with a ||
    
    Submitted by calif.io for the OpenAI Patch The Planet program
    
    Signed-off-by: Andrew Griffiths <andrew@calif.io>
    
    Reviewed by:    markj
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D59726
    
    (cherry picked from commit cb035c19c3e76d547eb7d4bca1f1106b117c27a0)
---
 sys/netpfil/ipfilter/netinet/ip_lookup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/netpfil/ipfilter/netinet/ip_lookup.c b/sys/netpfil/ipfilter/netinet/ip_lookup.c
index f9e00d3ec40b..02c3d06afdd8 100644
--- a/sys/netpfil/ipfilter/netinet/ip_lookup.c
+++ b/sys/netpfil/ipfilter/netinet/ip_lookup.c
@@ -666,7 +666,7 @@ ipf_lookup_iterate(ipf_main_softc_t *softc, void *data, int uid, void *ctx)
 	if (err != 0)
 		return (err);
 
-	if (iter.ili_unit < IPL_LOGALL && iter.ili_unit > IPL_LOGMAX) {
+	if (iter.ili_unit < IPL_LOGALL || iter.ili_unit > IPL_LOGMAX) {
 		IPFERROR(50038);
 		return (EINVAL);
 	}