Page MenuHomeFreeBSD

Always give ELF brands a chance to veto a match.
ClosedPublic

Authored by jhb on Jan 17 2018, 12:21 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Dec 10, 6:57 AM
Unknown Object (File)
Mon, Dec 2, 10:37 PM
Unknown Object (File)
Mon, Nov 25, 10:06 PM
Unknown Object (File)
Sun, Nov 24, 12:43 AM
Unknown Object (File)
Sat, Nov 23, 3:28 PM
Unknown Object (File)
Sat, Nov 23, 3:25 PM
Unknown Object (File)
Sat, Nov 23, 12:31 AM
Unknown Object (File)
Nov 17 2024, 7:52 PM
Subscribers
None

Details

Summary

If a brand provides a header_supported hook, check it when trying to find
a brand based on a matching interpreter as well as in the final loop for the
fallback brand. Previously a brand might reject a binary via a
header_supported hook in one of the earlier loops, but still be chosen by
one of these later loops.

Test Plan

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib added inline comments.
sys/kern/imgact_elf.c
375 ↗(On Diff #38072)

Why put the condition into the separate if () ? It naturally extends the existing condition with &&.

This revision is now accepted and ready to land.Jan 17 2018, 9:22 AM
sys/kern/imgact_elf.c
375 ↗(On Diff #38072)

Mostly because the if condition was starting to get ugly to read. The rest of this function always invokes header_supported in a separate statement as well and this seemed a bit more readable. (The == 0 in the strncmp having to wrap is rather unfortunate for readability.)

389 ↗(On Diff #38072)

My one open question is if we should be running header_supported here? On the one hand a fallback brand has to be opted into, OTOH, a header_supported method probably knows it can't possibly handle certain types of files so should probably be honored?

sys/kern/imgact_elf.c
389 ↗(On Diff #38072)

I agree that it would be more consistent to check all places where we might to select the brand, against the header_supported. Until we have a case were the matching result changes, it is more theoretical question.

  • Always check header_supported.
This revision now requires review to proceed.Jan 31 2018, 5:48 PM
jhb retitled this revision from Give ELF brands a chance to veto a match based on just the interpreter. to Always give ELF brands a chance to veto a match..Jan 31 2018, 5:50 PM
jhb edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Feb 5 2018, 6:20 PM
This revision was automatically updated to reflect the committed changes.