kernel: Add missing NULL check to _user_xsi_semget.
Private semaphores will have a key of -1, but IPC_PRIVATE is 0, meaning it is possible to wind up here and get a NULL semaphoreSet if someone passes us an argument of -1. Reported on Twitter.
This commit is contained in:
parent
1efb85decc
commit
c62142a72b
@ -771,8 +771,8 @@ _user_xsi_semget(key_t key, int numberOfSemaphores, int flags)
|
||||
|
||||
MutexLocker _(sXsiSemaphoreSetLock);
|
||||
semaphoreSet = sSemaphoreHashTable.Lookup(semaphoreSetID);
|
||||
if (!semaphoreSet->HasPermission()) {
|
||||
TRACE_ERROR(("xsi_semget: calling process has not permission "
|
||||
if (semaphoreSet == NULL || !semaphoreSet->HasPermission()) {
|
||||
TRACE_ERROR(("xsi_semget: calling process has no permission "
|
||||
"on semaphore %d, key %d\n", semaphoreSet->ID(),
|
||||
(int)key));
|
||||
return EACCES;
|
||||
@ -815,9 +815,9 @@ _user_xsi_semget(key_t key, int numberOfSemaphores, int flags)
|
||||
|
||||
MutexLocker _(sXsiSemaphoreSetLock);
|
||||
semaphoreSet->SetID();
|
||||
if (isPrivate)
|
||||
if (isPrivate) {
|
||||
semaphoreSet->SetIpcKey((key_t)-1);
|
||||
else {
|
||||
} else {
|
||||
semaphoreSet->SetIpcKey(key);
|
||||
ipcKey->SetSemaphoreSetID(semaphoreSet);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user