Skip to content

shmat

Intro

shmat - Attach a shared memory segment.

Description

The shmat system call attaches the shared memory segment identified by shmid to the address space of the calling process. shmaddr specifies the address at which the shared memory segment is attached. If shmaddr is NULL, the system will choose an address at which to attach the segment. The shmflg parameter specifies characteristics of the attachment, including read/write permissions.

A successful call to shmat returns the address of the attached shared memory segment. The segment is detached from the address space of the calling process with shmdt.

Arguments

  • shmid:int[K] - Identifier of the shared memory segment to be attached.
  • shmaddr:const void*[U] - If not NULL, address the segment should be attached at.
  • shmflg:int[K] - Specifies various flags for the attachment:
    SHM_RDONLY = 0x001  - Segment attached read-only
    SHM_RND    = 0x002  - Round addr to SHMLBA boundary
    SHM_REMAP  = 0x004  - Map into current address space
    SHM_RXAREA = 0x008  - Force/allow read/execute
    SHM_EXEC   = 0x010  - Segment attached execute-only
    

Available Tags

  • K - Originated from kernel-space.
  • U - Originated from user space (for example, pointer to user space memory used to get it)

Hooks

shmat_common

Type

kprobes + ftrace

Purpose

To measure the execution time of the syscall.

Example Use Case

Event shmat could be used when an application needs to access a shared memory segment that is not mapped in the address space.

Issues

None.

  • mmap - Create or map a memory segment.
  • shmdt - Detach a shared memory segment.

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.