-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix bugs reported by asan #5665
Fix bugs reported by asan #5665
Conversation
dbcfeb9
to
04ac5d2
Compare
Issue highlighted by PR osquery#5628 Do not take a reference of a string which is owned by a temporary, copy it instead. PR: osquery#5665
Issue highlighted by asan activated in PR osquery#5628 Do not use clear() on a vector inizialized with a fixed size to clear it of its contents when using it as a char buffer. PR: osquery#5665
Issue highlighted by asan activated in PR osquery#5628 Do not use memcpy to copy strings around. Also, ifa_name size is not guaranteed to be IFNAMSIZ. PR: osquery#5665
Issue highlighted by asan activated in PR osquery#5628 Reading a 8 byte field from a 4 byte aligned struct needs to be done with memcpy. PR: osquery#5665
Issue highlighted by asan activated in PR osquery#5628 Do not try to read the destination address of a netmask if such address is a default route. PR: osquery#5665
Issue highlighted by asan activated in PR osquery#5628 When shifting left or right a byte, that must be positive, so ensure it is. Light cleanup of a bugged and unused function. A deeper look into the table implementation is needed. PR: osquery#56658000 div>
Issue highlighted by asan activated in PR osquery#5628 Imprecisions between float -> double -> json -> double -> float lead to out of range values been saved into a float variable. Since json has only the notion of doubles as floating point numbers, it's better to require to use them. Also forced the json parser to parse floating point numbers with full precision, otherwise the test testing for precision would fail. PR: osquery#5665
Issue highlighted by asan activated in PR osquery#5628 StatusLogLine needs to be initialized before using it. PR: osquery#5665
Issue highlighted by asan activated in PR osquery#5628 EFI_DEVICE_PATH_PROTOCOL and HARDDRIVE_DEVICE_PATH were using the wrong alignment/padding, since on disk they are written with no padding. PR: osquery#5665
…rcularBuffer Issue highlighted by asan activated in PR osquery#5628 Ensure WrappedMessage has no padding since its members are written consecutively in the buffer. Also use memcpy when retrieving a WrappedMessage from a buffer, since it could be written at a misaligned address. PR: osquery#5665
So, I fixed all the bugs that could be fixed without heavy refactoring. I think the review of this PR has to be done in two phases:
I will open an issue about the undefined behaviors in the pub/sub. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting in the work and investigation here. I like the plan!
How’s this progressing, any updates? |
The PR for me and for now is "ready"; I just need to remove the commit that enabled Asan, which I'll do in a few. I'm still focusing on the toolchain and as mentioned previously, the UB in the Pub/Sub needs some refactoring, so that should be done later. |
Issue highlighted by PR osquery#5628 Do not take a reference of a string which is owned by a temporary, copy it instead. PR: osquery#5665
Issue highlighted by asan activated in PR osquery#5628 Do not use clear() on a vector inizialized with a fixed size to clear it of its contents when using it as a char buffer. PR: osquery#5665
Issue highlighted by asan activated in PR osquery#5628 Do not use memcpy to copy strings around. Also, ifa_name size is not guaranteed to be IFNAMSIZ. PR: osquery#5665
Issue highlighted by asan activated in PR osquery#5628 Reading a 8 byte field from a 4 byte aligned struct needs to be done with memcpy. PR: osquery#5665
Issue highlighted by asan activated in PR osquery#5628 Do not try to read the destination address of a netmask if such address is a default route. PR: osquery#5665
Issue highlighted by asan activated in PR osquery#5628 When shifting left or right a byte, that must be positive, so ensure it is. Light cleanup of a bugged and unused function. A deeper look into the table implementation is needed. PR: osquery#5665
Issue highlighted by asan activated in PR osquery#5628 Imprecisions between float -> double -> json -> double -> float lead to out of range values been saved into a float variable. Since json has only the notion of doubles as floating point numbers, it's better to require to use them. Also forced the json parser to parse floating point numbers with full precision, otherwise the test testing for precision would fail. PR: osquery#5665
Issue highlighted by asan activated in PR osquery#5628 StatusLogLine needs to be initialized before using it. PR: osquery#5665
Issue highlighted by asan activated in PR osquery#5628 EFI_DEVICE_PATH_PROTOCOL and HARDDRIVE_DEVICE_PATH were using the wrong alignment/padding, since on disk they are written with no padding. PR: osquery#5665
…rcularBuffer Issue highlighted by asan activated in PR osquery#5628 Ensure WrappedMessage has no padding since its members are written consecutively in the buffer. Also use memcpy when retrieving a WrappedMessage from a buffer, since it could be written at a misaligned address. PR: osquery#5665
04ac5d2
to
60844f8
Compare
Issue highlighted by asan activated in PR #5628 Imprecisions between float -> double -> json -> double -> float lead to out of range values been saved into a float variable. Since json has only the notion of doubles as floating point numbers, it's better to require to use them. Also forced the json parser to parse floating point numbers with full precision, otherwise the test testing for precision would fail. PR: #5665
Work in progress to fix the bugs reported by Asan, as initially reported by #5628.
Some of them will probably require a refactor of the publisher/subscriber framework though, so we need to decide what to do with them and when to actually enable Asan in the CI builds.
This PR temporarily enable Asan which will be removed when before merging.