diff options
author | Jing Chen <chjing@google.com> | 2020-10-26 19:24:28 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-10-26 19:26:42 -0700 |
commit | facb2fb9c39de72c2426849a972f7181e236e7ab (patch) | |
tree | e924d34198f7fee550a192ae5244f7f94829573f /pkg/sentry/syscalls/linux/sys_sem.go | |
parent | 528bc380222d1568fcbf95b449d0b19fd6dc0a00 (diff) |
Implement command IPC_STAT for semctl.
PiperOrigin-RevId: 339166854
Diffstat (limited to 'pkg/sentry/syscalls/linux/sys_sem.go')
-rw-r--r-- | pkg/sentry/syscalls/linux/sys_sem.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/pkg/sentry/syscalls/linux/sys_sem.go b/pkg/sentry/syscalls/linux/sys_sem.go index 47dadb800..c2d4bf805 100644 --- a/pkg/sentry/syscalls/linux/sys_sem.go +++ b/pkg/sentry/syscalls/linux/sys_sem.go @@ -129,9 +129,17 @@ func Semctl(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Syscal v, err := getPID(t, id, num) return uintptr(v), nil, err + case linux.IPC_STAT: + arg := args[3].Pointer() + ds, err := ipcStat(t, id) + if err == nil { + _, err = ds.CopyOut(t, arg) + } + + return 0, nil, err + case linux.IPC_INFO, linux.SEM_INFO, - linux.IPC_STAT, linux.SEM_STAT, linux.SEM_STAT_ANY, linux.GETNCNT, @@ -171,6 +179,16 @@ func ipcSet(t *kernel.Task, id int32, uid auth.UID, gid auth.GID, perms fs.FileP return set.Change(t, creds, owner, perms) } +func ipcStat(t *kernel.Task, id int32) (*linux.SemidDS, error) { + r := t.IPCNamespace().SemaphoreRegistry() + set := r.FindByID(id) + if set == nil { + return nil, syserror.EINVAL + } + creds := auth.CredentialsFromContext(t) + return set.GetStat(creds) +} + func setVal(t *kernel.Task, id int32, num int32, val int16) error { r := t.IPCNamespace().SemaphoreRegistry() set := r.FindByID(id) |