Paste number 329658: mkdir(2) returns EOVERFLOW within user namespace

Paste number 329658: mkdir(2) returns EOVERFLOW within user namespace
Pasted by: civodul
When:3 years, 7 months ago
Share:Tweet this! | http://paste.lisp.org/+72D6
Channel:None
Paste contents:
Raw Source | XML | Display As
#define _GNU_SOURCE 1
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mount.h>
#include <errno.h>
#include <signal.h>
#include <sched.h>
#include <sys/syscall.h>

static int
test_mkdir ()
{
  int ret;

  ret = mkdir ("/tmp/foo", 0755);
  assert (ret == 0 || errno == 0 || errno == EEXIST);

  errno = 0;
  ret = mount ("none", "/tmp/foo", "tmpfs", 0, NULL);
  assert_perror (errno);

  errno = 0;
  ret = mkdir ("/tmp/foo/bar", 0755);

  /* Here we get EOVERFLOW with Linux 4.8.1.  */
  assert_perror (errno);

  return EXIT_SUCCESS;
}

int
main ()
{
  switch (syscall (SYS_clone, CLONE_NEWNS | CLONE_NEWUSER | SIGCHLD,
		   NULL, 				  /* child stack */
		   NULL, NULL,				  /* ptid & ctid */
		   NULL))
    {
    case 0:
      test_mkdir ();
      break;
    case -1:
      assert_perror (errno);
      break;
    default:
      return EXIT_SUCCESS;
    }

  return EXIT_SUCCESS;
}

This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.