Hello, diff makes sense and reads OK to me. I will commit it later this week. today unless I'll hear some objections.
thanks and regards sashan On Wed, Nov 18, 2026 at 10:26:19PM +0000, [email protected] wrote: > >Synopsis: At the "set limit table-entries" limit, pfctl -T add sleeps > forever holding pfioctl_rw; every later pf ioctl hangs. > >Category: kernel > >Release: OpenBSD 8.0-current #157 (Nov 17 2026), src 3131021dba07 > > >Description: > pfr_create_kentry_unlocked() (pf_table.c:1016) uses PR_WAITOK > without PR_LIMITFAIL. When the pfrke pool is at its hard limit, > the add sleeps in pool_get() while pfioctl() holds pfioctl_rw, > so nothing can free an entry. pfctl -si, -d, -f ... then block > behind it; only a reboot recovers. Other limited pf pools > (tables, anchors, states, rules) already use PR_LIMITFAIL. > Happens whenever the limit equals the entries in use (seen with > 1 and with 50 entries). I have manually verfied the bug in current > and in test > > >How-To-Repeat: > pfctl -t k1t -T add 192.0.2.1 > N=$(vmstat -m | awk '$1=="pfrke_plain"{print $5}') > { echo "set limit table-entries $N"; cat /etc/pf.conf; } | pfctl -f - > pfctl -t k1t -T add 192.0.2.2 & # never returns > sleep 5; pfctl -si # hangs as well > > ps shows "pfrke_p" for the add and "pfioctl" for pfctl -si. > > >Fix: > For discussion : fail with ENOMEM at the limit, like > the other pf pools. With this, the add reports "Cannot > allocate memory" and pf stays usable (tested 3/3 vs 3/3 on > amd64, same tree with and without the diff). > > Index: sys/net/pf_table.c > =================================================================== > RCS file: /cvs/src/sys/net/pf_table.c,v > diff -u -p -r1.151 pf_table.c > --- sys/net/pf_table.c > +++ sys/net/pf_table.c > @@ -1009,7 +1009,7 @@ pfr_create_kentry_unlocked(struct pfr_addr *ad, int fl > panic("unknown pfra_type %d", ad->pfra_type); > > if (flags & PFR_FLAG_USERIOCTL) > - mflags |= PR_WAITOK; > + mflags |= PR_WAITOK | PR_LIMITFAIL; > else > mflags |= PR_NOWAIT; >
