Page MenuHomeFreeBSD

rtld: Reject ELF files with PT_LOAD or PT_TLS segments where filesz > memsz
AcceptedPublic

Authored by jhb on Wed, Jul 29, 7:23 PM.
Tags
None
Referenced Files
F164395554: D58541.diff
Fri, Jul 31, 12:42 PM
Unknown Object (File)
Wed, Jul 29, 7:52 PM
Subscribers

Details

Reviewers
kib
markj
jrtc27
Summary

All sorts of places in the ELF loading code assume that filesz <=
memsz, so check that explicitly up front. The kernel already performs
this check for the PT_LOAD segments in the main binary and rtld in
imgact_elf.c.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 75276
Build 72159: arc lint + arc unit

Event Timeline

jhb requested review of this revision.Wed, Jul 29, 7:23 PM

I do not object, but I also note that rtld trusts the format of the objects to be correct. There is a lot of missed bounds checks.

This revision is now accepted and ready to land.Thu, Jul 30, 4:24 AM

There's also lib/libc/gen/tls.c for PT_TLS

There's also lib/libc/gen/tls.c for PT_TLS

Oof, thanks for catching that, I'll add another commit for that.