Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

[18.09 backport] Graphdriver: fix "device" mode not being detected if "character-device" bit is set #160

Conversation

thaJeztah
Copy link
Member

backport of moby#38758 for 18.09. Cherry-pick was clean; no conflicts

Due to a bug in Golang (github.com/golang#27640), the "character device"
bit was omitted when checking file-modes with os.ModeType.

This bug was resolved in Go 1.12, but as a result, graphdrivers
would no longer recognize "device" files, causing pulling of
images that have a file with this filemode to fail;

failed to register layer:
unknown file type for /var/lib/docker/vfs/dir/.../dev/console

The current code checked for an exact match of Modes to be set. The
os.ModeCharDevice and os.ModeDevice bits will always be set in
tandem, however, because the code was only looking for an exact
match, this detection broke now that os.ModeCharDevice was added.

This patch changes the code to be more defensive, and instead
check if the os.ModeDevice bit is set (either with, or without
the os.ModeCharDevice bit).

In addition, some information was added to the error-message if
no type was matched, to assist debugging in case additional types
are added in future.

Signed-off-by: Sebastiaan van Stijn github@gone.nl
(cherry picked from commit c7a38c2)
Signed-off-by: Sebastiaan van Stijn github@gone.nl

- What I did

- How I did it

- How to verify it

- Description for the changelog

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

…e" bit is set

Due to a bug in Golang (github.com/golang#27640), the "character device"
bit was omitted when checking file-modes with `os.ModeType`.

This bug was resolved in Go 1.12, but as a result, graphdrivers
would no longer recognize "device" files, causing pulling of
images that have a file with this filemode to fail;

    failed to register layer:
    unknown file type for /var/lib/docker/vfs/dir/.../dev/console

The current code checked for an exact match of Modes to be set. The
`os.ModeCharDevice` and `os.ModeDevice` bits will always be set in
tandem, however, because the code was only looking for an exact
match, this detection broke now that `os.ModeCharDevice` was added.

This patch changes the code to be more defensive, and instead
check if the `os.ModeDevice` bit is set (either with, or without
the `os.ModeCharDevice` bit).

In addition, some information was added to the error-message if
no type was matched, to assist debugging in case additional types
are added in future.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit c7a38c2)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah added this to the 18.09.3 milestone Feb 20, 2019
@thaJeztah
Copy link
Member Author

ping @tonistiigi @kolyshkin @andrewhsu PTAL

Backporting this to prevent us running into issues if we update to a more recent version of Go at some point

@kolyshkin
Copy link

LGTM

@tiborvass tiborvass merged commit 2e4c5c5 into docker-archive:18.09 Feb 22, 2019
@thaJeztah thaJeztah deleted the 18.09_backport_add_missing_char_device_mode branch February 22, 2019 02:09
algitbot pushed a commit to alpinelinux/aports that referenced this pull request Mar 12, 2019
https://github.com/docker/docker-ce/releases/tag/v18.09.3

The more important fixes in this version:
* When copying existing folder, ignore xattr set errors when the target filesystem doesn't support xattr. docker-archive/engine#135
* Graphdriver: fix device mode not being detected if character-device bit is set. docker-archive/engine#160
* Fix nil pointer derefence on failure to connect to containerd. docker-archive/engine#162
* Delete stale containerd object on start failure. docker-archive/engine#154
liske pushed a commit to liske/aports that referenced this pull request Apr 7, 2019
https://github.com/docker/docker-ce/releases/tag/v18.09.3

The more important fixes in this version:
* When copying existing folder, ignore xattr set errors when the target filesystem doesn't support xattr. docker-archive/engine#135
* Graphdriver: fix device mode not being detected if character-device bit is set. docker-archive/engine#160
* Fix nil pointer derefence on failure to connect to containerd. docker-archive/engine#162
* Delete stale containerd object on start failure. docker-archive/engine#154
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants