Bug 252582 - Linuxulator: epoll create drop user data
Summary: Linuxulator: epoll create drop user data
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-emulation (Nobody)
URL:
Keywords:
Depends on:
Blocks: 247219
  Show dependency treegraph
 
Reported: 2021-01-11 16:11 UTC by shu
Modified: 2021-01-14 21:22 UTC (History)
3 users (show)

See Also:


Attachments
patch for epoll create (362 bytes, patch)
2021-01-11 16:11 UTC, shu
no flags Details | Diff
patch for linux epoll create (894 bytes, patch)
2021-01-11 16:24 UTC, shu
no flags Details | Diff
drop_epoll_data.patch (7.18 KB, patch)
2021-01-13 00:53 UTC, Vladimir Kondratyev
no flags Details | Diff
epoll test code (619 bytes, text/plain)
2021-01-14 03:29 UTC, shu
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description shu 2021-01-11 16:11:03 UTC
Created attachment 221464 [details]
patch for epoll create

In function epoll_create_common calls epoll_fd_install when kern_kqueue success,
I guess this is to initialize the proc emuldata space.
But when epoll has allocated a descriptor equal to EPOLL_DEF_SZ, the above action will clear the user data of fd EPOLL_DEF_SZ.This should be an error.

static int
epoll_create_common(struct thread *td, int flags)
{
        int error;
 
        error = kern_kqueue(td, flags, NULL);
        if (error != 0)
                return (error);
 
        epoll_fd_install(td, EPOLL_DEF_SZ, 0);
 
        return (0);
}

In my scenario, the function epoll_fd_install will cause the electron gpu thread consumes a lot of cpu resources because the returned fd cannot be processed correctly.
My patch is in the attachment.
Comment 1 shu 2021-01-11 16:24:46 UTC
Created attachment 221465 [details]
patch for linux epoll create
Comment 2 Vladimir Kondratyev freebsd_committer 2021-01-13 00:53:40 UTC
Created attachment 221517 [details]
drop_epoll_data.patch

Could you test this patch instead of your?
Comment 3 shu 2021-01-14 03:29:14 UTC
Created attachment 221549 [details]
epoll test code
Comment 4 shu 2021-01-14 03:30:19 UTC
Tested already, it works fine for me.
Test case is in the attachment.
Comment 5 Vladimir Kondratyev freebsd_committer 2021-01-14 21:22:00 UTC
https://reviews.freebsd.org/D28169