Skip to content



shmctl - System V shared memory operations


The shmctl system call is used to control System V (SVIPC) shared memory segments. It operates on the shared memory segment identified by the given shmid value. The cmd argument is used to specify the specific operation that needs to be performed. The buf argument is used to tell the kernel additional information about the operation, such as the data structure of struct shmid_ds defining the permission and size of the shared memory segment.

The shmctl system call is generally used to control the state of shared memory segments, like attach, detach, get the size of a segment, change permissions and so on.

The main advantages of using shmctl are that it provides an interface which is generic, easy to use and allows a range of different operations on shared memory segments.


  • shmid:int[K] - The id of the shared memory segment as returned by shmget.
  • cmd:int[K] - The command to be performed on the shared memory segment, can range from IPC_STAT to IPC_RMID.
  • buf:struct shmid_ds*[K] - Pointer to the buffer containing the information about the command to be performed on the shared memory segment.

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)






Hooked to get invoked whenever a shmctl system call is executed.

Example Use Case

The shmctl system call can be useful for development in data structures, message passing and process scheduling for distributed computing systems. It can be used to create shared memory segments, update information about existing memory segments, remove shared memory segments and more.


Since the shmctl system call is vulnerable to TOCTOU (time-of-check/time-of-use) attack, as some of its arguments can change between the time they are checked and used, it is very important to be aware of the security implications.

  • shmget
  • shmat
  • msgget
  • msgsnd
  • msgrcv

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.