diff options
| author | Bryan Cantrill <bryan@joyent.com> | 2014-04-29 08:02:44 +0000 |
|---|---|---|
| committer | Bryan Cantrill <bryan@joyent.com> | 2014-04-29 08:02:44 +0000 |
| commit | ed5eb5431dd90bfbd4f7846c63abf835255b336a (patch) | |
| tree | de68bccf0e03bcf545f1ddca8ec1bc341f10c7b7 /usr/src | |
| parent | 3007704e69081040c95079acf761911cf477cba3 (diff) | |
| download | illumos-joyent-ed5eb5431dd90bfbd4f7846c63abf835255b336a.tar.gz | |
OS-2950 epoll pid should not be bound until EPOLL_CTL_ADD
Diffstat (limited to 'usr/src')
| -rw-r--r-- | usr/src/uts/common/io/devpoll.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/usr/src/uts/common/io/devpoll.c b/usr/src/uts/common/io/devpoll.c index 14c2f47fac..3c1e80eb01 100644 --- a/usr/src/uts/common/io/devpoll.c +++ b/usr/src/uts/common/io/devpoll.c @@ -559,11 +559,13 @@ dpopen(dev_t *devp, int flag, int otyp, cred_t *credp) /* * allocate a pollcache skeleton here. Delay allocating bitmap * structures until dpwrite() time, since we don't know the - * optimal size yet. + * optimal size yet. We also delay setting the pid until either + * dpwrite() or attempt to poll on the instance, allowing parents + * to create instances of /dev/poll for their children. */ pcp = pcache_alloc(); dpep->dpe_pcache = pcp; - pcp->pc_pid = curproc->p_pid; + pcp->pc_pid = -1; *devp = makedevice(getmajor(*devp), minordev); /* clone the driver */ mutex_enter(&devpoll_lock); ASSERT(minordev < dptblsize); @@ -604,8 +606,12 @@ dpwrite(dev_t dev, struct uio *uiop, cred_t *credp) mutex_exit(&devpoll_lock); pcp = dpep->dpe_pcache; - if (curproc->p_pid != pcp->pc_pid) - return (EACCES); + if (curproc->p_pid != pcp->pc_pid) { + if (pcp->pc_pid != -1) + return (EACCES); + + pcp->pc_pid = curproc->p_pid; + } if (dpep->dpe_flag & DP_ISEPOLLCOMPAT) { size = sizeof (dvpoll_epollfd_t); @@ -870,8 +876,6 @@ dpioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp, int *rvalp) mutex_exit(&devpoll_lock); ASSERT(dpep != NULL); pcp = dpep->dpe_pcache; - if (curproc->p_pid != pcp->pc_pid) - return (EACCES); mutex_enter(&dpep->dpe_lock); @@ -895,6 +899,13 @@ dpioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp, int *rvalp) return (0); } + if (curproc->p_pid != pcp->pc_pid) { + if (pcp->pc_pid != -1) + return (EACCES); + + pcp->pc_pid = curproc->p_pid; + } + while ((dpep->dpe_flag & DP_WRITER_PRESENT) || (dpep->dpe_writerwait != 0)) { if (!cv_wait_sig_swap(&dpep->dpe_cv, &dpep->dpe_lock)) { |
