opnsense-src/tests/sys/kern
Mark Johnston e1ed334011 tty: Avoid leaving dangling pointers in tty_drop_ctty()
The TIOCNOTTY handler detaches the calling process from its controlling
terminal.  It clears the link from the session to the tty, but not the
pointers from the tty to the session and process group.  This means that
sess_release() doesn't call tty_rel_sess(), and that pgdelete() doesn't
call tty_rel_pgrp(), so the pointers are left dangling.

Fix this by clearing pointers in tty_drop_ctty().  Add a standalone
regression test.

Approved by:	so
Security:	FreeBSD-SA-26:10.tty
Security:	CVE-2026-5398
Reported by:	Nicholas Carlini <npc@anthropic.com>
Reviewed by:	kib, kevans
Fixes:		1b50b999f9 ("tty: implement TIOCNOTTY")
Differential Revision:	https://reviews.freebsd.org/D56046
2026-04-29 22:12:55 +02:00
..
acct Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
execve Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
pipe Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
basic_signal.c Reenable basic_signal:trap_signal_test on i386 2022-08-25 12:09:00 +08:00
coredump_phnum_helper.c Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
coredump_phnum_test.sh Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
fdgrowtable_test.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
jail_lookup_root.c tests: Add a regression test for commit 7587f6d484 2026-01-28 07:36:32 +01:00
kcov.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
kern_copyin.c Remove "All Rights Reserved" from FreeBSD Foundation copyrights 2024-08-06 15:39:53 -04:00
kern_descrip_test.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
kill_zombie.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
ktls_test.c ktls: Fix races that can lead to double initialization 2024-07-23 09:01:30 -04:00
ktrace_test.c ktrace tests: Add a test case for handling of exec+setuid binaries 2024-08-15 14:29:49 +00:00
libkern_crc32.c Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
Makefile tty: Avoid leaving dangling pointers in tty_drop_ctty() 2026-04-29 22:12:55 +02:00
Makefile.depend Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
Makefile.inc Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
module_test.c module_test: Fix some assignments to errno intended to be tests. 2022-03-14 14:05:05 -07:00
pdeathsig.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
pdeathsig_helper.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
ptrace_test.c ptrace_test: add test for expanded reporting of syscall args 2025-04-07 04:28:23 +03:00
reaper.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
sched_affinity.c sched tests: Avoid underflow when maxcpuid == 0 2024-07-21 20:55:27 -04:00
sendfile_helper.c Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
sendfile_test.sh Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
sigaltstack.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
sigsys.c tests/sigsys: initialize parameter passed to sysctlbyname() 2025-02-10 00:36:24 +08:00
sigwait.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
socket_accf.c tests/socket: add accept_filter(9) test 2022-08-08 14:10:18 -07:00
socket_msg_trunc.c socket tests: Build fix 2023-10-24 10:28:11 -04:00
socket_msg_waitall.c socket tests: Add a regression test for MSG_WAITALL 2023-09-27 08:33:24 -04:00
socket_splice.c SO_SPLICE tests: Fix a comment typo 2025-01-14 14:14:24 +00:00
sonewconn_overflow.py Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
sonewconn_overflow.sh Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
subr_physmem_test.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
sys_getrandom.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
sysctl_kern_proc.c spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
tiocnotty.c tty: Avoid leaving dangling pointers in tty_drop_ctty() 2026-04-29 22:12:55 +02:00
tty_pts.c kern: pts: do not special case closed slave side 2024-01-30 11:11:24 -06:00
unix_dgram.c unix: Add support for atomically setting the socket mode 2024-12-03 01:03:26 +00:00
unix_passfd_dgram.c tests/unix_passfd: compile SOCK_STREAM and SOCK_DGRAM versions 2022-06-24 09:09:11 -07:00
unix_passfd_stream.c tests/unix_passfd: compile SOCK_STREAM and SOCK_DGRAM versions 2022-06-24 09:09:11 -07:00
unix_passfd_test.c unix/tests: Add a regression test for fd transfer across jails 2026-02-24 19:22:12 +01:00
unix_seqpacket_test.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
unix_socketpair_test.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
waitpid_nohang.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00