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
Unknown Object (File)
Sun, Dec 15, 12:32 AM
Unknown Object (File)
Dec 2 2024, 3:38 PM
Unknown Object (File)
Oct 2 2024, 9:55 AM
Unknown Object (File)
Aug 18 2024, 7:10 AM
Unknown Object (File)
Aug 18 2024, 4:23 AM
Unknown Object (File)
Aug 16 2024, 11:21 AM
Unknown Object (File)
Jul 31 2024, 11:47 PM
Unknown Object (File)
Jul 28 2024, 10:03 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