public inbox for astral-devel@lists.astral-os.org
 help / color / mirror / Atom feed
* [PATCH 0/5] devfs: add anonymous register/remove
@ 2026-10-05 18:01 Matheus
  2026-10-05 18:01 ` [PATCH 1/5] statvfs: handle vnodes without a vfs Matheus
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Matheus @ 2026-10-05 18:01 UTC (permalink / raw)
  To: astral-devel

From: Matheus <matheusuky@gmail.com>

The current pty code uses a very hacky way of handling devfs
registration:

named register -> get device by name -> remove device

This is generally an unclean solution and temporarily leaves a device
name in the tree which any process could open() and interfere. 

Add anonymous operations which work on nodes that are unnamed and
directly return a pointer to the vnode. This still leaves a window which
could be used to access the vnode but it is much smaller and requires a
device node to already be in the filesystem (which needs root anyways).
Then, move the pty implementation to use these new functions.

Also fix a few related issues along the way:
- These new devfs vnodes are tecnically orphaned, so they don't have a
  valid vfs. Doing statvfs on them could crash the system.
- Fix a UAF on VOP_RELEASE, where the NULL could be set after the
  vfs_inactive happens but the lifetime of the object where NULL
  happened might be attached to the vnode lifetime.
- Fix another UAF on tty code: calling devfs_remove() in tty_unregister()
  might cause the tty to be free'd. This results in a possible UAF.

(this is also a test of the mailing list for multi-patch series and the
new @astral-os.org email)

Matheus (5):
  statvfs: handle vnodes without a vfs
  vfs: fix UAF on VOP_RELEASE
  tty: fix lifetime issue in tty_unregister()
  devfs: add anonymous variants to register/remove
  pty: use new anonymous devfs operations

 kernel-src/fs/devfs.c             | 47 ++++++++++++++++++++++++++++++-
 kernel-src/include/kernel/devfs.h |  7 ++++-
 kernel-src/include/kernel/vfs.h   |  9 +++---
 kernel-src/io/pty.c               | 13 +++------
 kernel-src/io/tty.c               |  3 ++
 kernel-src/sys/syscalls/statvfs.c | 10 +++++++
 6 files changed, 74 insertions(+), 15 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-10-05 18:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-05 18:01 [PATCH 0/5] devfs: add anonymous register/remove Matheus
2026-10-05 18:01 ` [PATCH 1/5] statvfs: handle vnodes without a vfs Matheus
2026-10-05 18:01 ` [PATCH 2/5] vfs: fix UAF on VOP_RELEASE Matheus
2026-10-05 18:01 ` [PATCH 3/5] tty: fix lifetime issue in tty_unregister() Matheus
2026-10-05 18:01 ` [PATCH 4/5] devfs: add anonymous variants to register/remove Matheus
2026-10-05 18:01 ` [PATCH 5/5] pty: use new anonymous devfs operations Matheus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox