-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fixing a buffer overflow bug in FixedBitVector #6715
Conversation
I am just a contributor, but I still can help with failing style checks: ChakraCore/lib/Runtime/Library/JavascriptLibrary.cpp Lines 1 to 5 in 0fc6103
|
…nterpret-casted into a pointer to bigger type, then dereferenced.
5f0cfc0
to
eba54a5
Compare
Hi @MadProbe, thanks for your help. I modified the copyright so I think the build should succeed now. I think I am exempt from adding my name |
eba54a5
to
0c5b376
Compare
Hi @kevcadieux sorry for the slow response; I've had a busy week. Question on saying you're doing this on behalf of microsoft:
|
I work on the MSVC compiler team, and we used open source projects to validate our AddressSanitizer implementation. One of the bugs that were found is in ChakraCore. This PR is just a one off to fix this bug; I am not affiliated with any team at Microsoft that is working on ChakraCore.
Yes, I am providing this fix as an open-source contribution under the MIT license used by ChakraCore. When I say that my change is done on behalf of Microsoft, I only mean that I am a Microsoft employee and that all my work belongs to Microsoft. To keep things simple, I will add my name to the Contributor Agreement. |
The
FixedBitVector
implementation contains a buffer overflow bug where a pointer to type of size 1 is reinterpret-casted into a pointer to a bigger type, and then dereferenced. Dereferencing the pointer to type of size bigger than 1 causes more bytes to be read from the buffer than are available. It looks like the code that was meant to ensure the correct pointer type was used was switching onsizeof(BVUnit::BVUnitTContainer)
instead ofsizeof(Container)
, resulting in using a bigger pointer type whensizeof(BVUnitTContainer)
is bigger than 1 butsizeof(Container)
is 1.This bug was found when building ChakraCore using MSVC with the AddressSanitizer feature turned on. Below is a sample ASan error stack trace: