github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/sys/linux/ipc.txt (about)

     1  # Copyright 2017 syzkaller project authors. All rights reserved.
     2  # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  include <linux/fcntl.h>
     5  include <linux/stat.h>
     6  include <linux/ipc.h>
     7  include <linux/shm.h>
     8  include <linux/msg.h>
     9  include <linux/sem.h>
    10  include <uapi/linux/shm.h>
    11  
    12  resource ipc[int32]: 0, -1
    13  
    14  type ipc_key_t proc[2039359027, 4, int32]
    15  
    16  # TODO: describe ipc syscall
    17  
    18  resource ipc_msq[ipc]
    19  msgget(key ipc_key_t, flags flags[msgget_flags]) ipc_msq
    20  msgget$private(key const[IPC_PRIVATE], flags flags[msgget_flags]) ipc_msq
    21  msgsnd(msqid ipc_msq, msgp ptr[in, msgbuf], sz len[msgp], flags flags[msgsnd_flags])
    22  msgrcv(msqid ipc_msq, msgp ptr[out, msgbuf], sz len[msgp], typ flags[msgbuf_type], flags flags[msgrcv_flags])
    23  msgctl$IPC_STAT(msqid ipc_msq, cmd const[IPC_STAT], buf buffer[out])
    24  msgctl$IPC_SET(msqid ipc_msq, cmd const[IPC_SET], buf ptr[in, msqid_ds])
    25  msgctl$IPC_RMID(msqid ipc_msq, cmd const[IPC_RMID])
    26  msgctl$IPC_INFO(msqid ipc_msq, cmd const[IPC_INFO], buf buffer[out])
    27  msgctl$MSG_INFO(msqid ipc_msq, cmd const[MSG_INFO], buf buffer[out])
    28  msgctl$MSG_STAT(msqid ipc_msq, cmd const[MSG_STAT], buf buffer[out])
    29  msgctl$MSG_STAT_ANY(msqid ipc_msq, cmd const[MSG_STAT_ANY], buf buffer[out])
    30  
    31  resource ipc_sem[ipc]
    32  semget(key ipc_key_t, nsems flags[sem_sem_id], flags flags[semget_flags]) ipc_sem
    33  semget$private(key const[IPC_PRIVATE], nsems flags[sem_sem_id], flags flags[semget_flags]) ipc_sem
    34  semop(semid ipc_sem, ops ptr[in, array[sembuf]], nops len[ops])
    35  semtimedop(semid ipc_sem, ops ptr[in, array[sembuf]], nops len[ops], timeout ptr[in, timespec])
    36  
    37  # semctl$GETVAL produces random errno values, so we use ignore_return attribute.
    38  # Since we don't have strict const enforcement, we need to apply it to all variants.
    39  # When/if we have stricter enforcement of arguments for syscall variants, we may remove some of the attributes.
    40  
    41  semctl$IPC_STAT(semid ipc_sem, semnum const[0], cmd const[IPC_STAT], arg buffer[out]) (ignore_return)
    42  semctl$IPC_SET(semid ipc_sem, semnum const[0], cmd const[IPC_SET], arg ptr[in, semid_ds]) (ignore_return)
    43  semctl$IPC_RMID(semid ipc_sem, semnum const[0], cmd const[IPC_RMID]) (ignore_return)
    44  semctl$IPC_INFO(semid ipc_sem, semnum flags[sem_sem_id], cmd const[IPC_INFO], buf buffer[out]) (ignore_return)
    45  semctl$SEM_INFO(semid ipc_sem, semnum flags[sem_sem_id], cmd const[SEM_INFO], arg buffer[out]) (ignore_return)
    46  semctl$SEM_STAT(semid ipc_sem, semnum flags[sem_sem_id], cmd const[SEM_STAT], arg buffer[out]) (ignore_return)
    47  semctl$SEM_STAT_ANY(semid ipc_sem, semnum flags[sem_sem_id], cmd const[SEM_STAT_ANY], arg buffer[out]) (ignore_return)
    48  semctl$GETALL(semid ipc_sem, semnum const[0], cmd const[GETALL], arg buffer[out]) (ignore_return)
    49  semctl$GETNCNT(semid ipc_sem, semnum flags[sem_sem_id], cmd const[GETNCNT], arg buffer[out]) (ignore_return)
    50  semctl$GETPID(semid ipc_sem, semnum flags[sem_sem_id], cmd const[GETPID], arg buffer[out]) (ignore_return)
    51  semctl$GETVAL(semid ipc_sem, semnum flags[sem_sem_id], cmd const[GETVAL], arg buffer[out]) (ignore_return)
    52  semctl$GETZCNT(semid ipc_sem, semnum flags[sem_sem_id], cmd const[GETZCNT], arg buffer[out]) (ignore_return)
    53  semctl$SETALL(semid ipc_sem, semnum const[0], cmd const[SETALL], arg ptr[in, array[int16]]) (ignore_return)
    54  semctl$SETVAL(semid ipc_sem, semnum flags[sem_sem_id], cmd const[SETVAL], arg ptr[in, int32]) (ignore_return)
    55  
    56  resource ipc_shm[ipc]
    57  resource shmaddr[intptr]: 0
    58  # The unused arg is unused by syscall (does not exist at all),
    59  # but it helps to generate sane size values.
    60  shmget(key proc[2039339027, 4], size len[unused], flags flags[shmget_flags], unused vma) ipc_shm
    61  shmget$private(key const[IPC_PRIVATE], size len[unused], flags flags[shmget_flags], unused vma) ipc_shm
    62  shmat(shmid ipc_shm, addr vma, flags flags[shmat_flags]) shmaddr
    63  shmctl$IPC_STAT(shmid ipc_shm, cmd const[IPC_STAT], buf buffer[out])
    64  shmctl$IPC_SET(shmid ipc_shm, cmd const[IPC_SET], buf ptr[in, shmid_ds])
    65  shmctl$IPC_RMID(shmid ipc_shm, cmd const[IPC_RMID])
    66  shmctl$IPC_INFO(shmid ipc_shm, cmd const[IPC_INFO], buf buffer[out])
    67  shmctl$SHM_INFO(shmid ipc_shm, cmd const[SHM_INFO], buf buffer[out])
    68  shmctl$SHM_STAT(shmid ipc_shm, cmd const[SHM_STAT], buf buffer[out])
    69  shmctl$SHM_STAT_ANY(shmid ipc_shm, cmd const[SHM_STAT_ANY], buf buffer[out])
    70  shmctl$SHM_LOCK(shmid ipc_shm, cmd const[SHM_LOCK])
    71  shmctl$SHM_UNLOCK(shmid ipc_shm, cmd const[SHM_UNLOCK])
    72  shmdt(addr shmaddr)
    73  
    74  msgget_flags = IPC_CREAT, IPC_EXCL, open_mode
    75  msgbuf_type = 0, 1, 2, 3
    76  msgsnd_flags = IPC_NOWAIT
    77  msgrcv_flags = IPC_NOWAIT, MSG_EXCEPT, MSG_NOERROR
    78  semget_flags = IPC_CREAT, IPC_EXCL, open_mode
    79  semop_flags = IPC_NOWAIT, SEM_UNDO
    80  sem_sem_id = 0, 1, 2, 3, 4
    81  shmget_flags = IPC_CREAT, IPC_EXCL, SHM_HUGETLB, SHM_HUGE_2MB, SHM_HUGE_1GB, SHM_NORESERVE, open_mode
    82  shmat_flags = SHM_RND, SHM_RDONLY, SHM_REMAP
    83  
    84  ipc_perm {
    85  # NEED: all these uid, gid, pid, mode seem to be 2 bytes on 386 (what about arm?)
    86  	key	ipc_key_t
    87  	uid	uid
    88  	gid	gid
    89  	cuid	uid
    90  	cgid	gid
    91  	mode	flags[open_mode, int32]
    92  	seq	int16
    93  }
    94  
    95  msqid_ds {
    96  	msg_perm	ipc_perm
    97  	msg_first	const[0, intptr]
    98  	msg_last	const[0, intptr]
    99  	msg_stime	intptr
   100  	msg_rtime	intptr
   101  	msg_ctime	intptr
   102  	msg_lcbytes	intptr
   103  	msg_lqbytes	intptr
   104  	msg_cbytes	int16
   105  	msg_qnum	int16
   106  	msg_qbytes	int16
   107  	msg_lspid	pid
   108  	msg_lrpid	pid
   109  }
   110  
   111  shmid_ds {
   112  	shm_perm	ipc_perm
   113  	shm_segsz	int32
   114  	shm_atime	intptr
   115  	shm_dtime	intptr
   116  	shm_ctime	intptr
   117  	shm_cpid	pid
   118  	shm_lpid	pid
   119  	shm_nattch	int16
   120  	shm_unused	const[0, int16]
   121  	shm_unused2	const[0, intptr]
   122  	shm_unused3	const[0, intptr]
   123  }
   124  
   125  semid_ds {
   126  	sem_perm		ipc_perm
   127  	sem_otime		intptr
   128  	sem_ctime		intptr
   129  	sem_base		const[0, intptr]
   130  	sem_pending		const[0, intptr]
   131  	sem_pending_last	const[0, intptr]
   132  	undo			const[0, intptr]
   133  	sem_nsems		int16
   134  }
   135  
   136  sembuf {
   137  	num	flags[sem_sem_id, int16]
   138  	op	int16
   139  	flg	flags[semop_flags, int16]
   140  }
   141  
   142  msgbuf {
   143  	typ	flags[msgbuf_type, intptr]
   144  	data	array[int8]
   145  } [packed]