Skip to content

Commit

Permalink
semctl09: Fix EPERM warning in cleanup()
Browse files Browse the repository at this point in the history
If semctl09 failed in one of the SAFE_*() functions during unprivileged user
test case, SAFE_SEMCTL() in cleanup() would fail with EPERM because the sem_id
is owned by root. Make sure that cleanup() always runs with root EUID.

Fixes: 2a3e43a ("syscalls/ipc: semctl09: add a test for SEM_STAT_ANY")

Reviewed-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Martin Doucha <mdoucha@suse.cz>
  • Loading branch information
mdoucha authored and pevik committed Jan 25, 2021
1 parent 4df2c0a commit 3833d44
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions testcases/kernel/syscalls/ipc/semctl/semctl09.c
Expand Up @@ -187,6 +187,8 @@ static void setup(void)

static void cleanup(void)
{
SAFE_SETEUID(root_uid);

if (sem_id >= 0)
SAFE_SEMCTL(sem_id, 0, IPC_RMID);
}
Expand Down

0 comments on commit 3833d44

Please sign in to comment.