From 7c343818f709d712cbe6a760ec09d3d44b1e0660 Mon Sep 17 00:00:00 2001 From: Bet4 <0xbet4@gmail.com> Date: Fri, 10 Jun 2022 23:51:59 +0800 Subject: [PATCH] Use global cwd in thread --- CREDITS.md | 2 +- qiling/os/linux/thread.py | 11 ----------- qiling/os/posix/syscall/sched.py | 1 - qiling/os/posix/syscall/unistd.py | 6 +----- 4 files changed, 2 insertions(+), 18 deletions(-) diff --git a/CREDITS.md b/CREDITS.md index 9ea9f0edf..e2bc84fa5 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -36,6 +36,7 @@ - Mark Jansen (learn-more) - cq674350529 - bkerler (viperbjk) +- bet4it #### Contributors (in no particular order) @@ -53,7 +54,6 @@ - madprogrammer - danielmoos - sigeryang -- bet4it - nullableVoidPtr diff --git a/qiling/os/linux/thread.py b/qiling/os/linux/thread.py index a5d0d8d24..1e2c5c1ba 100644 --- a/qiling/os/linux/thread.py +++ b/qiling/os/linux/thread.py @@ -14,7 +14,6 @@ from qiling.os.thread import * from qiling.arch.x86_const import * from qiling.exception import QlErrorExecutionStop -from qiling.os.path import QlOsPath LINUX_THREAD_ID = 2000 @@ -38,7 +37,6 @@ def __init__(self, ql: Qiling, start_address: int, exit_point: int, context = No self._start_address = start_address self._status = THREAD_STATUS_RUNNING self._return_val = 0 - self.path = self.ql.os.path self._log_file_fd = None self._sched_cb = None @@ -135,14 +133,6 @@ def return_val(self): def return_val(self, rv): self._return_val = rv - @property - def path(self): - return self._path - - @path.setter - def path(self, p: QlOsPath): - self._path = QlOsPath(self.ql.rootfs, p.cwd, self.ql.os.type) - @property def log_file_fd(self): return self._log_file_fd @@ -295,7 +285,6 @@ def clone(self): # Caveat: # Don't use thread id to identify the thread object. new_thread = self.ql.os.thread_class.spawn(self._ql, self._start_address, self._exit_point, self._saved_context, set_child_tid_addr = None, thread_id = self._thread_id) - new_thread._path = self._path new_thread._return_val = self._return_val new_thread._robust_list_head_len = self._robust_list_head_len new_thread._robust_list_head_ptr = self._robust_list_head_ptr diff --git a/qiling/os/posix/syscall/sched.py b/qiling/os/posix/syscall/sched.py index 9648182da..558e56d0a 100644 --- a/qiling/os/posix/syscall/sched.py +++ b/qiling/os/posix/syscall/sched.py @@ -82,7 +82,6 @@ def ql_syscall_clone(ql: Qiling, flags: int, child_stack: int, parent_tidptr: in set_child_tid_addr = child_tidptr th = ql.os.thread_class.spawn(ql, ql.arch.regs.arch_pc + 2, ql.os.exit_point, set_child_tid_addr = set_child_tid_addr) - th.path = f_th.path ql.log.debug(f'{str(th)} created') if flags & CLONE_PARENT_SETTID == CLONE_PARENT_SETTID: diff --git a/qiling/os/posix/syscall/unistd.py b/qiling/os/posix/syscall/unistd.py index fe0c01ca6..046446f63 100644 --- a/qiling/os/posix/syscall/unistd.py +++ b/qiling/os/posix/syscall/unistd.py @@ -380,11 +380,7 @@ def ql_syscall_chdir(ql: Qiling, path_name: int): relative_path = ql.os.path.transform_to_relative_path(pathname) if os.path.exists(real_path) and os.path.isdir(real_path): - if ql.os.thread_management: - ql.os.thread_management.cur_thread.path.cwd = relative_path - else: - ql.os.path.cwd = relative_path - + ql.os.path.cwd = relative_path regreturn = 0 ql.log.debug("chdir(%s) = %d"% (relative_path, regreturn)) else: