In order to avoid copying all the shared libraries and config files into the chroot folder, I plan to call chroot("path/to/folder");
right after all the shared libraries and config files have been loaded.
Would a buffer overflow exploit in the previously loaded libraries provide the attacker access outside the chroot? (Because they were loaded before chrooting.)
Are there any drawbacks to this delayed chroot method in comparison to chrooting before program execution?