Page MenuHomeFreeBSD

rtld-elf: Fix leaks and wild frees in origin_subst
ClosedPublic

Authored by jrtc27 on Jul 12 2022, 4:24 PM.
Tags
None
Referenced Files
F154243100: D35792.diff
Mon, Apr 27, 8:59 AM
Unknown Object (File)
Fri, Apr 24, 12:56 AM
Unknown Object (File)
Thu, Apr 23, 4:43 AM
Unknown Object (File)
Fri, Apr 17, 11:42 AM
Unknown Object (File)
Mon, Apr 13, 11:48 PM
Unknown Object (File)
Fri, Apr 10, 8:49 PM
Unknown Object (File)
Feb 28 2026, 9:36 AM
Unknown Object (File)
Feb 8 2026, 9:38 PM
Subscribers

Details

Summary

55abf23dd36b inverted the value passed to origin_subst_one when rolling
up the existing code into a loop. If the first token is found ($ORIGIN),
this results in a wild free of part of strtab. Processing the second
token works fine and will act how the first should have regardless of
whether found, allocating memory for the string without freeing.
Processing subsequent tokens however will then leak, regardless of
whether found, as they will also believe they need to allocate memory
and can't free the string.

Found by: CHERI
Fixes: 55abf23dd36b ("rtld: make token substitution table-driven")
MFC after: 3 days

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable