spiegel_podman/libpod
Matthew Heon 2c6dadd724 Fix a locking bug in that could cause a double-unlock
The `cleanupExecBundle` function was only meant to be called on a
locked container, as it does some state mutation operations. It
also has a timed wait (if the directory is busy and can't be
removed yet, give it a few milliseconds) in which it deliberately
yields the lock to not block the container for that time.

The `healthCheckExec()` function calls `cleanupExecBundle` out of
a `defer` block. This is after the `defer c.lock.Unlock()` so it
fires afterwards when the function returns, so we're normally
fine - the container is still locked when our defer runs. The
problem is that `healthCheckExec()` also unlocks the container
during the expensive exec operation, and can actually fail and
return while not holding the lock - meaning our `defer` can fire
on an unlocked container, leading to a potential double unlock
in `cleanupExecBundle`.

We could, potentially, re-lock the container after the exec
occurs, but we're actually waiting for a `select` to trigger to
end the function, so that's not a good solution. Instead, just
re-lock (if necessary) in the defer, before invoking
`cleanupExecBundle()`. The `defer c.lock.Unlock()` will fire
right after and unlock after us.

Fixes #26968

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2025-09-03 10:19:37 -04:00
..
define Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
driver Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
events Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
layers Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
linkmode chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
lock Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
logs bump go to 1.22 2024-09-03 15:14:15 +02:00
plugin Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
shutdown Revert "libpod: remove shutdown.Unregister()" 2024-11-27 08:09:50 -05:00
boltdb_state.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
boltdb_state_internal.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
common_test.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
container.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
container_api.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
container_commit.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
container_config.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
container_copy_common.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
container_copy_freebsd.go Mount volumes before copying into a container 2024-11-27 08:09:50 -05:00
container_copy_linux.go Mount volumes before copying into a container 2024-11-27 08:09:50 -05:00
container_exec.go Fix a locking bug in that could cause a double-unlock 2025-09-03 10:19:37 -04:00
container_freebsd.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
container_graph.go Add syncmap package and use it for graph stop/remove 2025-02-17 14:32:34 -05:00
container_graph_test.go Bump Go module to v5 2024-02-08 09:35:39 -05:00
container_inspect.go Fix podman inspect to correctly handle log_size_max 2025-07-03 16:04:48 -04:00
container_inspect_freebsd.go libpod: fix HostConfig.Devices output from 'podman inspect' on FreeBSD 2024-09-02 11:21:35 +01:00
container_inspect_linux.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
container_internal.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
container_internal_common.go Merge pull request #26945 from Luap99/vol-opts 2025-09-02 14:18:15 +00:00
container_internal_freebsd.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
container_internal_linux.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
container_internal_linux_test.go libpod: --user works with --hostuser entries 2025-04-07 18:11:06 +02:00
container_internal_test.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
container_linux.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
container_log.go libpod: log file use Wait() over event API 2024-11-01 18:53:08 +01:00
container_log_linux.go Bump Go module to v5 2024-02-08 09:35:39 -05:00
container_log_unsupported.go Bump Go module to v5 2024-02-08 09:35:39 -05:00
container_path_resolution.go Mount volumes before copying into a container 2024-11-27 08:09:50 -05:00
container_path_resolution_test.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
container_stat_common.go Mount volumes before copying into a container 2024-11-27 08:09:50 -05:00
container_stat_freebsd.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
container_stat_linux.go Bump Go module to v5 2024-02-08 09:35:39 -05:00
container_top_freebsd.go Bump Go module to v5 2024-02-08 09:35:39 -05:00
container_top_linux.c libpod/container_top_linux.c: fix missing header 2024-06-27 10:50:17 +02:00
container_top_linux.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
container_top_unsupported.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
container_validate.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
diff.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
doc.go document that using libpod package directly is not supported 2022-03-23 19:05:29 +01:00
events.go Fix HealthCheck log destination, count, and size defaults 2025-03-12 21:27:00 +01:00
healthcheck.go Fix: Ensure HealthCheck exec session terminates on timeout 2025-05-12 17:01:35 +02:00
healthcheck_config.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
healthcheck_linux.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
healthcheck_nosystemd_linux.go libpod: do not leak systemd hc startup unit timer 2024-06-04 18:03:46 +02:00
healthcheck_unsupported.go libpod: do not leak systemd hc startup unit timer 2024-06-04 18:03:46 +02:00
info.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
info_freebsd.go Bump Go module to v5 2024-02-08 09:35:39 -05:00
info_linux.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
info_test.go Bump Go module to v5 2024-02-08 09:35:39 -05:00
kube.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
mounts_linux.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
networking_common.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
networking_freebsd.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
networking_linux.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
networking_linux_test.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
networking_machine.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
networking_pasta_linux.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
networking_slirp4netns.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
oci.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
oci_conmon.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
oci_conmon_attach_common.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
oci_conmon_attach_freebsd.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
oci_conmon_attach_linux.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
oci_conmon_common.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
oci_conmon_exec_common.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
oci_conmon_exec_freebsd.go Cease using deprecated runc userlookup 2024-02-02 11:02:43 -05:00
oci_conmon_exec_linux.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
oci_conmon_freebsd.go libpod: intermediate mount if UID not mapped into the userns 2024-06-21 18:01:26 +02:00
oci_conmon_linux.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
oci_missing.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
oci_util.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
options.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
pod.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
pod_api.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
pod_internal.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
pod_internal_freebsd.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
pod_internal_linux.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
pod_status.go Bump Go module to v5 2024-02-08 09:35:39 -05:00
pod_top_freebsd.go Bump Go module to v5 2024-02-08 09:35:39 -05:00
pod_top_linux.go Bump Go module to v5 2024-02-08 09:35:39 -05:00
reset.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
rlimit_int64.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
rlimit_uint64.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
runtime.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
runtime_cstorage.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
runtime_ctr.go Merge pull request #26945 from Luap99/vol-opts 2025-09-02 14:18:15 +00:00
runtime_ctr_freebsd.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
runtime_ctr_linux.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
runtime_freebsd.go Detect unhandled reboots and require user intervention 2024-04-05 10:07:42 -04:00
runtime_img.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
runtime_linux.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
runtime_migrate.go libpod: fix a confusing error message from 'podman system reset' on FreeBSD 2025-02-11 15:13:29 +00:00
runtime_migrate_freebsd.go libpod: fix a confusing error message from 'podman system reset' on FreeBSD 2025-02-11 15:13:29 +00:00
runtime_migrate_linux.go libpod: fix a confusing error message from 'podman system reset' on FreeBSD 2025-02-11 15:13:29 +00:00
runtime_migrate_unsupported.go libpod: fix a confusing error message from 'podman system reset' on FreeBSD 2025-02-11 15:13:29 +00:00
runtime_pod.go Replace golang.org/x/exp/slices with slices from std 2024-04-23 11:16:40 +02:00
runtime_pod_common.go fix issues found by nilness 2025-05-13 17:20:10 +02:00
runtime_pod_freebsd.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
runtime_pod_linux.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
runtime_pre_go1.20.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
runtime_renumber.go Bump Go module to v5 2024-02-08 09:35:39 -05:00
runtime_test.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
runtime_volume.go libpod: remove duplicated HasVolume() check 2024-08-15 11:07:27 +02:00
runtime_volume_common.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
runtime_worker.go create runtime's worker queue before queuing any job 2024-07-09 11:15:29 +02:00
service.go Bump Go module to v5 2024-02-08 09:35:39 -05:00
sqlite_state.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
sqlite_state_internal.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
state.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
state_test.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
stats_common.go Bump Go module to v5 2024-02-08 09:35:39 -05:00
stats_freebsd.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
stats_linux.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
storage.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
util.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
util_freebsd.go libpod: rm some unused freebsd code 2025-04-02 13:35:14 -07:00
util_linux.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
util_linux_test.go replace deprecated selinux/label calls 2025-03-24 17:44:43 +01:00
util_test.go libpod: fix mount order for "/" volume 2025-05-20 15:52:27 +02:00
volume.go Switch common, storage and image to monorepo. 2025-09-01 12:33:04 +02:00
volume_inspect.go Bump Go module to v5 2024-02-08 09:35:39 -05:00
volume_internal.go Only stop chowning volumes once they're not empty 2024-05-22 17:47:01 -04:00
volume_internal_common.go Bump Go module to v5 2024-02-08 09:35:39 -05:00
volume_internal_freebsd.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00
volume_internal_linux.go chore: delete obsolete // +build lines 2024-01-04 11:53:38 +02:00