summaryrefslogtreecommitdiff
path: root/libpod/lock/shm_lock_manager_linux.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-01-04 14:15:08 -0500
committerMatthew Heon <matthew.heon@pm.me>2019-01-07 09:45:26 -0500
commiteba89259a5938f047d78b74c5bbbc908f8ff4be8 (patch)
treec5507f5c7a248252a819cdfa765e767c9faf531e /libpod/lock/shm_lock_manager_linux.go
parenta219431a317a2b6d9647ce81b7c845345e51b7da (diff)
downloadpodman-eba89259a5938f047d78b74c5bbbc908f8ff4be8.tar.gz
podman-eba89259a5938f047d78b74c5bbbc908f8ff4be8.tar.bz2
podman-eba89259a5938f047d78b74c5bbbc908f8ff4be8.zip
Address lingering review comments from SHM locking PR
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod/lock/shm_lock_manager_linux.go')
-rw-r--r--libpod/lock/shm_lock_manager_linux.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/libpod/lock/shm_lock_manager_linux.go b/libpod/lock/shm_lock_manager_linux.go
index 3e8f4f3d2..94dfd7dd7 100644
--- a/libpod/lock/shm_lock_manager_linux.go
+++ b/libpod/lock/shm_lock_manager_linux.go
@@ -3,7 +3,10 @@
package lock
import (
+ "syscall"
+
"github.com/containers/libpod/libpod/lock/shm"
+ "github.com/pkg/errors"
)
// SHMLockManager manages shared memory locks.
@@ -60,6 +63,11 @@ func (m *SHMLockManager) RetrieveLock(id uint32) (Locker, error) {
lock.lockID = id
lock.manager = m
+ if id >= m.locks.GetMaxLocks() {
+ return nil, errors.Wrapf(syscall.EINVAL, "lock ID %d is too large - max lock size is %d",
+ id, m.locks.GetMaxLocks()-1)
+ }
+
return lock, nil
}