Skip to content
This repository was archived by the owner on Nov 19, 2026. It is now read-only.

Fix accessing to layer without lock - #1351

Merged
rhatdan merged 1 commit into
containers:mainfrom
tyler92:fix-panic-in-layers
Sep 27, 2022
Merged

rhatdan merged 1 commit into
containers:mainfrom
tyler92:fix-panic-in-layers

Conversation

@tyler92

@tyler92 tyler92 commented Sep 16, 2022

Copy link
Copy Markdown
Contributor

There was a possibility to panic due to such behavior: attempted to update last-writer in lockfile without the write lock

Fixes: #1324

Signed-off-by: Mikhail Khachayants [email protected]

@tyler92

tyler92 commented Sep 16, 2022

Copy link
Copy Markdown
Contributor Author

I really don't know how to make sure that there are no double locks.

@rhatdan

rhatdan commented Sep 16, 2022

Copy link
Copy Markdown
Member

When adding a lock, it is always worth while opening [WIP] PR with this Change in Podman and Buildah to have their tests run against them.

@tyler92

tyler92 commented Sep 16, 2022

Copy link
Copy Markdown
Contributor Author

Ok, I'll do it

Comment thread layers.go Outdated
gidMap: copyIDMap(s.gidMap),
}
defer rlstore.Unlock()
rlstore.RLock()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

IIRC these should be write locks, so that incomplete layers can be cleaned up. (Not in the newROLayerStore case)

warning: I didn’t actually review this carefully — this is just a drive-by comment to make sure it is not forgotten.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, fixed. FYI: I'm still trying to check it with Podman and Buildah CI.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The crash in #1324 only happens on recovery from a previous crash, so I’m not at all sure those CI systems exercise that case. If they did, we should have found #1324 much earlier.

@tyler92 tyler92 Sep 21, 2022 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I understand. I just want to make sure, that my change doesn't broke something (e.g. there is no double lock).

When adding a lock, it is always worth while opening [WIP] PR with this Change in Podman and Buildah to have their tests run against them.

Comment thread layers.go Resolved
@tyler92
tyler92 force-pushed the fix-panic-in-layers branch from 1868743 to 4211ae4 Compare September 21, 2022 13:11
There was a possibility to panic due to such behavior:
attempted to update last-writer in lockfile without the write lock

Fixes: containers#1324

Signed-off-by: Mikhail Khachayants <[email protected]>
@tyler92
tyler92 force-pushed the fix-panic-in-layers branch from 4211ae4 to e35b061 Compare September 21, 2022 13:27
@tyler92

tyler92 commented Sep 21, 2022

Copy link
Copy Markdown
Contributor Author

CI in Podman and Buildah is green. @mtrmac what do you think about this PR?

@mtrmac mtrmac left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This LGTM.

For consistency, could you please update containers.go and images.go to do it the same way? They are correct now AFAICS, it’s just a matter of looking the same if they are doing the same thing:

  • Lock the lock after creating the whole store object, not before
  • Use the store’s Lock/RLock/Unlock method, instead of directly manipulating a lockfile object.

@rhatdan
rhatdan merged commit d9e14ec into containers:main Sep 27, 2022
rhatdan added a commit to rhatdan/storage that referenced this pull request Sep 27, 2022
Match containers and image lock to the new layer lock method.
in containers#1351

Signed-off-by: Daniel J Walsh <[email protected]>
rhatdan added a commit to rhatdan/storage that referenced this pull request Sep 28, 2022
Match containers and image lock to the new layer lock method.
in containers#1351

Signed-off-by: Daniel J Walsh <[email protected]>
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.

Panic: attempted to update last-writer in lockfile without the write lock

3 participants