[PATCH v2] man/man2/mkdir.2: Add EOVERFLOW

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



`mkdir` and `mkdirat` might set errno to EOVERFLOW when UID or GID
mapping has not been configured. See
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=036d523641c66bef713042894a17f4335f199e49

This is a small program in the commit message that shows this behavior:

static int childFunc(void *_)
{
        if (mount("tmpfs", "/tmp", "tmpfs", 0, NULL)) {
                err(EXIT_FAILURE, "mount");
        }
        if (mkdir("/tmp/test", 0755) == -1) {
                err(EXIT_FAILURE, "mkdir");
        }
        return 0;
}

int main(int argc, char *argv[])
{
        char *stack; /* Start of stack buffer */
        char *stackTop; /* End of stack buffer */
        pid_t pid;

        stack = mmap(NULL, STACK_SIZE, PROT_READ | PROT_WRITE,
                     MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0);
        if (stack == MAP_FAILED)
                err(EXIT_FAILURE, "mmap");

        stackTop = stack + STACK_SIZE;

        pid = clone(childFunc, stackTop, CLONE_NEWUSER | CLONE_NEWNS | SIGCHLD,
                    NULL);
        if (munmap(stack, STACK_SIZE) == -1)
                err(EXIT_FAILURE, "munmap");
        if (pid == -1)
                err(EXIT_FAILURE, "clone");

        if (waitpid(pid, NULL, 0) == -1)
                err(EXIT_FAILURE, "waitpid");

        exit(EXIT_SUCCESS);
}

Signed-off-by: Chen Linxuan <chenlinxuan@xxxxxxxxxxxxx>
---
 man/man2/mkdir.2 | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/man/man2/mkdir.2 b/man/man2/mkdir.2
index d84dbc27e..2af618d68 100644
--- a/man/man2/mkdir.2
+++ b/man/man2/mkdir.2
@@ -203,6 +203,10 @@ does not support the creation of directories.
 .B EROFS
 .I pathname
 refers to a file on a read-only filesystem.
+.B EOVERFLOW
+UID or GID mappings (see
+.BR user_namespaces (7))
+has not been configured.
 .SH VERSIONS
 Under Linux, apart from the permission bits, the
 .B S_ISVTX
-- 
2.43.0





[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux