Page MenuHomeFreeBSD

rtld: introduce PRELOAD_FDS
ClosedPublic

Authored by oshogbo on Mar 18 2021, 8:40 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Dec 8, 10:30 AM
Unknown Object (File)
Sun, Dec 8, 10:30 AM
Unknown Object (File)
Sun, Dec 8, 10:30 AM
Unknown Object (File)
Fri, Dec 6, 1:54 PM
Unknown Object (File)
Fri, Dec 6, 1:45 PM
Unknown Object (File)
Tue, Dec 3, 9:27 PM
Unknown Object (File)
Oct 3 2024, 10:24 PM
Unknown Object (File)
Oct 1 2024, 11:55 PM
Subscribers

Details

Summary

The new PRELOAD_FDS variable accepts a list of file descriptors
that should be loaded into the process.

This may be used to optimize a loading process - in the case when
we already have a file descriptor to the library; we don't have
to look into multiple PATH to find it.

It may also be used in capability mode to load a single additional
library without the need to open a directory that contains it.

The last use of this functionality t may be a race-free method
of loading libraries.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

oshogbo retitled this revision from rtld: intrdouce PRELOAD_FDS to rtld: introduce PRELOAD_FDS.Mar 18 2021, 8:43 PM
This comment was removed by oshogbo.
libexec/rtld-elf/rtld.c
2579

So here we dup the passed fd to set CLOEXEC. Does the original fd get closed somehow?

libexec/rtld-elf/rtld.c
2579

No, we do not.
I did the same think like in case of LD_LIBARARY_PATH_FDS.
We don't close anywhere the directories passed.
Now I think of that the consumer should have decision what to do with those fds (in both cases) right?

kib added inline comments.
libexec/rtld-elf/rtld.c
2491

return (-1);

You can stage a pre-patch changing other returns in this function, if you prefer common style. Or better, convert the function to style (mostly indents).

This revision is now accepted and ready to land.Mar 19 2021, 11:51 AM
markj added inline comments.
libexec/rtld-elf/rtld.c
2579

I misread the code, I didn't see that fd is closed below.

This revision was automatically updated to reflect the committed changes.