-
Notifications
You must be signed in to change notification settings - Fork 382
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 memory corruption bug #1090
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Close fds in case of returning with an error. Signed-off-by: Kornilios Kourtis <[email protected]>
runtime.NumCPU() returns the number of CPUs available to the process. This excludes offline CPUs, but also does not take into acount task CPU affinity. For example: ``` $ cat numcpus.go package main import ( "fmt" "runtime" ) func main() { fmt.Printf("%d\n", runtime.NumCPU()) } $ go run numcpus.go 16 $ taskset --cpu-list 0 go run numcpus.go 1 ``` This leads to memory corruption because we pass to the bpf() call a buffer smaller than the write it will perform, leading to data being overwritten. Reducing the timeout of the goroutine that reads stat maps will reproduce this quickly and lead to SIGSEGVs, corrupted prometheus metrics or other symptoms. Signed-off-by: Kornilios Kourtis <[email protected]>
create updateMapMetric() function to update the metrics for a single map. This allows to use defer() to do proper cleanup in case of an error. Signed-off-by: Kornilios Kourtis <[email protected]>
Signed-off-by: Kornilios Kourtis <[email protected]>
kkourt
force-pushed
the
pr/kkourt/memory-corruption-fix
branch
from
June 19, 2023 09:44
9baecf3
to
fae4ef2
Compare
kkourt
added
kind/backport
This PR provides functionality previously merged into master.
needs-backport/0.8
and removed
kind/backport
This PR provides functionality previously merged into master.
labels
Jun 19, 2023
kevsecurity
reviewed
Jun 19, 2023
kevsecurity
approved these changes
Jun 19, 2023
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.
LGTM. One comment unrelated, so feel free to ignore for now.
mtardy
reviewed
Jun 19, 2023
This was referenced Jun 27, 2023
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR includes a bug that fixes a memory corruption bug, and it includes some other minor patches as well. Please review patch-by-patch.
Fixes: #1083
Fixes: #193