-
Notifications
You must be signed in to change notification settings - Fork 18.9k
c.RWLayer: check for nil before use #36242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
cpuguy83
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one minor nit.
daemon/changes.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably check if the container is in the dead state first.
This would allow us to give a better error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just here or in mount/unmount as well?
10dcedf to
42ced1d
Compare
daemon/daemon.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for checking for container.Dead here, unmount and in Windows, like in ContainerChanges
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see the updated version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, adding a check for container.Dead is a change in workflow -- meaning we no longer mount/unmount containers in Dead state. I'm not quite sure if this is the right change....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted the check for container.Dead in mount/umount/change, leaving only in getInspectData where a similar check was before

1a18157 to
9535192
Compare
|
LGTM |
|
There seems to be a deadlock in inspect. |
|
Windows: |
Since commit e9b9e4a has landed, there is a chance that container.RWLayer is nil (due to some half-removed container). Let's check the pointer before use to avoid any potential nil pointer dereferences, resulting in a daemon crash. Note that even without the abovementioned commit, it's better to perform an extra check (even it's totally redundant) rather than to have a possibility of a daemon crash. In other words, better be safe than sorry. [v2: add a test case for daemon.getInspectData] [v3: add a check for container.Dead and a special error for the case] Fixes: e9b9e4a Signed-off-by: Kir Kolyshkin <[email protected]>
9535192 to
195893d
Compare
cpuguy83
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
thaJeztah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Previously the RWLayer reference was cleared without holding the mutex. This could lead to goroutine panics in various places that use the container.RWLayer because nil checks introduced in moby#36242 where not sufficient as the reference could change after the check for nil and before the reference use. Signed-off-by: Tadeusz Dudkiewicz <[email protected]>
Previously the RWLayer reference was cleared without holding the container lock. This could lead to goroutine panics in various places that use the container.RWLayer because nil checks introduced in moby#36242 where not sufficient as the reference could change right before the use. Fixes moby#49227 Signed-off-by: Tadeusz Dudkiewicz <[email protected]>
Previously the RWLayer reference was cleared without holding the container lock. This could lead to goroutine panics in various places that use the container.RWLayer because nil checks introduced in moby#36242 where not sufficient as the reference could change right before the use. Fixes moby#49227 Signed-off-by: Tadeusz Dudkiewicz <[email protected]> (cherry picked from commit 97dc305) Signed-off-by: Paweł Gronowski <[email protected]>
Since commit e9b9e4a (#36160) has landed, there is a chance that
container.RWLayer is nil (due to some half-removed container). Let's
check the pointer before use to avoid any potential nil pointer
dereferences, resulting in a daemon crash.
Note that even without the abovementioned commit, it's better to perform
an extra check (even it's totally redundant) rather than to have a
possibility of a daemon crash. In other words, better be safe than
sorry.
Fixes: e9b9e4a
Signed-off-by: Kir Kolyshkin [email protected]
- 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)