Commit 3ca54916 authored by Davide Libenzi's avatar Davide Libenzi Committed by Linus Torvalds

[PATCH] epoll: replace the file lookup hash with rbtrees

The epoll allocation for the fd lookup hash used to allocate up to 1MB
(depending on the "hint" size passed to epoll_create()) with
__get_free_pages(0), and this might lead to a "malicious" user to do
something like:

    for (i = 0; i < 1024; i++)
        epoll_create(BIG-NUM);

You can replace "malicious user" with IBM-ltp test suite, and the meaning
does not change.  The above code might exhaust memory badly, even before
the file creation limit is topped.  Also, the allocation was independent
from the number of fds pushed into the epoll fd hash.  Using an rb-tree
ther will be not pre-allocation of the hash, and the size of the memory
used will be proportional to the number of fds pushed into the epoll fd.
The patch also removes 100 lines of code, that is never a bad thing ;)
Signed-off-by: default avatarDavide Libenzi <davidel@xmailserver.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent b2dbffab
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment