git: cb035c19c3e7 - main - ipfilter: fix inverted range check on the lookup iterator unit

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Fri, 25 Sep 2026 17:00:48 UTC
The branch main has been updated by markj:

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

commit cb035c19c3e76d547eb7d4bca1f1106b117c27a0
Author:     Andrew Griffiths <andrew@calif.io>
AuthorDate: 2026-09-06 20:44:35 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-09-25 16:50:42 +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
---
 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 a52dbef00166..b0fb2b09c325 100644
--- a/sys/netpfil/ipfilter/netinet/ip_lookup.c
+++ b/sys/netpfil/ipfilter/netinet/ip_lookup.c
@@ -663,7 +663,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);
 	}