git: 8364b6bc0c36 - main - ipfw: fix off-by-one in the IP_FW_XADD rule count check
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 19 Nov 2026 17:58:00 UTC
The branch main has been updated by maxim:
URL: https://cgit.FreeBSD.org/src/commit/?id=8364b6bc0c36ab66f71cb2b3e00479326132c80f
commit 8364b6bc0c36ab66f71cb2b3e00479326132c80f
Author: Maxim Konovalov <maxim@FreeBSD.org>
AuthorDate: 2026-11-17 02:22:18 +0000
Commit: Maxim Konovalov <maxim@FreeBSD.org>
CommitDate: 2026-11-19 17:57:21 +0000
ipfw: fix off-by-one in the IP_FW_XADD rule count check
Restore the pre-4a77657cbc0 ">=" comparison, otherwise parse_rules_v1()
writes one rule_check_info beyond the allocated buffer.
Do the same in ip_fw_compat.c, which has a copy of the loop but is not
built at the moment.
stable/14 is not affected.
Reviewed by: ae
Fixes: 4a77657cbc0 ("ipfw: migrate ipfw to 32-bit size rule numbers")
MFC after: 1 week
MFC to: stable/15
Found with: Claude Code Opus 5.5
Differential Revision: https://reviews.freebsd.org/D61727
---
sys/netpfil/ipfw/ip_fw_compat.c | 2 +-
sys/netpfil/ipfw/ip_fw_sockopt.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/sys/netpfil/ipfw/ip_fw_compat.c b/sys/netpfil/ipfw/ip_fw_compat.c
index 590159411509..3f4ed9411be7 100644
--- a/sys/netpfil/ipfw/ip_fw_compat.c
+++ b/sys/netpfil/ipfw/ip_fw_compat.c
@@ -309,7 +309,7 @@ parse_rules_v0(struct ip_fw_chain *chain, ip_fw3_opheader *op3,
r = (struct ip_fw_rule *)(ctlv + 1);
while (clen > 0) {
rsize = RULEUSIZE1(r);
- if (rsize > clen || count > ctlv->count) {
+ if (rsize > clen || count >= ctlv->count) {
error = EINVAL;
break;
}
diff --git a/sys/netpfil/ipfw/ip_fw_sockopt.c b/sys/netpfil/ipfw/ip_fw_sockopt.c
index a5892bb387e5..458e8ba9cc30 100644
--- a/sys/netpfil/ipfw/ip_fw_sockopt.c
+++ b/sys/netpfil/ipfw/ip_fw_sockopt.c
@@ -2424,7 +2424,7 @@ parse_rules_v1(struct ip_fw_chain *chain, ip_fw3_opheader *op3,
r = (struct ip_fw_rule *)(ctlv + 1);
while (clen > 0) {
rsize = RULEUSIZE1(r);
- if (rsize > clen || count > ctlv->count) {
+ if (rsize > clen || count >= ctlv->count) {
error = EINVAL;
break;
}