You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue can be used to figure out a way out of this without breakage, while reducing risk of this UB to be exploited at some point.
What we did so far
make multi-threaded usage on linux and freebsd safe by synchronizing the function call, knowing that this will reduce multi-threaded 'trashing' somewhat and be ineffective in case calls are made directly to libc::getmnt*() from other threads.
yank all v2.0 versions prior to v2.0.4 as they contained the use of getmntent()
How to fix Linux
This fix reduces chances of UB to zero and makes the Mutex unnecessary.
use getmntent_r() instead of getmntent()
How to fix FreeBSD
This fix reduces chances of UB to zero and makes the Mutex unnecessary.
Use getfsstat directly, which avoids the statically allocated buffers entirely. Thanks, @avitex, for the suggestion.
That's all we know.
The text was updated successfully, but these errors were encountered:
Byron
changed the title
possible UB on linux in all releases that use getmntent
🚨possible UB on linux in all releases that use getmntent🚨
Jan 22, 2022
Note that you're given ownership of the buffer with getfsstat, of which you could just smack into a OnceCell. For the case where a thread loses the race on init, you would have to call free on the buffer.
See this PR for more information.
This issue can be used to figure out a way out of this without breakage, while reducing risk of this UB to be exploited at some point.
What we did so far
libc::getmnt*()
from other threads.getmntent()
How to fix Linux
This fix reduces chances of UB to zero and makes the Mutex unnecessary.
getmntent_r()
instead ofgetmntent()
How to fix FreeBSD
This fix reduces chances of UB to zero and makes the Mutex unnecessary.
getfsstat
directly, which avoids the statically allocated buffers entirely. Thanks, @avitex, for the suggestion.That's all we know.
The text was updated successfully, but these errors were encountered: