提交 396bef4b 编写于 作者: J Jim Meyering 提交者: Anthony Liguori

arm-semi: don't leak 1KB user string lock buffer upon TARGET_SYS_OPEN

Always call unlock_user before returning.
Signed-off-by: NJim Meyering <meyering@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 a7e47d4b
...@@ -194,18 +194,19 @@ uint32_t do_arm_semihosting(CPUARMState *env) ...@@ -194,18 +194,19 @@ uint32_t do_arm_semihosting(CPUARMState *env)
if (!(s = lock_user_string(ARG(0)))) if (!(s = lock_user_string(ARG(0))))
/* FIXME - should this error code be -TARGET_EFAULT ? */ /* FIXME - should this error code be -TARGET_EFAULT ? */
return (uint32_t)-1; return (uint32_t)-1;
if (ARG(1) >= 12) if (ARG(1) >= 12) {
unlock_user(s, ARG(0), 0);
return (uint32_t)-1; return (uint32_t)-1;
}
if (strcmp(s, ":tt") == 0) { if (strcmp(s, ":tt") == 0) {
if (ARG(1) < 4) int result_fileno = ARG(1) < 4 ? STDIN_FILENO : STDOUT_FILENO;
return STDIN_FILENO; unlock_user(s, ARG(0), 0);
else return result_fileno;
return STDOUT_FILENO;
} }
if (use_gdb_syscalls()) { if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "open,%s,%x,1a4", ARG(0), gdb_do_syscall(arm_semi_cb, "open,%s,%x,1a4", ARG(0),
(int)ARG(2)+1, gdb_open_modeflags[ARG(1)]); (int)ARG(2)+1, gdb_open_modeflags[ARG(1)]);
return env->regs[0]; ret = env->regs[0];
} else { } else {
ret = set_swi_errno(ts, open(s, open_modeflags[ARG(1)], 0644)); ret = set_swi_errno(ts, open(s, open_modeflags[ARG(1)], 0644));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册