Messages in this thread | | | Date | Sun, 07 Nov 1999 19:20:08 +0100 | From | Manfred Spraul <> | Subject | Re: [patch] ipc updates |
| |
Andi Kleen wrote: > > As far as I can see it still has the resource race (resources are charged > after sleeping without rechecking, so there is a window where the user is > able to overcommit). Here is for reference my 2.2 patch that fixes the > problem and Scott Maxwell's DoS. >
I think my patch solves both problems: * the overcommit race does not exist: the code never sleeps between checking for free queue space and increasing q_cbytes. I first load the message into kernel space, then acquire a spinlock and (test for free space, add to queue, increase q_cbytes) atomically. I know that you can slightly overcommit: each process that is sleeping in sys_sndmsg() can overcommit by one message (ie MSGMAX), but I think we can ignore that: it's negligable compared to the total memory for a process (kernel stack, page tables, ...). The memory is recovered if an interrupt aborts sys_sndmsg().
* Scott's DoS: > +#define MSGQNUM 1024 /* <=65535 */ /* Max messages in flight / queue */
I use a simpler solution without a new limit: sys_msgsnd(): - if(msgsz + msq->q_cbytes > msq->q_qbytes) { - DECLARE_WAITQUEUE(wait,current); + if(msgsz + msq->q_cbytes > msq->q_qbytes || + 1 + msq->q_qnum > msq->q_qbytes) { + struct msg_sender s; I reuse the number of bytes in the queue. This allows the user to overcommit by ~ 3%, IMHO that's acceptable. (16384 one byte messages eat ~ 512 kB kernel memory, 2 8 Kb message + 16382 0 byte messages around 528 kB)
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |