c.RWLayer: check for nil before use - #36242
Conversation
There was a problem hiding this comment.
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.
Just here or in mount/unmount as well?
10dcedf to
42ced1d
Compare
There was a problem hiding this comment.
+1 for checking for container.Dead here, unmount and in Windows, like in ContainerChanges
There was a problem hiding this comment.
Please see the updated version
There was a problem hiding this comment.
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.
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 <kolyshkin@gmail.com>
9535192 to
195893d
Compare
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 <tadeusz.dudkiewicz@rtbhouse.com>
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 <tadeusz.dudkiewicz@rtbhouse.com>
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 <tadeusz.dudkiewicz@rtbhouse.com> (cherry picked from commit 97dc305) Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
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 kolyshkin@gmail.com
- 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)