Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/posix-poll: Make epoll_ctl identify files by (fd + file description) #1198

Merged
merged 2 commits into from Dec 13, 2023

Conversation

andreittr
Copy link
Contributor

@andreittr andreittr commented Dec 11, 2023

Description of changes

Previously epoll_ctl would identify epoll entries by fd alone, in accordance with published documentation (see epoll_ctl(2)).
However, the Linux kernel actually identifies entries by a tuple of (fd, file description) instead, a behavior on which some applications mistakenly depend.
In order to support these applications we have to mimic this behavior.

This changeset implements the above described identification of files, along with relevant cleanup of epoll_ctl-related code.
In addition, the first commit in the PR fixes an omission whereby epoll_ctl would fail to lookup the fd when Unikraft is configured without the legacy vfscore.

Prerequisite checklist

  • Read the contribution guidelines regarding submitting new changes to the project;
  • Tested your changes against relevant architectures and platforms;
  • Ran the checkpatch.uk on your commit series before opening this PR;
  • Updated relevant documentation.

Base target

  • Architecture(s): N/A
  • Platform(s): N/A
  • Application(s): N/A

Additional configuration

Should work with or without CONFIG_LIBVFSCORE.

Previously, when compiling without CONFIG_LIBVFSCORE, epoll_ctl would
fail to lookup the file descriptor, leading to the use of uninitialized
memory.
This change fixes this omission, adding lookup code for pure newvfs
configurations.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Previously epoll_ctl would identify epoll entries by fd alone, in
accordance with published documentation (see epoll_ctl(2)).
However, the Linux kernel actually identifies entries by a tuple of
(fd, file description) instead, a behavior on which some applications
mistakenly depend. In order to support these applications we have to
mimic this behavior.
This change implements the above described identification of files,
along with relevant cleanup of epoll_ctl-related code.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
@andreittr andreittr requested a review from a team as a code owner December 11, 2023 15:23
@razvand razvand removed the request for review from a team December 13, 2023 21:46
@razvand razvand added area/lib Internal Unikraft Microlibrary kind/quick-fix Issue is a quick fix lib/vfscore VFS Core Interface lang/c Issues or PRs to do with C/C++ labels Dec 13, 2023
@razvand razvand added this to the v0.16.0 (Telesto) milestone Dec 13, 2023
Copy link
Contributor

@razvand razvand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed-by: Razvan Deaconescu razvand@unikraft.io
Approved-by: Razvan Deaconescu razvand@unikraft.io

@razvand razvand merged commit 8db347a into unikraft:staging Dec 13, 2023
8 checks passed
razvand pushed a commit that referenced this pull request Dec 13, 2023
Previously, when compiling without CONFIG_LIBVFSCORE, epoll_ctl would
fail to lookup the file descriptor, leading to the use of uninitialized
memory.
This change fixes this omission, adding lookup code for pure newvfs
configurations.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1198
razvand pushed a commit that referenced this pull request Dec 13, 2023
Previously epoll_ctl would identify epoll entries by fd alone, in
accordance with published documentation (see epoll_ctl(2)).
However, the Linux kernel actually identifies entries by a tuple of
(fd, file description) instead, a behavior on which some applications
mistakenly depend. In order to support these applications we have to
mimic this behavior.
This change implements the above described identification of files,
along with relevant cleanup of epoll_ctl-related code.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1198
@andreittr andreittr deleted the ttr/fix-epollfd branch January 16, 2024 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/lib Internal Unikraft Microlibrary kind/quick-fix Issue is a quick fix lang/c Issues or PRs to do with C/C++ lib/vfscore VFS Core Interface
Projects
Status: Done!
Development

Successfully merging this pull request may close these issues.

None yet

2 participants