summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2015-10-17 23:01:37 +0000
committerderaadt <deraadt@openbsd.org>2015-10-17 23:01:37 +0000
commitac9ffc7a1e5e75f3798c64c67936ee67042823da (patch)
tree6e53b0505bf40550068c242ff30856dfa663c866
parentAllow TIOCSCTTY on tty devices, if the pledge says "tty id" (diff)
downloadwireguard-openbsd-ac9ffc7a1e5e75f3798c64c67936ee67042823da.tar.xz
wireguard-openbsd-ac9ffc7a1e5e75f3798c64c67936ee67042823da.zip
Unify TIOCGPGRP/TIOCGWINSZ/TIOCGWINSZ behaviour regarding ENOTTY return.
(both "tty" and "ioctl" allow these; they should behave the same)
-rw-r--r--sys/kern/kern_pledge.c11
1 files 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 <nicm@openbsd.org>
@@ -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);