Print this page


Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/devpoll.c
          +++ new/usr/src/uts/common/io/devpoll.c
↓ open down ↓ 667 lines elided ↑ open up ↑
 668  668                          return (EACCES);
 669  669                  }
 670  670  
 671  671                  pcp->pc_pid = curproc->p_pid;
 672  672          }
 673  673  
 674  674          uiosize = uiop->uio_resid;
 675  675          pollfdnum = uiosize / size;
 676  676  
 677  677          /*
 678      -         * For epoll-enabled handles, restrict the allowed write size to 2.
 679      -         * This corresponds to an epoll_ctl(3C) performing an EPOLL_CTL_MOD
 680      -         * operation which is expanded into two operations (DEL and ADD).
 681      -         *
 682      -         * All other operations performed through epoll_ctl(3C) will consist of
 683      -         * a single entry.
 684      -         */
 685      -        if (is_epoll && pollfdnum > 2) {
 686      -                return (EINVAL);
 687      -        }
 688      -
 689      -        /*
 690  678           * We want to make sure that pollfdnum isn't large enough to DoS us,
 691  679           * but we also don't want to grab p_lock unnecessarily -- so we
 692  680           * perform the full check against our resource limits if and only if
 693  681           * pollfdnum is larger than the known-to-be-sane value of UINT8_MAX.
 694  682           */
 695  683          if (pollfdnum > UINT8_MAX) {
 696  684                  mutex_enter(&curproc->p_lock);
 697  685                  if (pollfdnum >
 698  686                      (uint_t)rctl_enforced_value(rctlproc_legacy[RLIMIT_NOFILE],
 699  687                      curproc->p_rctls, curproc)) {
↓ open down ↓ 38 lines elided ↑ open up ↑
 738  726           * other writers in this code.
 739  727           *
 740  728           * Waiting for all readers to drop their references to the dpe is
 741  729           * unecessary since the pollcache itself is protected by pc_lock.
 742  730           */
 743  731          mutex_enter(&dpep->dpe_lock);
 744  732          dpep->dpe_writerwait++;
 745  733          while ((dpep->dpe_flag & DP_WRITER_PRESENT) != 0) {
 746  734                  ASSERT(dpep->dpe_refcnt != 0);
 747  735  
 748      -                /*
 749      -                 * The epoll API does not allow EINTR as a result when making
 750      -                 * modifications to the set of polled fds.  Given that write
 751      -                 * activity is relatively quick and the size of accepted writes
 752      -                 * is limited above to two entries, a signal-ignorant wait is
 753      -                 * used here to avoid the EINTR.
 754      -                 */
 755      -                if (is_epoll) {
 756      -                        cv_wait(&dpep->dpe_cv, &dpep->dpe_lock);
 757      -                        continue;
 758      -                }
 759      -
 760      -                /*
 761      -                 * Non-epoll writers to /dev/poll handles can tolerate EINTR.
 762      -                 */
 763  736                  if (!cv_wait_sig_swap(&dpep->dpe_cv, &dpep->dpe_lock)) {
 764  737                          dpep->dpe_writerwait--;
 765  738                          mutex_exit(&dpep->dpe_lock);
 766  739                          kmem_free(pollfdp, uiosize);
 767  740                          return (EINTR);
 768  741                  }
 769  742          }
 770  743          dpep->dpe_writerwait--;
 771  744          dpep->dpe_flag |= DP_WRITER_PRESENT;
 772  745          dpep->dpe_refcnt++;
↓ open down ↓ 983 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX