Skip to content

Conversation

jsternberg
Copy link
Collaborator

Go 1.23 changed the behavior of os.Stat to set ModeIrregular when it
encountered a mount point reparse point on Windows. These were
previously labeled as symlinks.

We attempted to fix this by clearing ModeIrregular during checksum
generation, but we only cleared it in the case where ModeIrregular and
at least one other mode type was set.

After reviewing the original solution and issue, I believe that this was
too conservative. The original issue seems to indicate that only the
ModeIrregular bit was set so the condition would not have triggered
and cleared it properly. I thought mount points would have both
ModeDir and ModeIrregular set, but they only seem to have
ModeIrregular set.

This unconditionally clears the bit similar to socket files which should
properly fix the issue on Windows.

Fixes docker/for-win#14083.

Related to #5665.

@jsternberg jsternberg added this to the v0.23.0 milestone Jun 11, 2025
@jsternberg jsternberg requested a review from Copilot June 11, 2025 14:16
@jsternberg jsternberg force-pushed the unconditional-clear-mode-irregular branch from bbd5249 to df01637 Compare June 11, 2025 14:16
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR simplifies the logic in NewFromStat to unconditionally clear the ModeIrregular bit (in addition to the already-cleared socket bit) for compatibility with archive/tar.FileInfoHeader.

  • Remove conditional clearing of ModeIrregular
  • Add unconditional clearing of both ModeSocket and ModeIrregular
  • Update comment to describe both bits at once
Comments suppressed due to low confidence (2)

cache/contenthash/filehash.go:44

  • [nitpick] Minor grammar: change do not handle them to does not handle them since archive/tar.FileInfoHeader is singular.
// Clear the socket and irregular bits since archive/tar.FileInfoHeader do not handle them

cache/contenthash/filehash.go:45

  • [nitpick] Consider combining the two bit-clearing operations into one expression, e.g., stat.Mode &^= uint32(os.ModeSocket | os.ModeIrregular), to reduce duplication.
stat.Mode &^= uint32(os.ModeSocket)

Go 1.23 changed the behavior of `os.Stat` to set `ModeIrregular` when it
encountered a mount point reparse point on Windows. These were
previously labeled as symlinks.

We attempted to fix this by clearing `ModeIrregular` during checksum
generation, but we only cleared it in the case where `ModeIrregular` and
at least one other mode type was set.

After reviewing the original solution and issue, I believe that this was
too conservative. The original issue seems to indicate that only the
`ModeIrregular` bit was set so the condition would not have triggered
and cleared it properly. I thought mount points would have both
`ModeDir` and `ModeIrregular` set, but they only seem to have
`ModeIrregular` set.

This unconditionally clears the bit similar to socket files which should
properly fix the issue on Windows.

Signed-off-by: Jonathan A. Sternberg <[email protected]>
@jsternberg jsternberg force-pushed the unconditional-clear-mode-irregular branch from df01637 to 450362a Compare June 11, 2025 14:45
@tonistiigi tonistiigi merged commit 0972af1 into moby:master Jun 11, 2025
139 checks passed
@jsternberg jsternberg deleted the unconditional-clear-mode-irregular branch June 11, 2025 16:06
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.

failed to solve: archive/tar: unknown file mode ?rwxr-xr-x while following official tutorial
2 participants