Page MenuHomeFreeBSD

Linux epoll: Check both read and write kqueue events existence in EPOLL_CTL_ADD
ClosedPublic

Authored by wulf on Nov 23 2019, 12:07 PM.
Tags
None
Referenced Files
F81578193: D22515.diff
Thu, Apr 18, 9:55 AM
Unknown Object (File)
Sat, Mar 30, 2:06 PM
Unknown Object (File)
Dec 21 2023, 9:27 PM
Unknown Object (File)
Dec 20 2023, 6:24 AM
Unknown Object (File)
Nov 9 2023, 2:49 PM
Unknown Object (File)
Aug 8 2023, 12:58 AM
Unknown Object (File)
Jul 5 2023, 1:30 PM
Unknown Object (File)
Jun 30 2023, 6:57 AM
Subscribers

Details

Summary

Linux epoll EPOLL_CTL_ADD op handler should always check registration
of both EVFILT_READ and EVFILT_WRITE kevents to deceide if supplied
file descriptor fd is already registered with epoll instance.

Test Plan
/* Sample testcase */

#include <sys/epoll.h> 
#include <assert.h>
#include <stdio.h> 
#include <stdlib.h>
#include <unistd.h>
   
int
main (int argc, char *argv[])
{
        struct epoll_event event;
        int epfd, err;

        epfd = epoll_create1(EPOLL_CLOEXEC);
        assert(epfd);

        event.events = EPOLLIN; 
        err = epoll_ctl(epfd, EPOLL_CTL_ADD, STDIN_FILENO, &event);
        assert(err == 0);

        event.events = EPOLLOUT;
        if (epoll_ctl(epfd, EPOLL_CTL_ADD, STDIN_FILENO, &event) == 0) {
                printf("EPOLL_CTL_ADD (erroneously) succeed\n");
                exit(EXIT_FAILURE);
        }

        printf("ok\n");
        return (EXIT_SUCCESS);
}

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Do you think we could add all of these test cases to the tree somewhere? (Not integrated w/ ATF presumably as we wouldn't have a convenient way to build Linux binaries.)

This revision is now accepted and ready to land.Nov 23 2019, 4:27 PM

Do you think we could add all of these test cases to the tree somewhere?

Good idea. I think we can add other permissive licensed epoll unit tests like https://github.com/jiixyj/epoll-shim/blob/master/test/epoll-test.c and https://github.com/cloudius-systems/osv/blob/master/tests/tst-epoll.cc . I will try to take a look at that.

(Not integrated w/ ATF presumably as we wouldn't have a convenient way to build Linux binaries.)

We can store precompiled i386 or amd64 binaries in VCS like we do with firmware blobs