linux-test-project / ltp

Linux Test Project (mailing list: https://lists.linux.it/listinfo/ltp)
https://linux-test-project.readthedocs.io/
GNU General Public License v2.0
2.32k stars 1.02k forks source link

semctl09 broken on 32bit powerpc (and 64bit time) #1196

Open andree182 opened 1 month ago

andree182 commented 1 month ago

For some reason, semctl09 fails unless compiled with -O0.

semctl09.c:141: TINFO: Test SEM_STAT_ANY with nobody user
semctl09.c:163: TPASS: SEM_INFO returned valid index 10 to semid 10
semctl09.c:175: TFAIL: Counted used = 1, semuse = 0
semctl09.c:118: TFAIL: semusz = 0, expected 1
semctl09.c:125: TFAIL: semaem = 0, expected 2
semctl09.c:141: TINFO: Test SEM_STAT_ANY with root user
semctl09.c:163: TPASS: SEM_INFO returned valid index 10 to semid 10
semctl09.c:175: TFAIL: Counted used = 1, semuse = 0
semctl09.c:118: TFAIL: semusz = 0, expected 1
semctl09.c:125: TFAIL: semaem = 0, expected 2

It looks like __semctl64 is used for the actual call. With -O0, it seems to return the same structure that is returned in the kernel, with -O1 not, the structure gets mostly zeroed after the call

semid = do_semctl(TST_RET, 0, SEM_STAT_ANY);

Most likely semid_ds is not the right thing to put into the call to SEM_STAT_ANY (making it static confirms the issue by segfault).

E.g. char info[2048]; in do_semctl() fixes the issue.

metan-ucw commented 1 month ago

I suppose that this is the same problem as shmctl, we are mixing the kernel syscall with the glibc structure layout. I suppose that we need the kernel structure layout for the raw syscall instead of the glibc layout.