mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
process-util: also disable dlopen() in safe_fork()
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "argv-util.h"
|
||||
#include "cgroup-util.h"
|
||||
#include "dirent-util.h"
|
||||
#include "dlfcn-util.h"
|
||||
#include "env-file.h"
|
||||
#include "errno-util.h"
|
||||
#include "escape.h"
|
||||
@@ -1695,6 +1696,15 @@ int pidref_safe_fork_full(
|
||||
r, "Failed to rename process, ignoring: %m");
|
||||
}
|
||||
|
||||
/* let's disable dlopen() in the child, as a paranoia safety precaution: children should not live for
|
||||
* long and only do minimal work before exiting or exec()ing. Doing dlopen() is not either. If people
|
||||
* want dlopen() they should do it before forking. This is a safety precuation in particular for
|
||||
* cases where the child does namespace shenanigans: we should never end up loading a module from a
|
||||
* foreign environment. Note that this has no effect on NSS! (i.e. it only has effect on uses of our
|
||||
* dlopen_safe(), which we use comprehensively in our codebase, but glibc NSS doesn't bother, of
|
||||
* course.) */
|
||||
block_dlopen();
|
||||
|
||||
if (flags & (FORK_DEATHSIG_SIGTERM|FORK_DEATHSIG_SIGINT|FORK_DEATHSIG_SIGKILL))
|
||||
if (prctl(PR_SET_PDEATHSIG, fork_flags_to_signal(flags)) < 0) {
|
||||
log_full_errno(prio, errno, "Failed to set death signal: %m");
|
||||
|
||||
Reference in New Issue
Block a user