Page MenuHomeFreeBSD

rtld: introduce PRELOAD_FDS
ClosedPublic

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

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
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
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.Thu, Mar 18, 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
2490

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.Fri, Mar 19, 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.