Skip to contentSkip to conversation

semctl09: Fix EPERM warning in cleanup()

PATCH New Martin Doucha 2 participants 2 messages Jan 25, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 semctl09: Fix EPERM warning in cleanup()

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.

---
 testcases/kernel/syscalls/ipc/semctl/semctl09.c | 2 ++
 1 file changed, 2 insertions(+)
testcases/kernel/syscalls/ipc/semctl/semctl09.c +2 -0
index d36ba62e5..f0c757cdd 100644
@@ -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);
 }
Signature · 1 line
2.29.2
#1 lore raw

PATCH 1/1 semctl09: Fix EPERM warning in cleanup()

Hi Martin,

Quoted 3 lines

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.

Thanks a lot, merged!

Kind regards,
Petr