Skip to content

daemon: Set umask to 0000 #52892

Merged
thaJeztah merged 3 commits into
moby:masterfrom
vvoland:daemon-clear-umask
Jun 17, 2026
Merged

daemon: Set umask to 0000 #52892
thaJeztah merged 3 commits into
moby:masterfrom
vvoland:daemon-clear-umask

Conversation

@vvoland

@vvoland vvoland commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Clear the daemon umask so explicitly requested file modes are preserved instead of being filtered by the previous 0022 umask.

This fixes cases such as COPY --chmod=777 producing 0755 permissions, and adjusts daemon-owned file creation sites that previously relied on the old umask to remove group/other-write bits.

Also document that managed containerd inherits the daemon's cleared umask.

Release notes (optional)

Fix explicit file modes being filtered by the daemon umask, including `COPY --chmod` permissions

A picture of a cute animal (not mandatory but encouraged)

@vvoland vvoland added this to the 29.6.0 milestone Jun 16, 2026
@vvoland vvoland self-assigned this Jun 16, 2026
@github-actions github-actions Bot added area/networking Networking area/daemon Core Engine labels Jun 16, 2026
Comment thread daemon/libnetwork/osl/namespace_linux.go Dismissed
// setDefaultUmask sets the umask to 0022 to avoid problems
// setDefaultUmask sets the umask to 0 to avoid problems
// caused by custom umask
func setDefaultUmask() error {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After successfully setting the umask, we should probably also update that global var in (fsutil.UmaskIsZero = true) #52817 (comment)

Previously the daemon forced its umask to 0022, which silently stripped
the group/other-write bits from any explicitly requested file mode.

This caused e.g. `COPY --chmod=777` to result in 0755 rather than 0777.

Clear the umask so explicit modes are honored.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@vvoland vvoland force-pushed the daemon-clear-umask branch from 99535ea to 9384dea Compare June 17, 2026 12:22
@thaJeztah

Copy link
Copy Markdown
Member

FWIW, we can still suppress the CodeQL warning through the UI, but I generally prefer it to be captured in code where possible (think it's cleaner to have a comment in version control that indicates it was evaluated and decided on).

vvoland added 2 commits June 17, 2026 14:57
Clearing the daemon umask means creation sites can no longer rely on
umask 0022 to remove group/other-write bits from permissive modes.

Adjust modes for daemon-owned files that previously depended on the old
umask:

- fuse-overlayfs lower file
- goroutine stack dump file
- layer migration tar-data file
- network namespace mount file

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Managed containerd inherits the daemon's cleared umask, so files it
creates are no longer filtered by the historical 0022 umask.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@vvoland vvoland force-pushed the daemon-clear-umask branch from 9384dea to 533ae76 Compare June 17, 2026 12:57
@vvoland

vvoland commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

I left the suppression commit, but dropped the graphql workflow change. Let's defer to a follow up

@thaJeztah

Copy link
Copy Markdown
Member

Yeah, let's suppress it manually.

I'm still wondering if there's 2 separate CodeQL workflows running; a default (on the repository config) and one defined as GitHub action. There's also still a warning that there's a config issue that we still need to look at (CodeQL is really confusing, more so due to our DIND flows I guess)

"github.com/moby/moby/v2/daemon/libnetwork/portallocator"
"github.com/moby/moby/v2/pkg/homedir"
"github.com/pkg/errors"
fsutilcopy "github.com/tonistiigi/fsutil/copy" //nolint:depguard // Needed to keep fsutil copy behavior aligned with the daemon umask.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, I forgot about the depguard.

Perhaps the workaround can be removed now that docker sets the proper umask as well, but not sure if it's used elsewhere.

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thaJeztah

Copy link
Copy Markdown
Member

Probably flaky test;

=== Failed
=== FAIL: integration-cli TestDockerCLIRunSuite/TestRunStdinBlockedAfterContainerExit (33.61s)
    docker_cli_run_test.go:3522: timeout waiting for command to exit

@thaJeztah thaJeztah merged commit a95784f into moby:master Jun 17, 2026
279 of 286 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docker COPY with chmod fails to add permissions

3 participants