From ac9ffc7a1e5e75f3798c64c67936ee67042823da Mon Sep 17 00:00:00 2001 From: deraadt Date: Sat, 17 Oct 2015 23:01:37 +0000 Subject: [PATCH] Unify TIOCGPGRP/TIOCGWINSZ/TIOCGWINSZ behaviour regarding ENOTTY return. (both "tty" and "ioctl" allow these; they should behave the same) --- sys/kern/kern_pledge.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/sys/kern/kern_pledge.c b/sys/kern/kern_pledge.c index 08329c03a61..c08bf63c276 100644 --- a/sys/kern/kern_pledge.c +++ b/sys/kern/kern_pledge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_pledge.c,v 1.44 2015/10/17 22:58:30 deraadt Exp $ */ +/* $OpenBSD: kern_pledge.c,v 1.45 2015/10/17 23:01:37 deraadt Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott @@ -1055,14 +1055,11 @@ pledge_ioctl_check(struct proc *p, long com, void *v) if ((p->p_p->ps_pledge & PLEDGE_IOCTL)) { switch (com) { case TIOCGETA: - if (fp->f_type == DTYPE_VNODE && (vp->v_flag & VISTTY)) - return (0); - return (ENOTTY); case TIOCGPGRP: - case TIOCGWINSZ: /* various programs */ + case TIOCGWINSZ: /* ENOTTY for return for non-tty */ if (fp->f_type == DTYPE_VNODE && (vp->v_flag & VISTTY)) return (0); - break; + return (ENOTTY); case BIOCGSTATS: /* bpf: tcpdump privsep on ^C */ if (fp->f_type == DTYPE_VNODE && fp->f_ops->fo_ioctl == vn_ioctl) @@ -1114,7 +1111,7 @@ pledge_ioctl_check(struct proc *p, long com, void *v) /* FALLTHROUGH */ case TIOCGPGRP: case TIOCGETA: - case TIOCGWINSZ: /* various programs */ + case TIOCGWINSZ: /* ENOTTY for return for non-tty */ if (fp->f_type == DTYPE_VNODE && (vp->v_flag & VISTTY)) return (0); return (ENOTTY); -- 2.20.1