clock_nanosleep¶
Intro¶
clock_nanosleep - cause the current thread to sleep until a given time
Description¶
The clock_nanosleep() system call causes the current thread to be suspended from execution until the absolute time specified by *tsp. The suspesion time may be shorter than requested because of the delivery of a signal. If the call is interrupted by the delivery of a signal, the remaining sleep time is returned in the remain argument of type struct timespcae, or is 0 if the timer expired. Two flags for use with nanosleep() are available, and defined in time.h
- TIMER_ABSTIME - set absolute timer value
- TIMER_RELTIME - set relative timer value
Arguments¶
-
clockid
:const clockid_t
- The following clocks IDs are available;- [CLOCK_REALTIME] (https://man7.org/linux/man-pages/man2/clock_gettime.2.html)
- [CLOCK_MONOTONIC] (https://man7.org/linux/man-pages/man2/clock_gettime.2.html)
- [CLOCK_MONOTONIC_RAW] (https://man7.org/linux/man-pages/man2/clock_gettime.2.html)
- [CLOCK_BOOTTIME] (https://man7.org/linux/man-pages/man7/timer_create.7.html)
-
flags
:int
- If this is set to 0, the timer expiration value is specified in therequest
argument and is an absolute value. If the flag is set to TIMER_ABSTIME, ts is an absolute time. If TIMER_RELTIME is specified in flags, ts is a relative time. -
request
:const struct timespec*
K - pointer to the timespec structure contains the expcation time of the nanosleep call. For the TIMER_ABSTIME the expiration time is an absolute time specified byrequest
. For the TIMER_RELTIME the expiration time is a relative time specified byrequest
. -
remain
:struct timespec*
K - pointer to the timespec structure containing the remaining sleep time left or 0 if the timer expired.
Available Tags¶
- K - Originated from kernel-space.
- U - Originated from user space (for example, pointer to user space memory used to get it)
- TOCTOU - Vulnerable to TOCTOU (time of check, time of use)
- OPT - Optional argument - might not always be available (passed with null value)
Hooks¶
nanosleep¶
Type¶
Probed
Purpose¶
Hooked to track execution of clock_nanosleep syscall.
Example Use Case¶
clock_nanosleep can be used to set a timer that will cause the current thread of a process to be suspended for a given amount of time. This can be useful for implementing algorithms such as synchronization, where it is necessary to wait for a certain amount of time before proceeding.
Issues¶
- clock_nanosleep is vulnerable to TOCTOU (Time-of-Check-Time-of-Use) attack
Related Events¶
- clock_gettime()
- clock_settime()
- clock_getres()
- timer_create()
- timer_settime()
This document was automatically generated by OpenAI and needs review. It might not be accurate and might contain errors. The authors of Tracee recommend that the user reads the "events.go" source file to understand the events and their arguments better.