The uid and jail types of the "lookup" rule option take their key from
the credentials that check_uidgid() caches for the packet. When no
local socket is associated with the packet, for example a forwarded
packet or an ICMP message, check_uidgid() leaves the cached pointer
NULL, and ipfw_chk() dereferenced it.
Such a packet has no uid or jail ID, so do not match it, as the uid,
gid and jail options already do not.
Add two cases to the lookup tests:
uid "lookup uid" matches the traffic of a local socket, and an
ICMP echo request, which has no socket, matches only
"not lookup uid"
jail the same for "lookup jail", over IPv6No test covered the uid and gid options either, so add uid.sh,
modelled on lookup.sh, with an inetd service in a VNET jail:
uid "uid 0" and "uid root" match the packets the service sends,
"uid 4242" does not
gid the same for "gid 0", "gid wheel" and "gid 4242"Without the fix, lookup:uid and lookup:jail panic the kernel; uid:uid
and uid:gid pass with and without it.
Reported by: Yuxiang Yang, Yizhou Zhao, Xuewei Feng, Qi Li, and
Ke Xu from Tsinghua University using GLM5.1 from Z.ai
Fixes: 472099c4b024 ("implement a new match option,")
MFC after: 2 weeks
Assisted-by: Claude Opus 5.5