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)
Sat, Jun 29, 5:47 PM
Unknown Object (File)
Sun, Jun 23, 11:57 AM
Unknown Object (File)
Sat, Jun 22, 8:10 PM
Unknown Object (File)
Sat, Jun 22, 4:00 PM
Unknown Object (File)
Fri, Jun 21, 11:27 AM
Unknown Object (File)
Wed, Jun 19, 2:13 PM
Unknown Object (File)
May 23 2024, 11:55 AM
Unknown Object (File)
Feb 1 2024, 4:24 AM
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