Skip to content

Conversation

@penguin359
Copy link
Contributor

The fd_set macros don't check for overflow and will cause an
out-of-bounds access when given a file description >= FD_SETSIZE (1024)

This is to address issue #118 which originally reported this crash. Ultimately, we should switch to using either poll() or epoll() for handling file descriptor events, but this PR will at least prevent lldpad from a crash when used with a large (> ~500) interfaces. Some interfaces will fail to operate correctly, but this at least allows for partial functionality until the full fix can be included.

The fd_set macros don't check for overflow and will cause an
out-of-bounds access when given a file description >= FD_SETSIZE (1024)

This doesn't fix the fundamental issue, but prevents a crash and should
allow partial functionality. The full fix requires switching to poll()
instead.
Copy link
Contributor Author

@penguin359 penguin359 left a comment

Choose a reason for hiding this comment

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

Hmm, seems I am still unable to assign this to @apconole for a review.

@penguin359 penguin359 self-assigned this Dec 27, 2024
@penguin359 penguin359 added the bug label Dec 27, 2024
@apconole apconole self-assigned this Jan 8, 2025
return;

if (sock >= FD_SETSIZE) {
warn_too_many_fds();
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm okay with this being added, but a quick grep through the code doesn't seem to find any in-tree callers for eloop_wait_for_read_sock.

Maybe we should delete it instead?

Copy link
Contributor Author

@penguin359 penguin359 Jan 17, 2025

Choose a reason for hiding this comment

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

Yes, I only see eloop_register_read_sock() and eloop_unregister_read_sock() used, but not eloop_wait_for_read_sock(). Also, it looks like eloop_register_sock(), eloop_unregister_sock(), and os_get_time() can all be made static.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I found several things to clean-up in eloop.c/eloop.h including function prototypes in the header files that refer to functions that have never existed in the Git history. I'll save that clean-up for another PR, but I think I can drop that function for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you are okay with it, I'll merge this patch and backport it to the 1.1 branch.

@apconole
Copy link
Contributor

Merged and backported. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants