Allow TIOCSCTTY on tty devices, if the pledge says "tty id"
authorderaadt <deraadt@openbsd.org>
Sat, 17 Oct 2015 22:58:30 +0000 (22:58 +0000)
committerderaadt <deraadt@openbsd.org>
Sat, 17 Oct 2015 22:58:30 +0000 (22:58 +0000)
worked out with nicm

sys/kern/kern_pledge.c

index a155f22..08329c0 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: kern_pledge.c,v 1.43 2015/10/17 22:54:23 deraadt Exp $        */
+/*     $OpenBSD: kern_pledge.c,v 1.44 2015/10/17 22:58:30 deraadt Exp $        */
 
 /*
  * Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
@@ -1103,6 +1103,11 @@ pledge_ioctl_check(struct proc *p, long com, void *v)
                                return (0);
                        break;
 #endif
+               case TIOCSCTTY:         /* tmux etc */
+                       if ((p->p_p->ps_pledge & PLEDGE_ID) == 0 &&
+                           fp->f_type == DTYPE_VNODE && (vp->v_flag & VISTTY))
+                               return (0);
+                       break;
                case TIOCSPGRP:
                        if ((p->p_p->ps_pledge & PLEDGE_PROC) == 0)
                                break;