-
Notifications
You must be signed in to change notification settings - Fork 43
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
BSD mountinfo implementation is unsound #51
Comments
Related: #24 (one other issue is freebsd implementation requires cgo) We need someone who works with FreeBSD to fix this, and we need some CI to test it on. |
Related to using reflect.SliceHeader: moby/moby#41626 |
@cyphar Would you elaborating more? I don't see problem with current usage of reflect.SliceHeader in sys/mountinfo/mountinfo_bsd.go Line 28 in 1bc8673
|
I'm not saying it doesn't work, the issue is that |
I dont think it can be the issue if you did use reflect.SliceHeader correctly. I invite you to read golang/go#41705 (comment) |
Fair enough, I was going by the literal reading of the documentation (and I've been bitten by Go's runtime far too many times to be optimistic that its behaviour will be nice). But if the Go authors say the example is valid then there's only one correctness issue in the BSD implementation. |
There are two problems:
According to the documentation of
reflect.SliceHeader
it's never safe to modify or otherwise make use of the contents ofSliceHeader
:I'm sure that this is more of a CYA statement than anything else, but it does mean that technically our usage of this is unsound -- and ultimately the fix is just to switch to a C-style loop over the pointers.
getmntinfo
modifies a global variable, which means that if multiple goroutines try to get mountinfo at the same time we will end up potentially modifying the global structure during iteration. We could work around this by mutexing it or something, but a simpler solution would be to just usegetfsstat(2)
which allows us to pass our own allocated array.The text was updated successfully, but these errors were encountered: