On Mon, Jan 18, 2016 at 12:55:30PM +0100, Alexandre Ratchov wrote: > If a usb audio device is disconnected, the device vnode is closed > and replaced by a deadfs vnode, of type VBAD. The sndiod process > still has a descriptor in use for which any ioctl() fails. It's > supposed to get the return value, notice the error and close the > file descriptor. > > Unfortunately, if pledge is used, pledge_ioctl() checks if the > vnode type is VCHR and the process ends up killed. > > The diff below fixes this by accepting the audio ioctls if the > vnode type is VBAD. >
As usb disks and ttys could be disconnected as well, I'm tempted to make the check for all ioctls. Opinions? Index: kern_pledge.c =================================================================== RCS file: /cvs/src/sys/kern/kern_pledge.c,v retrieving revision 1.146 diff -u -p -u -p -r1.146 kern_pledge.c --- kern_pledge.c 9 Jan 2016 06:13:43 -0000 1.146 +++ kern_pledge.c 18 Jan 2016 11:52:23 -0000 @@ -1149,8 +1149,11 @@ pledge_ioctl(struct proc *p, long com, s } /* fp != NULL was already checked */ - if (fp->f_type == DTYPE_VNODE) + if (fp->f_type == DTYPE_VNODE) { vp = fp->f_data; + if (vp->v_type == VBAD) + return (0); + } /* * Further sets of ioctl become available, but are checked a