OS-5941: epoll should exclude normal files/directories

Details

Issue Type:Bug
Priority:4 - Normal
Status:Resolved
Created at:2017-02-03T21:08:32.000Z
Updated at:2017-03-03T03:27:08.000Z

People

Created by:Patrick Mooney [X]
Reported by:Patrick Mooney [X]
Assigned to:Patrick Mooney [X]

Resolution

Fixed: A fix for this issue is checked into the tree and tested.
(Resolution Date: 2017-03-03T03:27:08.000Z)

Fix Versions

2017-03-16 LIBYAN LOCAL (Release Date: 2017-03-16)

Description

When comparing epoll behavior on Linux to SmartOS/LX, a difference was found in what epoll supports vs poll(2). While poll(2) will happily operate on files and directories, epoll_ctl() excludes both:

Linux:

open("poll.c", O_RDONLY)                = 3
epoll_create1(0)                        = 4
epoll_ctl(4, EPOLL_CTL_ADD, 3, {EPOLLIN|EPOLLOUT, {u32=3, u64=18020514542911491}}) = -1 EPERM (Operation not permitted)
poll([{fd=3, events=POLLIN|POLLOUT}], 1, 0) = 1 ([{fd=3, revents=POLLIN|POLLOUT}])
open(".", O_RDONLY|O_DIRECTORY)         = 3
epoll_create1(0)                        = 4
epoll_ctl(4, EPOLL_CTL_ADD, 3, {EPOLLIN|EPOLLOUT, {u32=3, u64=18020514542911491}}) = -1 EPERM (Operation not permitted)
poll([{fd=3, events=POLLIN|POLLOUT}], 1, 0) = 1 ([{fd=3, revents=POLLIN|POLLOUT}])

SmartOS:

open("poll.c", O_RDONLY)                = 3
epoll_create1(0)                        = 4
epoll_ctl(4, EPOLL_CTL_ADD, 3, {EPOLLIN|EPOLLOUT, {u32=3, u64=3}}) = 0
poll([{fd=3, events=POLLIN|POLLOUT}], 1, 0) = 1 ([{fd=3, revents=POLLIN|POLLOUT}])
open(".", O_RDONLY|O_DIRECTORY)         = 3
epoll_create1(0)                        = 4
epoll_ctl(4, EPOLL_CTL_ADD, 3, {EPOLLIN|EPOLLOUT, {u32=3, u64=3}}) = 0
poll([{fd=3, events=POLLIN|POLLOUT}], 1, 0) = 1 ([{fd=3, revents=POLLIN|POLLOUT}])

Comments

Comment by Patrick Mooney [X]
Created at 2017-02-24T21:22:34.000Z

Test results with suggested wad applied:

test_create     0       TPASS
test_create     1       TPASS
test_create     2       TPASS
test_depth1     0       TPASS
test_depth1     1       TPASS
test_depth1     2       TPASS
test_depth1     3       TPASS
test_depth1     4       TPASS
test_depth1     5       TPASS
test_depth1     6       TPASS
test_depth2     0       TBROK: too deep: Success
test_dir        0       TPASS
test_dir        1       TPASS
test_et 0       TPASS
test_et 1       TPASS
test_et 2       TPASS
test_et 3       TPASS
test_et 4       TPASS
test_et 5       TPASS
test_et 6       TPASS
test_file       0       TPASS
test_file       1       TPASS
test_loop       0       TFAIL: 22 != 40
test_nested     0       TPASS
test_nested     1       TPASS
test_nested     2       TPASS
test_nested     3       TPASS
test_nested     4       TPASS
test_nested     5       TPASS
test_nested     6       TPASS
test_nested     7       TPASS
test_nested_et  0       TPASS
test_nested_et  1       TPASS
test_nested_et  2       TPASS
test_nested_et  3       TPASS
test_nested_et  4       TPASS
test_nested_et  5       TPASS
test_nested_et  6       TPASS
test_nested_et  7       TPASS
test_nested_et  8       TPASS
test_nested_et  9       TPASS
test_nested_et  10      TPASS
test_timeout    0       TPASS
test_timeout    1       TPASS
test_timeout    2       TPASS
test_timeout    3       TPASS
test_timeout    4       TPASS
test_timeout    5       TPASS
test_timeout    6       TPASS
test_timeout    7       TPASS
test_timeout    8       TPASS
test_timeout    9       TPASS
test_timeout    10      TPASS
test_timeout    11      TPASS
test_timeout    12      TPASS

The test_depth2 failure is an existing known problem with illumos epoll. The test_loop failure is also pre-existing and will be addressed in a follow-up patch.


Comment by Patrick Mooney [X]
Created at 2017-03-02T00:35:37.000Z

On a PI with this wad, I tested non-epoll /dev/poll (and poll(2)) against normal files to ensure that their behavior hadn't changed. It all performed as expected with poll/devpoll resulting in proper events and epoll rejecting the request with EPERM.


Comment by Bot Bot [X]
Created at 2017-03-02T20:52:07.000Z

illumos-joyent commit 8a54bd0 (branch master, by Patrick Mooney)

OS-5941 epoll should exclude normal files/directories
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Robert Mustacchi <rm@joyent.com>