diff options
Diffstat (limited to 'emulators/qemu-devel/files/patch-z9d-bsd-user-sson003d')
| -rw-r--r-- | emulators/qemu-devel/files/patch-z9d-bsd-user-sson003d | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/emulators/qemu-devel/files/patch-z9d-bsd-user-sson003d b/emulators/qemu-devel/files/patch-z9d-bsd-user-sson003d new file mode 100644 index 000000000000..5dfbaa4ea476 --- /dev/null +++ b/emulators/qemu-devel/files/patch-z9d-bsd-user-sson003d @@ -0,0 +1,92 @@ +diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c +index 8abb1dd..c2c3a65 100644 +--- a/bsd-user/elfload.c ++++ b/bsd-user/elfload.c +@@ -798,6 +798,7 @@ static abi_ulong setup_arg_pages(abi_ulong p, struct bsd_binprm *bprm, + p -= roundup(execpath_len, sizeof(abi_ulong)); + /* XXX - check return value of memcpy_to_target() */ + memcpy_to_target(p, execpath, execpath_len); ++ strlcpy(target_proc_pathname, execpath, execpath_len); + } + + /* Add canary for SSP. */ +diff --git a/bsd-user/main.c b/bsd-user/main.c +index bb614de..b6aaa7e 100644 +--- a/bsd-user/main.c ++++ b/bsd-user/main.c +@@ -62,6 +62,7 @@ unsigned long x86_stack_size = 512 * 1024; + + static void save_proc_pathname(void); + char qemu_proc_pathname[PATH_MAX]; ++char target_proc_pathname[PATH_MAX]; + + #ifdef __FreeBSD__ + static void +diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h +index 110b54e..d51f50c 100644 +--- a/bsd-user/qemu.h ++++ b/bsd-user/qemu.h +@@ -224,6 +224,7 @@ void mmap_fork_end(int child); + /* main.c */ + extern unsigned long x86_stack_size; + extern char qemu_proc_pathname[]; ++extern char target_proc_pathname[]; + + /* user access */ + +diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c +index 74b5c86..636083a 100644 +--- a/bsd-user/syscall.c ++++ b/bsd-user/syscall.c +@@ -485,8 +485,6 @@ static abi_long do_freebsd_sysctl(abi_ulong namep, int32_t namelen, abi_ulong ol + abi_ulong oldlen = 0; + int32_t *snamep = g_malloc(sizeof(int32_t) * namelen), *p, *q, i; + uint32_t kind = 0; +- abi_ulong argv, argv0; +- char *fullpath = NULL; + + if (oldlenp) + if (get_user_ual(oldlen, oldlenp)) +@@ -533,30 +531,14 @@ static abi_long do_freebsd_sysctl(abi_ulong namep, int32_t namelen, abi_ulong ol + case KERN_PROC: + switch(snamep[2]) { + case KERN_PROC_PATHNAME: +- if (get_user_ual(argv, TARGET_PS_STRINGS)) { +- ret = -TARGET_EFAULT; +- goto out; +- } +- if (get_user_ual(argv0, argv)) { +- ret = -TARGET_EFAULT; +- goto out; +- } +- +- fullpath = realpath(g2h(argv0), NULL); +- if (NULL == fullpath) +- fullpath = (char *)g2h(argv0); +- holdlen = strlen(fullpath) + 1; ++ holdlen = strlen(target_proc_pathname) + 1; + if (holdp) { + if (oldlen < holdlen) { + ret = -TARGET_EINVAL; + goto out; + } +- if (!access_ok(VERIFY_WRITE, argv0, +- holdlen)) { +- ret = -TARGET_EFAULT; +- goto out; +- } +- strlcpy(holdp, fullpath, oldlen); ++ strlcpy(holdp, target_proc_pathname, ++ oldlen); + } + ret = 0; + goto out; +@@ -597,8 +579,6 @@ static abi_long do_freebsd_sysctl(abi_ulong namep, int32_t namelen, abi_ulong ol + #endif + + out: +- if (fullpath) +- free(fullpath); + if (oldlenp) + put_user_ual(holdlen, oldlenp); + unlock_user(hnamep, namep, 0); |
