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)
Sun, May 5, 11:00 AM
Unknown Object (File)
Jan 14 2024, 4:51 PM
Unknown Object (File)
Dec 23 2023, 2:35 AM
Unknown Object (File)
Aug 21 2023, 9:16 PM
Unknown Object (File)
Jun 13 2023, 7:17 AM
Unknown Object (File)
May 26 2023, 9:25 PM
Unknown Object (File)
May 14 2023, 6:18 AM
Unknown Object (File)
May 8 2023, 1:01 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.