Subject: compat bugfix verification needed
To: None <tech-kern@NetBSD.ORG>
From: Scott Bartram <scottb@orionsoft.com>
List: tech-kern
Date: 02/13/1998 15:15:00
In tracking down some iBCS2 emulation bugs with semaphores, I've
think I've found the problem but I can't test the fix on all of
the affected emulations - COMPAT_{FREEBSD,SUNOS}.

Also, the same bug I've found is present in the emulation code
for COMPAT_{SVR4,LINUX}.

If nobody screams, I'll commit this and fix the other affected
code.

scott

-------
*** kern_ipc_10.c.orig	Thu Feb 12 11:05:05 1998
--- kern_ipc_10.c	Thu Feb 12 11:24:58 1998
***************
*** 40,45 ****
--- 40,47 ----
  #include <sys/mount.h>
  #include <sys/syscallargs.h>
  
+ #include <compat/common/compat_util.h>
+ 
  #include <vm/vm.h>
  #include <vm/vm_map.h>
  #include <vm/vm_map.h>
***************
*** 78,90 ****
  	struct sys_semconfig_args /* {
  		syscallarg(int) flag;
  	} */ semconfig_args;
  
  	switch (SCARG(uap, which)) {
  	case 0:						/* __semctl() */
  		SCARG(&__semctl_args, semid) = SCARG(uap, a2);
  		SCARG(&__semctl_args, semnum) = SCARG(uap, a3);
  		SCARG(&__semctl_args, cmd) = SCARG(uap, a4);
! 		SCARG(&__semctl_args, arg) = (union semun *)SCARG(uap, a5);
  		return (sys___semctl(p, &__semctl_args, retval));
  
  	case 1:						/* semget() */
--- 80,96 ----
  	struct sys_semconfig_args /* {
  		syscallarg(int) flag;
  	} */ semconfig_args;
+ 	caddr_t sg = stackgap_init(p->p_emul);
  
  	switch (SCARG(uap, which)) {
  	case 0:						/* __semctl() */
  		SCARG(&__semctl_args, semid) = SCARG(uap, a2);
  		SCARG(&__semctl_args, semnum) = SCARG(uap, a3);
  		SCARG(&__semctl_args, cmd) = SCARG(uap, a4);
! 		SCARG(&__semctl_args, arg) = stackgap_alloc(&sg,
! 			sizeof(union semun *));
! 		bcopy(&SCARG(uap, a5), SCARG(&__semctl_args, arg),
! 			sizeof(union semun));
  		return (sys___semctl(p, &__semctl_args, retval));
  
  	case 1:						/* semget() */
-----