LDD-tree resolution - #5
Conversation
| WhichError(#[from] which::Error), | ||
| } | ||
|
|
||
| fn lddtree_collect_extra_library_paths(tree: &DependencyTree) -> Vec<PathBuf> { |
There was a problem hiding this comment.
Please move the ldd/elf helpers to a new elf.rs file.
There was a problem hiding this comment.
Makes sense to me. Will do.
There was a problem hiding this comment.
done. let me know if anything else should be moved.
| help = "Disable shared-library dependency resolution (lddtree)", | ||
| long_help = "Disable shared-library dependency resolution using lddtree. When set, Island will not automatically allow shared library dependencies; only the resolved command path will be allowed. Use this if your profile already grants the necessary access or if you want fully declarative dependency access rules." | ||
| )] | ||
| no_ldd: bool, |
There was a problem hiding this comment.
A similar feature could be implemented for other interpreters, so a --no-dependency=elf seems more generic.
There was a problem hiding this comment.
Well, thinking more about it, we should probably get rid of this CLI option and only add a profile's configuration instead. Something like no_dependency = ["elf"]. 🤔
There was a problem hiding this comment.
Makes sense but how should this work with merging profiles?
If profile A and B are selected, and A specifies no elf dependencies but B doesn't, should the elf dependencies be resolved?
There was a problem hiding this comment.
I guess it would make more sense to do the union of the no_dependency from all active profiles.
There was a problem hiding this comment.
Ok I added a feature for this with a top level config option no_dependency. Right now elf is the only valid array member. It does a union of all the profiles for this.
|
Gonna do a rebase here in a bit to clean up the commits. |
Adds ELF lddtree resolution to island. Don't even add the binary being ran if no_dependency = ["elf"] Signed-off-by: Justin Suess <utilityemal77@gmail.com>
90c353f to
9a63ef9
Compare
|
I rebased it on main and it should merge cleanly now. but I still need to figure out how handle interpreted (non-elf) executables. |
|
One issue I'm running into with trusting $PATH (next on the TODO list) is the performance. I'm testing an initial implementation. Recursively trusting every shared object in the path is expensive, even with some smart "visited" logic and symlink handling. We have to open every elf file, read its magic bytes and headers, etc. It's an IO bound problem. It takes about 10 seconds to add every program on $PATH and it's dependencies to the ruleset on my system with a good cpu, 128gb ram, and an NVME disk. I have a couple of options for you ordered by how good I think they are:
Let me know what you think. If you want this $PATH feature to be a seperate PR, or if I'm misunderstanding your intention entirely just say the word. |
Adds automatic resolution of binaries and their dependencies to
island run, and creates access rules granting access to them at runtime.This feature can be disabled at runtime with the
--no-lddflag.It adds two crates, lddtree and which. lddtree does the ELF parsing and dependency resolution, and which resolves the command from the path.
Issue with lddtree (workaround added)
Currently, for some reason, lddtree does not properly resolve the full paths of n>1 order dependencies. For example, libcap in the top command on nixos is a dependency of the libsystemd package. lddtree will have libcap.so.2 listed as a dependency, but not have the absolute path to the lib, only the library name.
My hypothesis: lddtree only searches for absolute paths using the binary's RUNPATH/RPATHs. But some systems (notably nixos), also rely on each library's RUNPATH/RPATHs, and may not include the full paths of n>1 dependencies in every binary.
A workaround for this was implemented, but this may be useful submitted upstream.
Todo: