Skip to content

🚨possible UB on linux in all releases that use getmntent🚨 #42

@Byron

Description

@Byron

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

  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions