From 377f99e807f4aa42ece9f0cd437f50af11611b4c Mon Sep 17 00:00:00 2001 From: Aleksandar Markovic Date: Mon, 19 Aug 2019 15:20:29 +0200 Subject: [PATCH] linux-user: Special case /etc/ld.cache.so and pretend it does not exist Prevent target executables from opening host ld.so.cache. --- linux-user/syscall.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 8367cb1..f5bae6e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8820,6 +8820,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (!(p = lock_user_string(arg1))) { return -TARGET_EFAULT; } + if (strcmp("/etc/ld.so.cache", path(p)) == 0) { + unlock_user(p, arg1, 0); + return -TARGET_ENONET; + } ret = get_errno(statfs(path(p), &stfs)); unlock_user(p, arg1, 0); convert_statfs: @@ -8859,6 +8863,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (!(p = lock_user_string(arg1))) { return -TARGET_EFAULT; } + if (strcmp("/etc/ld.so.cache", path(p)) == 0) { + unlock_user(p, arg1, 0); + return -TARGET_ENONET; + } ret = get_errno(statfs(path(p), &stfs)); unlock_user(p, arg1, 0); convert_statfs64: @@ -9059,6 +9067,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (!(p = lock_user_string(arg1))) { return -TARGET_EFAULT; } + if (strcmp("/etc/ld.so.cache", path(p)) == 0) { + unlock_user(p, arg1, 0); + return -TARGET_ENONET; + } ret = get_errno(stat(path(p), &st)); unlock_user(p, arg1, 0); goto do_stat; @@ -9068,6 +9080,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (!(p = lock_user_string(arg1))) { return -TARGET_EFAULT; } + if (strcmp("/etc/ld.so.cache", path(p)) == 0) { + unlock_user(p, arg1, 0); + return -TARGET_ENONET; + } ret = get_errno(lstat(path(p), &st)); unlock_user(p, arg1, 0); goto do_stat; @@ -10268,6 +10284,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (!(p = lock_user_string(arg1))) { return -TARGET_EFAULT; } + if (strcmp("/etc/ld.so.cache", path(p)) == 0) { + unlock_user(p, arg1, 0); + return -TARGET_ENONET; + } ret = get_errno(stat(path(p), &st)); unlock_user(p, arg1, 0); if (!is_error(ret)) @@ -10279,6 +10299,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (!(p = lock_user_string(arg1))) { return -TARGET_EFAULT; } + if (strcmp("/etc/ld.so.cache", path(p)) == 0) { + unlock_user(p, arg1, 0); + return -TARGET_ENONET; + } ret = get_errno(lstat(path(p), &st)); unlock_user(p, arg1, 0); if (!is_error(ret)) @@ -10319,6 +10343,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, if (p == NULL) { return -TARGET_EFAULT; } + if (strcmp("/etc/ld.so.cache", path(p)) == 0) { + unlock_user(p, arg1, 0); + return -TARGET_ENONET; + } #if defined(__NR_statx) { /* -- 2.7.4