Subject: port-sparc/9022: semctl(2) returns invalid results.
To: None <gnats-bugs@gnats.netbsd.org>
From: None <ura@hiru.aoba.yokohama.jp>
List: netbsd-bugs
Date: 12/18/1999 06:22:03
>Number: 9022
>Category: port-sparc
>Synopsis: semctl(2) returns invalid results.
>Confidential: no
>Severity: critical
>Priority: high
>Responsible: port-sparc-maintainer (NetBSD/sparc Portmaster)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Dec 18 06:20:59 1999
>Last-Modified:
>Originator: URA Hiroshi
>Organization:
URA Hiroshi E-mail: ura@hiru.aoba.yokohama.jp
>Release: NetBSD-current 1.4P (1999/12/17)
>Environment:
System: NetBSD uzuki.hiru.aoba.yokohama.jp 1.4P NetBSD 1.4P (UZUKI) #26: Fri Dec 17 18:55:34 JST 1999 root@:/usr/local/src/NetBSD/current/src/sys/arch/sparc/compile/UZUKI sparc
>Description:
When I tried to run samba on SS10 on running -current, I get a following
error messages.
ERROR: root did not create the semaphore: semgid=950, rootgid=0
I wrote an attached test code by way of cheking semctl(2). I got vaild
results on PC running -current, but I got invaild on Sparc running same
-current.
case PC:
pc% ./shmemtest.i386elf
real user id = 12494
real group id = 20
effective user id = 12494
effective group id = 20
*** union ***
semaphore user id = 12494
group id = 20
creator user id = 12494
creator group id = 20
mode = 1644 (932)
*** varargs ***
semaphore user id = 12494
group id = 20
creator user id = 12494
creator group id = 20
mode = 1644 (932)
*** sleeping ***
^Z
Suspended
pc% bg
[1] ./shmemtest.i386elf &
pc% ipcs -a
<snip>
Semaphores:
T ID KEY MODE OWNER GROUP CREATOR CGROUP \
NSEMS OTIME CTIME
s 458752 1114482 --rw-r--r-- 12494 20 12494 20 \
16no-entry 14:48:12
case Sparc:
sparc{1}% ./shmemtest.sparc
real user id = 12494
real group id = 20
effective user id = 12494
effective group id = 20
*** union ***
semaphore user id = 20
group id = 12494
creator user id = 20
creator group id = 932
mode = 2200000 (589824)
*** varargs ***
semaphore user id = 12494
group id = 20
creator user id = 12494
creator group id = 20
mode = 1644 (932)
*** sleeping ***
^Z
Suspended
sparc% bg
[1] ./shmemtest.sparc &
sparc% ipcs -a
<snip>
Semaphores:
T ID KEY MODE OWNER GROUP CREATOR CGROUP \
NSEMS OTIME CTIME
s 589824 1114482 --rw-r--r-- 12494 20 12494 20 \
16no-entry 14:50:01
------ 8X ------ 8X ------ begin cut here ---- 8X------ 8X ------
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
int
main(argc, argv)
int argc;
char *argv[];
{
int sem_id;
volatile union {
int val;
struct semid_ds *buf;
unsigned short *array;
} sem_un;
struct semid_ds sem_ds;
printf("real user id = %d\n", getuid());
printf("real group id = %d\n", getgid());
printf("effective user id = %d\n", geteuid());
printf("effective group id = %d\n", getegid());
if ((sem_id = semget(0x110172, 0, 0)) < 0) {
if ((sem_id = semget(0x110172, 16,
IPC_CREAT | IPC_EXCL | 0644)) < 0) {
perror("semget");
exit(EXIT_FAILURE);
}
}
printf("*** union ***\n");
sem_un.buf = &sem_ds;
if (semctl(sem_id, 0, IPC_STAT, sem_un) != 0) {
perror("semctl");
exit(EXIT_FAILURE);
}
printf("semaphore user id = %d\n"
" group id = %d\n"
" creator user id = %d\n"
" creator group id = %d\n"
" mode = %4o (%d)\n",
sem_ds.sem_perm.uid, sem_ds.sem_perm.gid,
sem_ds.sem_perm.cuid, sem_ds.sem_perm.cgid,
sem_ds.sem_perm.mode, sem_ds.sem_perm.mode);
printf("*** varargs ***\n");
if (semctl(sem_id, 0, IPC_STAT, &sem_ds) != 0) {
perror("semctl");
exit(EXIT_FAILURE);
}
printf("semaphore user id = %d\n"
" group id = %d\n"
" creator user id = %d\n"
" creator group id = %d\n"
" mode = %4o (%d)\n",
sem_ds.sem_perm.uid, sem_ds.sem_perm.gid,
sem_ds.sem_perm.cuid, sem_ds.sem_perm.cgid,
sem_ds.sem_perm.mode, sem_ds.sem_perm.mode);
printf("*** sleeping ***\n");
sleep(120);
if (semctl(sem_id, 0, IPC_RMID, sem_un) != 0) {
perror("semctl");
exit(EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
}
------ 8X ------ 8X ------ end cut here ----- 8X ------ 8X ------
>How-To-Repeat:
compile and run an above test code on your sparc running NetBSD-current.
>Fix:
I do't know.
>Audit-Trail:
>Unformatted: