Page MenuHomeFreeBSD

rtld-elf: Check the return value of obj_enforce_relro()
ClosedPublic

Authored by arichardson on Jun 19 2021, 11:21 AM.

Details

Summary

The mprotect() call was failing on CheriBSD when changing rtld's relro
page permissions due to missing CHERI capability permissions on the
mprotect() argument but did not report an error since the return value
was being ignored. It should never fail on any supported FreeBSD
architecture, but checking the return value seems like a good
sanity check to me.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

libexec/rtld-elf/rtld.c
2291–2292

Indentation is a bit odd in this entire function, I just used the existing style.

This revision is now accepted and ready to land.Jun 19 2021, 1:48 PM
libexec/rtld-elf/rtld.c
2291–2292

Other users of obj_enforce_relro() check for -1 to detect error.

libexec/rtld-elf/rtld.c
2291–2292

Ah yes, best to be consistent. @kib okay to commit with != 0 changed to == -1?

kib added inline comments.
libexec/rtld-elf/rtld.c
2291–2292

Sure, ok.