File mode creation mask (umask)
Umask is a process file-creation mask that clears selected requested permission bits when ordinary mask-based creation rules apply rather than default-ACL inheritance.
Requested permissions: without a parent default ACL, Linux applies requested_mode & ~umask & 0777 to the permission bits. Mask 0022 changes a request for 0666 to 0644, while 0600 remains 0600. This is bit clearing, not octal subtraction; the mask cannot add an execute bit absent from the request. These values are caller-supplied examples, not mandatory modes for all files or directories. [1] [3]
Default ACL: a Linux parent directory's default ACL replaces ordinary umask processing. The new object's inherited access ACL is constrained by the requested mode's corresponding permission classes. A named entry can remain stored while the ACL mask removes its effective rights. A process umask and an ACL_MASK entry are different controls. [2]
Process state: a child created by fork() inherits the mask and execve() preserves it. POSIX threads share the process mask; calling umask() to fetch a value and then restore it leaves a non-atomic interval that can race with file creation in another thread. Linux's /proc/self/status exposes an Umask field without changing the mask, but reading it does not freeze later process state. [1] [4]
Separate controls: umask does not choose group ownership or replace later permission changes. Linux parent-directory set-group-ID and filesystem mount rules govern group inheritance; a new subdirectory also inherits a parent's set-group-ID bit. The 0777 calculation covers permission bits, not every st_mode field. Creation permissions differ from the access mode of the descriptor returned by open(). [3] [5]
Relations
Limitations
- The ordinary bit-clearing formula does not describe Linux creation under a parent default ACL.
- Creation modes alone do not establish successful access under all identities and security mechanisms.
Citations
- Linux man-pages: umask(2), creation mask, inheritance and query race
- Linux ACL project: acl(5), object creation and permission correspondence
- Linux man-pages: mkdir(2), creation permissions and group inheritance
- Linux man-pages: pthreads(7), shared process attributes
- Linux man-pages: open(2), creation mode versus descriptor access
Further reading
Sources & caveats
- Documentation synthesis. Numerical examples are permission-bit calculations, not new native measurements; the linked analysis separately labels its earlier ACL observations.