Maratyszcza / Maratyszcza/pthreadpool
heap-buffer-overflow in pthreadpool_create()
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 396
- Forks
- 153
- PR merge metrics
- No merged PRs in 30d
Description
see https://issuetracker.google.com/211696118 for the original bug report.
the code's moved about and is at https://github.com/Maratyszcza/pthreadpool/blob/a134dd5d4cee80cce15db81a72e7f929d71dd413/src/memory.c#L27 now, but the bug's still there.
probably wants to be something like this instead:
const size_t threadpool_size;
if (__builtin_mul_overflow(threads_count, sizeof(struct thread_info), &threadpool_size) ||
__builtin_add_overflow(threadpool_size, sizeof(struct pthreadpool), &threadpool_size)) {
return NULL;
}
or the original reporter's
+ if (threads_count > (UINT_MAX - sizeof(struct pthreadpool)) / sizeof(struct thread_info)) {
+ return NULL;
+ }
(which is more conservative because UINT_MAX isn't the right constant on LP64.)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/memory.c at the allocation used by pthreadpool_create(), using the linked commit and original bug report for context. Verify the size calculation for the thread pool and confirm that oversized values are rejected by returning NULL without a heap-buffer-overflow.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100