shmctl(IPC_RMID): fix wrong owner/creator checking (revised)

Don't check owner/creator of the segment in case of superuser.
This commit is contained in:
NAKAMURA Gou
2016-03-28 15:55:44 +09:00
parent a083e6c2bf
commit 18add6a9bd

View File

@ -51,6 +51,7 @@
#include <limits.h>
#include <mc_perf_event.h>
#include <march.h>
#include <process.h>
/* Headers taken from kitten LWK */
#include <lwk/stddef.h>
@ -3785,7 +3786,8 @@ SYSCALL_DECLARE(shmctl)
dkprintf("shmctl(%#x,%d,%p): lookup: %d\n", shmid, cmd, buf, error);
return error;
}
if ((obj->ds.shm_perm.uid != proc->euid)
if (!has_cap_sys_admin(thread)
&& (obj->ds.shm_perm.uid != proc->euid)
&& (obj->ds.shm_perm.cuid != proc->euid)) {
shmobj_list_unlock();
dkprintf("shmctl(%#x,%d,%p): -EPERM\n", shmid, cmd, buf);