HomeFreeBSD

tty: Avoid leaving dangling pointers in tty_drop_ctty()

Description

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: 1b50b999f9b5 ("tty: implement TIOCNOTTY")
Differential Revision: https://reviews.freebsd.org/D56046

Details

Provenance
markjAuthored on Mar 23 2026, 3:22 PM
Reviewer
rG1b50b999f9b5: tty: implement TIOCNOTTY
Differential Revision
Restricted Differential Revision
Parents
rGe8156a7e5fff: src.conf.5: Regenerate
Branches
Unknown
Tags
Unknown

Event Timeline