⬢ DragonFlyBSD Kernel Audit
DF-4749 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/misc/nmdm/nmdm.c
+++ b/sys/dev/misc/nmdm/nmdm.c
@@ -36,6 +36,7 @@
  */
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/jail.h>
 #include <sys/uio.h>
 #include <sys/proc.h>
 #include <sys/caps.h>
@@ -196,6 +197,11 @@
 
 	if ((tp->t_state & TS_ISOPEN) == 0) {
 		ttychars(tp);		/* Set up default chars */
+		if (pti->pt_prison == NULL && ap->a_cred->cr_prison != NULL) {
+			/* Pin the pair to the prison that opened it first */
+			prison_hold(ap->a_cred->cr_prison);
+			pti->pt_prison = ap->a_cred->cr_prison;
+		}
 		tp->t_iflag = TTYDEF_IFLAG;
 		tp->t_oflag = TTYDEF_OFLAG;
 		tp->t_lflag = TTYDEF_LFLAG;