mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
tty: fix lifetime issue in tty_unregister()
The tty_unregister code removes the tty's vnode from the devfs mappings. This causes a reference to be dropped, which can then cause the tty to be freed and the remaining code in tty_unregister does a UAF. Fix this by holding a reference across the unregister operation.
This commit is contained in:
@@ -581,6 +581,8 @@ tty_t *tty_create(char *name, ttydevicewritefn_t writefn, ttyinactivefn_t inacti
|
|||||||
}
|
}
|
||||||
|
|
||||||
void tty_unregister(tty_t *tty) {
|
void tty_unregister(tty_t *tty) {
|
||||||
|
vnode_t *mastervnode = tty->mastervnode;
|
||||||
|
VOP_HOLD(mastervnode);
|
||||||
devfs_remove(tty->name, DEV_MAJOR_TTY, tty->minor);
|
devfs_remove(tty->name, DEV_MAJOR_TTY, tty->minor);
|
||||||
|
|
||||||
proc_t *foreground = getforeground(tty);
|
proc_t *foreground = getforeground(tty);
|
||||||
@@ -588,6 +590,7 @@ void tty_unregister(tty_t *tty) {
|
|||||||
jobctl_signal(foreground, SIGHUP, NULL);
|
jobctl_signal(foreground, SIGHUP, NULL);
|
||||||
PROC_RELEASE(foreground);
|
PROC_RELEASE(foreground);
|
||||||
}
|
}
|
||||||
|
VOP_RELEASE(mastervnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tty_release(tty_t *tty) {
|
void tty_release(tty_t *tty) {
|
||||||
|
|||||||
Reference in New Issue
Block a user