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

libkmod: Check child range in memory mapped index #167

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libkmod/libkmod-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ static struct index_mm_node *index_mm_read_node(struct index_mm *idx, uint32_t o
first = read_char_mm(&p);
last = read_char_mm(&p);

if (first > last)
Copy link
Contributor

Choose a reason for hiding this comment

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

makes sense, but then now we silently use a corrupted index - modprobe even returns success.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which is also true for first > last or out of memory conditions with failing memory allocations here.

If it's a subtle hint to add error checks of index_mm_read_node callers: Yes, we should do that. ;) Eventually we have to adjust the API though, because index_dump itself returns void.

if (first > last || first < 0 || last < 0)
return NULL;

child_count = last - first + 1;
Expand Down