4#include <cosmos/fs/types.hxx>
7#include <clues/SystemCall.hxx>
8#include <clues/arch.hxx>
9#include <clues/dso_export.h>
10#include <clues/items/clone.hxx>
11#include <clues/items/creds.hxx>
12#include <clues/items/fs.hxx>
13#include <clues/items/items.hxx>
14#include <clues/items/prctl.hxx>
15#include <clues/items/process.hxx>
16#include <clues/items/strings.hxx>
17#include <clues/sysnrs/generic.hxx>
21#ifdef CLUES_HAVE_ARCH_PRCTL
24struct CLUES_API ArchPrctlSystemCall :
27 ArchPrctlSystemCall() :
30 result.emplace(item::SuccessResult{});
31 setReturnItem(*result);
35 item::ArchOpParameter op;
37 std::optional<item::ULongValue> on_off;
39 std::optional<item::GenericPointerValue> set_addr;
41 std::optional<item::PointerToScalar<unsigned long>> get_addr;
43 std::optional<item::SuccessResult> result;
45 std::optional<item::IntValue> on_off_ret;
49 bool check2ndPass(
const Tracee&)
override;
51 void prepareNewSystemCall()
override;
61struct CLUES_API CloneSystemCall :
66 stack{
"stack",
"stack address"},
69 setParameters(flags, stack);
84 std::optional<item::PointerToScalar<cosmos::ProcessID>>
parent_tid;
89 std::optional<item::PointerToScalar<cosmos::FileNum>>
pidfd;
107 std::optional<item::GenericPointerValue>
tls;
121struct CLUES_API Clone3SystemCall :
125 size{
"size",
"cl_args structure size"},
143struct CLUES_API ForkSystemCall :
155struct CLUES_API ExecveSystemCall :
160 pathname{
"filename"},
161 argv{
"argv",
"argument vector"},
162 envp{
"envp",
"environment block pointer"} {
164 setParameters(pathname, argv, envp);
173struct CLUES_API ExecveAtSystemCall :
176 ExecveAtSystemCall() :
179 pathname{
"filename"},
180 argv{
"argv",
"argument vector"},
181 envp{
"envp",
"environment block pointer"} {
183 setParameters(dirfd, pathname, argv, envp, flags);
194template <
typename ID_T>
195struct GetXIdSystemCall :
209 const char* getShortLabel() {
211 case SystemCallNr::GETUID32: [[fallthrough]];
212 case SystemCallNr::GETUID:
return "uid";
213 case SystemCallNr::GETEUID32: [[fallthrough]];
214 case SystemCallNr::GETEUID:
return "euid";
215 case SystemCallNr::GETGID32: [[fallthrough]];
216 case SystemCallNr::GETGID:
return "gid";
217 case SystemCallNr::GETEGID32: [[fallthrough]];
218 case SystemCallNr::GETEGID:
return "egid";
219 default:
return "???";
223 const char* getLongLabel() {
225 case SystemCallNr::GETUID32: [[fallthrough]];
226 case SystemCallNr::GETUID:
return "real user ID";
227 case SystemCallNr::GETEUID32: [[fallthrough]];
228 case SystemCallNr::GETEUID:
return "effective user ID";
229 case SystemCallNr::GETGID32: [[fallthrough]];
230 case SystemCallNr::GETGID:
return "real group ID";
231 case SystemCallNr::GETEGID32: [[fallthrough]];
232 case SystemCallNr::GETEGID:
return "effective group ID";
233 default:
return "???";
243struct CLUES_API Wait4SystemCall :
250 setParameters(pid, wstatus, options, rusage);
Access to System Call Data.
void setReturnItem(SystemCallItem &ret)
Sets the return value system call item.
SystemCall(const SystemCallNr nr)
Instantiates a new SystemCall object with given properties.
SystemCallNr callNr() const
Returns the system call table number for this system call.
Base class for traced processes.
Flags for system calls with at semantics like linkat(), faccessat().
Structure used in clone3().
Base class for file descriptor system call items.
Pointer to a struct rusage to be filled in.
A nullptr-terminated array of pointers to c-strings.
c-string style system call data.
An always-success return value.
Pointer to an int containing wait() status result data.
@ PARAM_IN
An input parameter to the system call.
@ RETVAL
A system call return value.
SystemCallNr
Abstract system call number usable across architectures and ABIs.
item::ProcessIDItem pid
New child's PID or zero if executing in child context.
item::CloneArgs cl_args
Combined clone arguments.
void updateFDTracking(const Tracee &proc) override
Update file descriptor tracking.
item::SizeValue size
Size of the CloneArgs structure argument in cl_args.
std::optional< item::GenericPointerValue > tls
Thread-local-storage data for the new child.
item::ProcessIDItem new_pid
The new child's PID.
std::optional< item::PointerToScalar< cosmos::FileNum > > pidfd
PID file descriptor referring to the new child.
std::optional< item::GenericPointerValue > child_tid
TID of the new child written out to a pid_* in the child.
void prepareNewSystemCall() override
Perform any necessary actions before processing a new system call entry event.
std::optional< item::PointerToScalar< cosmos::ProcessID > > parent_tid
TID of the new child written out to a pid_t* in the parent.
bool check2ndPass(const Tracee &) override
Check whether a second pass needs to be made processing parameters.