If someone has the patches running, it would be interesting to see how it fares with this little test; (adjust MEM_SIZE to match your physical ram)
For a long time, this has managed to bring almost all my Linux-systems to a crawl, not surprising since it basically forces excessive swapping. My worry though, and the reason that I investigated it, is that occasionally some application is bound to go haywire and do something like this.
On some systems, the result is so bad, I can't even regain control of the system in reasonable time. IMHO, this is a plausible denial-of-service attack for any multi-user-system, or any service which can be triggered to excessive ram consumption.
/* Stupid program aiming to eat the swap alive */
#include <stdlib.h>
#include <string.h>
size_t MEM_SIZE = 1024*1024*1024;
float MEM_USE = 2;
size_t ALLOC_SIZE = 4*1024*1024;
int main() {
char **lists;
char *list;
size_t i,j;
size_t lists_len = (MEM_SIZE*MEM_USE) / ALLOC_SIZE;
lists = malloc(lists_len * sizeof(list));
for (i = 0; i < lists_len; i++)
lists[i] = malloc(ALLOC_SIZE);
while (1) {
for (i = 0; i < lists_len; i++)
memcpy(lists[i], lists[(i+1)%lists_len], ALLOC_SIZE);
}
return 0;
}
For a long time, this has managed to bring almost all my Linux-systems to a crawl, not surprising since it basically forces excessive swapping. My worry though, and the reason that I investigated it, is that occasionally some application is bound to go haywire and do something like this.
On some systems, the result is so bad, I can't even regain control of the system in reasonable time. IMHO, this is a plausible denial-of-service attack for any multi-user-system, or any service which can be triggered to excessive ram consumption.
/* Stupid program aiming to eat the swap alive */
#include <stdlib.h>
#include <string.h>
size_t MEM_SIZE = 1024*1024*1024;
float MEM_USE = 2;
size_t ALLOC_SIZE = 4*1024*1024;
int main() {
char **lists;
char *list;
size_t i,j;
size_t lists_len = (MEM_SIZE*MEM_USE) / ALLOC_SIZE;
lists = malloc(lists_len * sizeof(list));
for (i = 0; i < lists_len; i++)
lists[i] = malloc(ALLOC_SIZE);
while (1) {
for (i = 0; i < lists_len; i++)
memcpy(lists[i], lists[(i+1)%lists_len], ALLOC_SIZE);
}
return 0;
}
Comment