I met with such question about msgget recently.
while(1)
{
msqid = msgget(IPC_PRIVATE,IPC_CREAT);
if(msqid<0)
break;
printf("msqid=%d\n",msqid);
}
Soonly, it consumes all the msqid in the kernel.
Because the msgget is kernel-persistant, next time, the process run and quit with ENOSPC immdiately.
Although configuring the sysconf to compass the problem. but i should reconfigure again and again if the malicious code keeps running.
It’s a serious kind of leak, in my opinions, and make other process be in lack of msqid.
How can system administror to avoid this ?
All of the SysV IPC interfaces (shared memory, semaphores, etc.) have this same problem, among many other problems, the worst of which is atrocious performance due to bad design where every operation requires a call into kernelspace. If you can, abandon these interfaces and use the equivalent POSIX replacements (
mq_*for message queues).