Page MenuHomeFreeBSD

Factor out retrieving the interpreter path from the main ELF loader routine.
ClosedPublic

Authored by trasz on Mar 26 2019, 3:42 PM.
Tags
None
Referenced Files
F106132335: D19715.diff
Wed, Dec 25, 10:42 PM
Unknown Object (File)
Fri, Dec 13, 5:23 AM
Unknown Object (File)
Wed, Dec 11, 4:30 PM
Unknown Object (File)
Oct 2 2024, 12:49 PM
Unknown Object (File)
Oct 2 2024, 12:37 AM
Unknown Object (File)
Sep 30 2024, 5:29 PM
Unknown Object (File)
Sep 23 2024, 3:35 AM
Unknown Object (File)
Sep 22 2024, 8:16 PM
Subscribers

Details

Summary

Factor out retrieving the interpreter path from the main ELF
loader routine.

One small difference is that it no longer errors out if there
are multiple PT_INTERP sections; it just uses the first one.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 23307
Build 22338: arc lint + arc unit

Event Timeline

If you only move some parts of the case PT_INTERP into the helper, you can 1. avoid one more pass over phdrs 2. easily keep the logic to error on more than one interpreter.

Also I do not completely like the removal of the interp_name_len argument from the get_brandinfo args.

sys/kern/imgact_elf.c
285

If you insist on doing this arg removal, at least write this code as

interp_name_len = interp != NULL ? strlen(interp) : 0;

Kib's suggestions.

Updating D19715: Factor out retrieving the interpreter path from the main ELF

loader routine.

sys/kern/imgact_elf.c
904

Add assertions: phdr type is PT_INTERP, vp is exclusively locked.

905

curthread is used only once, it seems. I do not see a need for td.

933

If you restore the 'else' clause, then *interpp = interp; return (0); can be left once in the end of the function.

Improve.

Updating D19715: Factor out retrieving the interpreter path from the main ELF

loader routine.

trasz added inline comments.
sys/kern/imgact_elf.c
933

I find the current version easier to read, to be honest.

kib added inline comments.
sys/kern/imgact_elf.c
933

For me (the reader) it is reverse. I need to understand that all successful exit paths satisfy the function interface, and single success-exit with non-duplicated code makes it easier to see.

I would not stop you from committing this due to the rearrangement of three lines, but I prefer the described version.

This revision is now accepted and ready to land.Mar 27 2019, 4:41 PM
This revision was automatically updated to reflect the committed changes.