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
Unknown Object (File)
Tue, Dec 3, 1:49 AM
Unknown Object (File)
Nov 20 2024, 11:05 AM
Unknown Object (File)
Nov 20 2024, 11:04 AM
Unknown Object (File)
Nov 19 2024, 6:33 AM
Unknown Object (File)
Nov 16 2024, 4:51 AM
Unknown Object (File)
Oct 9 2024, 8:57 PM
Unknown Object (File)
Oct 1 2024, 11:41 AM
Unknown Object (File)
Sep 24 2024, 7: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