Skip to content

Commit 391c4b6

Browse files
stgraber3XX0
authored andcommitted
Preload glibc libraries before switching root
Signed-off-by: Jonathan Calmels <[email protected]>
1 parent 484612e commit 391c4b6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/driver.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ setup_rpc_service(struct driver *ctx, const char *root, uid_t uid, gid_t gid, pi
139139
xclose(ctx->fd[SOCK_CLT]);
140140

141141
if (!str_equal(root, "/")) {
142+
/* Preload glibc libraries to avoid symbols mismatch after changing root. */
143+
if (xdlopen(ctx->err, "libm.so.6", RTLD_NOW) == NULL)
144+
goto fail;
145+
if (xdlopen(ctx->err, "librt.so.1", RTLD_NOW) == NULL)
146+
goto fail;
147+
if (xdlopen(ctx->err, "libpthread.so.0", RTLD_NOW) == NULL)
148+
goto fail;
149+
142150
if (chroot(root) < 0 || chdir("/") < 0) {
143151
error_set(ctx->err, "change root failed");
144152
goto fail;

0 commit comments

Comments
 (0)