Print this page
8634 epoll fails to wake on certain edge-triggered conditions
8635 epoll should not emit POLLNVAL
8636 recursive epoll should emit EPOLLRDNORM
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Igor Kozhukhov <igor@dilos.org>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/bpf/bpf.c
          +++ new/usr/src/uts/common/io/bpf/bpf.c
↓ open down ↓ 32 lines elided ↑ open up ↑
  33   33   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  34   34   * SUCH DAMAGE.
  35   35   *
  36   36   *      @(#)bpf.c       8.4 (Berkeley) 1/9/95
  37   37   * static char rcsid[] =
  38   38   * "Header: bpf.c,v 1.67 96/09/26 22:00:52 leres Exp ";
  39   39   */
  40   40  /*
  41   41   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  42   42   * Use is subject to license terms.
       43 + * Copyright 2017 Joyent, Inc.
  43   44   */
  44   45  
  45   46  /*
  46   47   * The BPF implements the following access controls for zones attempting
  47   48   * to read and write data. Writing of data requires that the net_rawaccess
  48   49   * privilege is held whilst reading data requires either net_rawaccess or
  49   50   * net_observerability.
  50   51   *
  51   52   *                              | Shared |  Exclusive |   Global
  52   53   * -----------------------------+--------+------------+------------+
↓ open down ↓ 1336 lines elided ↑ open up ↑
1389 1390                  mutex_exit(&d->bd_lock);
1390 1391                  return (EINVAL);
1391 1392          }
1392 1393  
1393 1394          (void) strlcpy(buffer, d->bd_ifname, bufsize);
1394 1395          mutex_exit(&d->bd_lock);
1395 1396  
1396 1397          return (0);
1397 1398  }
1398 1399  
1399      -/*
1400      - * Support for poll() system call
1401      - *
1402      - * Return true iff the specific operation will not block indefinitely - with
1403      - * the assumption that it is safe to positively acknowledge a request for the
1404      - * ability to write to the BPF device.
1405      - * Otherwise, return false but make a note that a selnotify() must be done.
1406      - */
     1400 +/* ARGSUSED */
1407 1401  int
1408 1402  bpfchpoll(dev_t dev, short events, int anyyet, short *reventsp,
1409 1403      struct pollhead **phpp)
1410 1404  {
1411 1405          struct bpf_d *d = bpf_dev_get(getminor(dev));
1412 1406  
     1407 +        /*
     1408 +         * Until this driver is modified to issue proper pollwakeup() calls on
     1409 +         * its pollhead, edge-triggered polling is not allowed.
     1410 +         */
     1411 +        if (events & POLLET) {
     1412 +                return (EPERM);
     1413 +        }
     1414 +
1413 1415          if (events & (POLLIN | POLLRDNORM)) {
1414 1416                  /*
1415 1417                   * An imitation of the FIONREAD ioctl code.
1416 1418                   */
1417 1419                  mutex_enter(&d->bd_lock);
1418 1420                  if (d->bd_hlen != 0 ||
1419 1421                      ((d->bd_immediate || d->bd_state == BPF_TIMED_OUT) &&
1420 1422                      d->bd_slen != 0)) {
1421 1423                          *reventsp |= events & (POLLIN | POLLRDNORM);
1422 1424                  } else {
     1425 +                        /*
     1426 +                         * Until the bpf driver has been updated to include
     1427 +                         * adequate pollwakeup() logic, no pollhead will be
     1428 +                         * emitted here, preventing the resource from being
     1429 +                         * cached by poll()/devpoll/epoll.
     1430 +                         */
1423 1431                          *reventsp = 0;
1424      -                        if (!anyyet)
1425      -                                *phpp = &d->bd_poll;
1426 1432                          /* Start the read timeout if necessary */
1427 1433                          if (d->bd_rtout > 0 && d->bd_state == BPF_IDLE) {
1428 1434                                  bpf_clear_timeout(d);
1429 1435                                  /*
1430 1436                                   * Only allow the timeout to be set once.
1431 1437                                   */
1432 1438                                  if (d->bd_callout == 0)
1433 1439                                          d->bd_callout = timeout(bpf_timed_out,
1434 1440                                              d, d->bd_rtout);
1435 1441                                  d->bd_state = BPF_WAITING;
↓ open down ↓ 458 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX