Page MenuHomeFreeBSD

rtld: introduce PRELOAD_FDS

Authored by oshogbo on Mar 18 2021, 8:40 PM.



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

rG FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; 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.

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


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.

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.

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

This revision was automatically updated to reflect the committed changes.