opnsense-src/sys/netinet
Gleb Smirnoff 513f2e2e71 tcp: always set tcp_tun_port to a correct value
The tcp_tun_port field that is used to pass port value between UDP
and TCP in case of tunneling is a generic field that used to pass
data between network layers.  It can be contaminated on entry, e.g.
by a VLAN tag set by a NIC driver.  Explicily set it, so that it
is zeroed out in a normal not-tunneled TCP.  If it contains garbage,
tcp_twcheck() later can enter wrong block of code and treat the packet
as incorrectly tunneled one.  On main and stable/14 that will end up
with sending incorrect responses, but on stable/13 with ipfw(8) and
pcb-matching rules it may end up in a panic.

This is a minimal conservative patch to be merged to stable branches.
Later we may redesign this.

PR:			275169
Reviewed by:		tuexen
Differential Revision:	https://reviews.freebsd.org/D43065
2023-12-19 11:24:17 -08:00
..
cc sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
khelp sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
libalias sys: Remove $FreeBSD$: one-line bare tag 2023-08-16 11:55:17 -06:00
netdump netdump: Check the return value of ifunit_ref() 2023-10-02 08:09:26 -04:00
tcp_stacks tcp/hpts: make stacks responsible for clearing themselves out HPTS 2023-12-04 10:19:46 -08:00
accf_data.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
accf_dns.c sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
accf_http.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
dccp.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
icmp6.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
icmp_var.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
if_ether.c sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
if_ether.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
igmp.c sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
igmp.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
igmp_var.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
in.c sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
in.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
in_cksum.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
in_debug.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
in_fib.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
in_fib.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
in_fib_algo.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
in_fib_dxr.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
in_gif.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
in_jail.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
in_kdtrace.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
in_kdtrace.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
in_mcast.c mcast: fix leaked igmp packets on multicast cleanup 2023-12-14 22:06:01 +01:00
in_pcb.c tcp: tcp: allow SOL_SOCKET-level socket options via sysctl interface 2023-12-09 13:03:51 +01:00
in_pcb.h sockets: don't malloc/free sockaddr memory on getpeername/getsockname 2023-11-30 08:31:10 -08:00
in_pcb_var.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
in_prot.c Fix 'security.bsd.see_jail_proc' by using cr_bsd_visible() 2023-09-28 11:59:08 -03:00
in_proto.c sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
in_rmx.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
in_rss.c sys: Remove $FreeBSD$: two-line .c pattern 2023-08-16 11:54:30 -06:00
in_rss.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
in_systm.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
in_var.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
ip.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
ip6.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
ip_carp.c netlink: move NETLINK define to opt_global.h 2023-10-13 09:23:47 +02:00
ip_carp.h sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
ip_carp_nl.h carp: allow commands to use interface name rather than index 2023-03-31 11:29:58 +02:00
ip_divert.c pf: use an enum for packet direction in divert tag 2023-10-20 09:16:08 +02:00
ip_divert.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
ip_dummynet.h dummynet: add simple gilbert-elliott channel model 2023-12-17 13:20:45 +01:00
ip_ecn.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
ip_ecn.h sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
ip_encap.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
ip_encap.h sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
ip_fastfwd.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
ip_fw.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
ip_gre.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
ip_icmp.c sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
ip_icmp.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
ip_id.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
ip_input.c sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
ip_mroute.c ip_mroute: allow MRT_DEL_MFC even if there are pending upcalls 2023-12-14 22:04:43 +01:00
ip_mroute.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
ip_options.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
ip_options.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
ip_output.c sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
ip_reass.c vnet: (read) lock the vnet list while iterating it 2023-12-07 13:34:47 +01:00
ip_var.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
pim.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
pim_var.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
raw_ip.c sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
sctp.h sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
sctp_asconf.c sctp: cleanup cdefs.h include 2023-08-18 15:25:34 +02:00
sctp_asconf.h sctp: cleanup cdefs.h include 2023-08-18 15:25:34 +02:00
sctp_auth.c sctp: cleanup locking for notifications 2023-09-08 16:20:51 +02:00
sctp_auth.h sctp: cleanup SCTP AUTH related notification 2023-09-08 13:13:43 +02:00
sctp_bsd_addr.c sctp: cleanup cdefs.h include 2023-08-18 15:25:34 +02:00
sctp_bsd_addr.h sctp: cleanup cdefs.h include 2023-08-18 15:25:34 +02:00
sctp_cc_functions.c sctp: cleanup cdefs.h include 2023-08-18 15:25:34 +02:00
sctp_constants.h sctp: make sure all SCTP RESET notifications use sctp_ulp_notify() 2023-09-08 14:19:56 +02:00
sctp_crc32.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
sctp_crc32.h sctp: cleanup cdefs.h include 2023-08-18 15:25:34 +02:00
sctp_header.h sctp: cleanup cdefs.h include 2023-08-18 15:25:34 +02:00
sctp_indata.c sctp: improve handling of socket shutdown for reading 2023-08-24 15:52:55 +02:00
sctp_indata.h sctp: cleanup cdefs.h include 2023-08-18 15:25:34 +02:00
sctp_input.c sctp: make sure all SCTP RESET notifications use sctp_ulp_notify() 2023-09-08 14:19:56 +02:00
sctp_input.h sctp: cleanup cdefs.h include 2023-08-18 15:25:34 +02:00
sctp_kdtrace.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
sctp_kdtrace.h sctp: cleanup cdefs.h include 2023-08-18 15:25:34 +02:00
sctp_lock_bsd.h sctp: cleanup cdefs.h include 2023-08-18 15:25:34 +02:00
sctp_module.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
sctp_os.h sockets: don't malloc/free sockaddr memory on getpeername/getsockname 2023-11-30 08:31:10 -08:00
sctp_os_bsd.h sockets: don't malloc/free sockaddr memory on getpeername/getsockname 2023-11-30 08:31:10 -08:00
sctp_output.c sctp: cleanup cdefs.h include 2023-08-18 15:25:34 +02:00
sctp_output.h sctp: cleanup cdefs.h include 2023-08-18 15:25:34 +02:00
sctp_pcb.c sctp: Various fixes for loader tunables 2023-10-09 12:36:48 +08:00
sctp_pcb.h sctp: cleanup cdefs.h include 2023-08-18 15:25:34 +02:00
sctp_peeloff.c sctp: cleanup cdefs.h include 2023-08-18 15:25:34 +02:00
sctp_peeloff.h sctp: cleanup cdefs.h include 2023-08-18 15:25:34 +02:00
sctp_ss_functions.c sctp: cleanup cdefs.h include 2023-08-18 15:25:34 +02:00
sctp_structs.h sctp: cleanup handling of graceful shutdown of the peer 2023-08-19 12:35:49 +02:00
sctp_syscalls.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
sctp_sysctl.c sctp: minor clean 2023-11-06 11:04:15 +01:00
sctp_sysctl.h sctp: cleanup cdefs.h include 2023-08-18 15:25:34 +02:00
sctp_timer.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
sctp_timer.h sctp: cleanup cdefs.h include 2023-08-18 15:25:34 +02:00
sctp_uio.h sctp: cleanup cdefs.h include 2023-08-18 15:25:34 +02:00
sctp_usrreq.c sockets: don't malloc/free sockaddr memory on getpeername/getsockname 2023-11-30 08:31:10 -08:00
sctp_var.h sockets: don't malloc/free sockaddr memory on getpeername/getsockname 2023-11-30 08:31:10 -08:00
sctputil.c sctp: don't call sctp_ulp_notify() recursively 2023-09-08 21:19:59 +02:00
sctputil.h sctp: make sure all SCTP RESET notifications use sctp_ulp_notify() 2023-09-08 14:19:56 +02:00
siftr.c siftr: refactor batch log processing 2023-12-07 14:48:44 +01:00
tcp.h tcp: for LRD move sysctl from tcp.do_lrd tp tcp.sack.lrd, remove sockopt 2023-11-30 21:11:45 +01:00
tcp_accounting.h Move access to tcp's t_logstate into inline functions and provide new tracepoint and bbpoint capabilities. 2023-03-16 11:43:16 -04:00
tcp_ecn.c sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
tcp_ecn.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
tcp_fastopen.c tcp: Initialize the maximum number of entries in a client cookie cache bucket 2023-09-03 04:34:07 +08:00
tcp_fastopen.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
tcp_fsm.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
tcp_hostcache.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
tcp_hpts.c tcp_hpts: make the module unloadable 2023-12-19 10:21:56 -08:00
tcp_hpts.h tcp_hpts: make the module unloadable 2023-12-19 10:21:56 -08:00
tcp_input.c tcp: always set tcp_tun_port to a correct value 2023-12-19 11:24:17 -08:00
tcp_log_buf.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
tcp_log_buf.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
tcp_lro.c kern/subr_trap.c: repair the HPTS performance hack in userret() 2023-12-04 10:19:46 -08:00
tcp_lro.h hpts/lro: make tcp_lro_flush_tcphpts() and tcp_run_hpts() pointers 2023-12-04 10:19:46 -08:00
tcp_lro_hpts.c tcp_hpts: make the module unloadable 2023-12-19 10:21:56 -08:00
tcp_offload.c tcp_fill_info(): Change lock assertion on INPCB to locked only 2023-08-22 20:33:49 +02:00
tcp_offload.h tcp_fill_info(): Change lock assertion on INPCB to locked only 2023-08-22 20:33:49 +02:00
tcp_output.c tcp: properly unroll sack transmission on tx error with LRD 2023-12-18 13:02:22 +01:00
tcp_pcap.c sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
tcp_pcap.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
tcp_ratelimit.c sys: Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:36 -06:00
tcp_ratelimit.h tcp: Silence a -Wunused-function warning in tcp_ratelimit.h 2023-10-25 10:03:58 -04:00
tcp_reass.c sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
tcp_sack.c tcp: for LRD move sysctl from tcp.do_lrd tp tcp.sack.lrd, remove sockopt 2023-11-30 21:11:45 +01:00
tcp_seq.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
tcp_stats.c sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
tcp_subr.c tcp_hpts: let tcp_hpts_init() set a random CPU only once 2023-12-07 14:41:43 -08:00
tcp_syncache.c tcp: properly initialize LRD while accepting session in syncache 2023-12-02 12:17:01 +01:00
tcp_syncache.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
tcp_timer.c sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
tcp_timer.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
tcp_timewait.c sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
tcp_usrreq.c tcp/hpts: make stacks responsible for clearing themselves out HPTS 2023-12-04 10:19:46 -08:00
tcp_var.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
tcpip.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
toecore.c tcp_fill_info(): Change lock assertion on INPCB to locked only 2023-08-22 20:33:49 +02:00
toecore.h tcp_fill_info(): Change lock assertion on INPCB to locked only 2023-08-22 20:33:49 +02:00
udp.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
udp_usrreq.c sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
udp_var.h sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
udplite.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00