dlfcn-util: let's make our dlopen() code fail if we enter a container namespace
Now that we dlopen() so many deps, it might happen by accident that we end up dlopen()ening stuff when we entered a container, which we should really avoid, to not mix host and container libraries. Let's add a global variable we can set when we want to block dlopen() to ever succeed. This is then checked primarily in dlopen_many_sym_or_warn(), where we'll generate EPERM plus a log message. There are a couple of other places we invoke dlopen(), without going through dlopen_many_sym_or_warn(). This adds the same check there.
This commit is contained in:
@@ -4372,6 +4372,9 @@ static int outer_child(
|
||||
if (pid == 0) {
|
||||
fd_outer_socket = safe_close(fd_outer_socket);
|
||||
|
||||
/* In the child refuse dlopen(), so that we never mix shared libraries from payload and parent */
|
||||
block_dlopen();
|
||||
|
||||
/* The inner child has all namespaces that are requested, so that we all are owned by the
|
||||
* user if user namespaces are turned on. */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user