listen port is not bound to port 0. With a matching pf divert-to
rule this assumption is no longer true and could crash the kernel
with kassert. In both pf and stack drop TCP packets with destination
port 0 before they can do harm.
OK sashan@ claudio@
-/* $OpenBSD: pf.c,v 1.1169 2023/01/06 17:44:34 sashan Exp $ */
+/* $OpenBSD: pf.c,v 1.1170 2023/01/12 13:09:47 bluhm Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
NULL, reason, pd->af))
return (PF_DROP);
pd->hdrlen = sizeof(*th);
- if (pd->off + (th->th_off << 2) > pd->tot_len ||
+ if (th->th_dport == 0 ||
+ pd->off + (th->th_off << 2) > pd->tot_len ||
(th->th_off << 2) < sizeof(struct tcphdr)) {
REASON_SET(reason, PFRES_SHORT);
return (PF_DROP);
-/* $OpenBSD: tcp_input.c,v 1.384 2022/12/09 00:24:44 bluhm Exp $ */
+/* $OpenBSD: tcp_input.c,v 1.385 2023/01/12 13:09:47 bluhm Exp $ */
/* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */
/*
th->th_win = ntohs(th->th_win);
th->th_urp = ntohs(th->th_urp);
+ if (th->th_dport == 0) {
+ tcpstat_inc(tcps_noport);
+ goto dropwithreset_ratelim;
+ }
+
/*
* Locate pcb for segment.
*/