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: Fix epoll crash on NULL event arg #1259

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

andreittr
Copy link
Contributor

Description of changes

Previously epoll_ctl would crash on EPOLL_CTL_ADD and EPOLL_CTL_MOD if its event arg was NULL.
No global checking is done since event == NULL is a valid case for EPOLL_CTL_DEL.
This change fixes this oversight, safely returning -EFAULT on a NULL arg for the add and mod operations.

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

CONFIG_LIBPOSIX_POLL=y

Test snippet:

int e = epoll_create1(0);
int r = epoll_ctl(e, EPOLL_CTL_ADD, 0, NULL);
assert(r == -EFAULT); /* No segfault should happen */

Previously epoll_ctl would crash on EPOLL_CTL_ADD and EPOLL_CTL_MOD if
its event arg was NULL. No global checking is done since event==NULL is
a valid case for EPOLL_CTL_DEL.
This change fixes this oversight, safely returning -EFAULT on a NULL arg
for the add and mod operations.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
@andreittr andreittr requested a review from a team as a code owner January 11, 2024 16:00
@github-actions github-actions bot added area/lib Internal Unikraft Microlibrary lang/c Issues or PRs to do with C/C++ labels Jan 11, 2024
@razvand razvand requested review from razvanvirtan and removed request for a team January 18, 2024 08:45
@razvand razvand added this to the v0.16.1 (Telesto) milestone Jan 18, 2024
@razvand razvand requested review from mariapana and StefanJum and removed request for razvanvirtan February 1, 2024 05:30
@razvand razvand modified the milestones: v0.17.0 (Calypso), v0.16.2 Feb 1, 2024
Copy link

@mariapana mariapana 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: Maria Pana maria.pana4@gmail.com

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.

Approved-by: Razvan Deaconescu razvand@unikraft.io

@razvand razvand added the merge Label to trigger merge action label Feb 6, 2024
@unikraft-bot unikraft-bot changed the base branch from staging to staging-1259 February 6, 2024 17:18
@unikraft-bot unikraft-bot merged commit 518f884 into unikraft:staging-1259 Feb 6, 2024
13 checks passed
@unikraft-bot unikraft-bot added ci/merged Merged by CI and removed merge Label to trigger merge action labels Feb 6, 2024
unikraft-bot pushed a commit that referenced this pull request Feb 6, 2024
Previously epoll_ctl would crash on EPOLL_CTL_ADD and EPOLL_CTL_MOD if
its event arg was NULL. No global checking is done since event==NULL is
a valid case for EPOLL_CTL_DEL.
This change fixes this oversight, safely returning -EFAULT on a NULL arg
for the add and mod operations.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Maria Pana <maria.pana4@gmail.com>
GitHub-Closes: #1259
@andreittr andreittr deleted the ttr/fix-epoll-null branch February 7, 2024 13:16
SerbanSo pushed a commit to SerbanSo/unikraft-ASLR that referenced this pull request Jun 16, 2024
Previously epoll_ctl would crash on EPOLL_CTL_ADD and EPOLL_CTL_MOD if
its event arg was NULL. No global checking is done since event==NULL is
a valid case for EPOLL_CTL_DEL.
This change fixes this oversight, safely returning -EFAULT on a NULL arg
for the add and mod operations.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Maria Pana <maria.pana4@gmail.com>
GitHub-Closes: unikraft#1259
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/lib Internal Unikraft Microlibrary ci/merged Merged by CI lang/c Issues or PRs to do with C/C++
Projects
Development

Successfully merging this pull request may close these issues.

5 participants