Page MenuHomeFreeBSD

Factor out resource limit enforcement code in the ELF loader.
ClosedPublic

Authored by trasz on Mar 23 2019, 1:28 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 20 2023, 6:50 AM
Unknown Object (File)
Dec 13 2023, 3:00 PM
Unknown Object (File)
Dec 12 2023, 10:16 AM
Unknown Object (File)
Nov 11 2023, 4:50 PM
Unknown Object (File)
Nov 8 2023, 9:01 AM
Unknown Object (File)
Nov 7 2023, 4:40 PM
Unknown Object (File)
Nov 7 2023, 10:55 AM
Unknown Object (File)
Nov 6 2023, 6:48 PM
Subscribers

Details

Summary

Factor out resource limit enforcement code in the ELF loader.
It makes the code slightly easier to follow, and might make
it easier to fix the resouce accounting to also account for
the interpreter.

The PROC_UNLOCK() is moved earlier - I don't see anything
it should protect; the lim_max() is a wrapper around lim_rlimit(),
and that, differently from lim_rlimit_proc(), doesn't require
the proc lock to be held.

Diff Detail

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

Event Timeline

sys/kern/imgact_elf.c
826 ↗(On Diff #55384)

Can these two lines be merged with 80-columns limit ?

833 ↗(On Diff #55384)

merge the conditions from these two if()s.

851 ↗(On Diff #55384)

I think it is useful to re-flow all moved comments

853 ↗(On Diff #55384)

Make the flag check style-compliant:

if ((phdr[i].p_flags & PF_X) != 0 && text_size < seg_size) {
1155 ↗(On Diff #55384)

Why did you removed the lock ? This must be noted in the commit message together with explanation why it is safe.

trasz added inline comments.
sys/kern/imgact_elf.c
826 ↗(On Diff #55384)

Not really, they overflow by one or two characters. Also, there seems to be an interesting distinction - the ones from the first line are initialized upfront, the ones from the second line are not.

851 ↗(On Diff #55384)

Done. I hadn't touched the lower one, since reflowing it doesn't make it any shorter.

1155 ↗(On Diff #55384)

From my understanding, the lock was there because of the call to lim_max() - but lim_max() is a wrapper around lim_rlimit(), which, differently from lim_rlimit_proc(), doesn't seem to require the proc lock. Right?

And yes, you are right that I should mention this in the commit message; I'll update the description.

trasz marked an inline comment as done.
trasz edited the summary of this revision. (Show Details)

Update after suggestions from kib@.

This revision is now accepted and ready to land.Mar 25 2019, 5:45 PM
This revision was automatically updated to reflect the committed changes.