Skip to content

Commit

Permalink
Use so_names to prevent loading wrong abi (#56)
Browse files Browse the repository at this point in the history
As stated in https://bugzilla.redhat.com/show_bug.cgi?id=1361037,
"This is an application defect.

If you're using a path it's expected you know what you're loading.

One _should_ be using '#include <gnu/lib-names.h>' to get LIBC_SO and then dlopen that, it's the only supported solution, particularly consider distributions that might have /usr/lib64, or multi-arched lib dirs. You could be loading libc.so.6 from an incompatible ABI.

Loding by SONAME is the only safe option."
  • Loading branch information
Matthieu Coudron authored Nov 9, 2016
1 parent 805f38d commit 688038c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions model/elf-cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <sstream>
#include <string.h>
#include <sys/mman.h>
#include <gnu/lib-names.h>

namespace ns3 {

Expand All @@ -20,19 +21,19 @@ ElfCache::ElfCache (std::string directory, uint32_t uid)
m_uid (uid)
{
struct Overriden overriden;
overriden.from = "libc.so.6";
overriden.from = LIBC_SO;
overriden.to = "libc-ns3.so";
m_overriden.push_back (overriden);
overriden.from = "libpthread.so.0";
overriden.from = LIBPTHREAD_SO;
overriden.to = "libpthread-ns3.so";
m_overriden.push_back (overriden);
overriden.from = "librt.so.1";
overriden.from = LIBRT_SO;
overriden.to = "librt-ns3.so";
m_overriden.push_back (overriden);
overriden.from = "libm.so.6";
overriden.from = LIBM_SO;
overriden.to = "libm-ns3.so";
m_overriden.push_back (overriden);
overriden.from = "libdl.so.2";
overriden.from = LIBDL_SO;
overriden.to = "libdl-ns3.so";
m_overriden.push_back (overriden);
}
Expand Down

0 comments on commit 688038c

Please sign in to comment.