Project

General

Profile

Bug #7506

epoll_create1 should toss EINVAL for invalid flags

Added by Adam Števko over 2 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Category:
lib - userland libraries
Start date:
2016-10-25
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:

Description

While compiling Python 3.5 and running test suite, one test in test_epoll.py fails (
https://github.com/python/cpython/blob/3.5/Lib/test/test_epoll.py#L80):

        if hasattr(select, "EPOLL_CLOEXEC"):
            select.epoll(select.EPOLL_CLOEXEC).close()
            self.assertRaises(OSError, select.epoll, flags=12356)

When digging into the issue, I tried to run the code on both Linux and illumos (fresh OpenIndiana):

https://gist.github.com/xen0l/2792654274bc57470cb1b4217eaf76d9

When stracing on Linux, I see:

epoll_create1(EPOLL_CLOEXEC|0x1e240)    = -1 EINVAL (Invalid argument)

but nothing similar happens on illumos.

Digging deeper in the source code, we are missing a check for flags arguments as in Linux:
http://src.illumos.org/source/xref/linux-master/fs/eventpoll.c#1802

Our man pages also states:

 The epoll_create() and epoll_create1() functions will fail if:

       EINVAL
                 Either the size is zero (epoll_create()) or the flags are
                 invalid (epoll_create1()).

However, the reality is that epoll_create1 doesn't return EINVAL.

Our epoll_create should just behave the same as on Linux.

History

#1

Updated by Patrick Mooney over 2 years ago

  • Assignee changed from Robert Mustacchi to Patrick Mooney

Just to confirm: Your test was performed in a native illumos zone (or the GZ), not an LX-branded zone, right?

#2

Updated by Adam Števko over 2 years ago

Yes, it was tested on OpenIndiana with latest illumos bits compiled and run in both NGZ and GZ.

#3

Updated by Robert Mustacchi over 2 years ago

  • Subject changed from LX epoll_create behaviour is different from Linux to epoll_create1 should toss EINVAL for invalid flags
  • Category set to lib - userland libraries
  • % Done changed from 0 to 100
  • Tags deleted (needs-triage)
#4

Updated by Electric Monk over 2 years ago

  • Status changed from New to Closed

git commit a192d1c0eb1d05a03ead3c7f898e864e4bf0399c

commit  a192d1c0eb1d05a03ead3c7f898e864e4bf0399c
Author: Patrick Mooney <pmooney@pfmooney.com>
Date:   2016-11-17T15:12:22.000Z

    7506 epoll_create1 should toss EINVAL for invalid flags
    Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
    Reviewed by: Robert Mustacchi <rm@joyent.com>
    Approved by: Dan McDonald <danmcd@omniti.com>

Also available in: Atom PDF