Date: Sat, 4 Mar 2006 21:20:07 GMT From: "Pedro F. Giffuni" <giffunip@asme.org> To: freebsd-emulation@FreeBSD.org Subject: Re: kern/91293: [svr4] [patch] *Experimental* Update to the SVR4 emulation (from NetBSD) Message-ID: <200603042120.k24LK7a0049207@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/91293; it has been noted by GNATS. From: "Pedro F. Giffuni" <giffunip@asme.org> To: bug-followup@FreeBSD.org Cc: Subject: Re: kern/91293: [svr4] [patch] *Experimental* Update to the SVR4 emulation (from NetBSD) Date: Sat, 04 Mar 2006 16:15:15 -0500 I have greatly reduced the size and scope of the patch by removing all the code for 64bit emulation and things that don't apply to FreeBSd (IRIX defines). This is the log for the changes included: _______________________ svr4_filio.c -Bounds check syscall arguments where appropriate svr4_ioctl.c - Kill register declarations. svr4_misc.c - Add new sysconfig bits. - fix obvious bug in svr4_sys_resolvepath(): - fix NetBSD security/14444 - use strlcpy - PR/29696 not all filesystems support cookies. svr4_resource.c - Kill register declarations. svr4_signal.c - Remove returns after returns(!) svr4_stat.c: - Remove breaks after returns, unreachable returns and returns after returns(!). - use strlcpy - Fix the sysinfo(SI_HW_SERIAL, emulation so that we actually get the hostid of the machine rather than always getting "0". - Fix systeminfo. 1. return length is the string length even if the string would not fit. 2. add SI_ISALIST 3. on 32 bit emulation, don't return sparc64 as the arch! svr4_sysconfig.h - Add new sysconfig bits, Fix the bogus numbering of the old bits. ___________________________ diff -ru svr4.orig/svr4_filio.c svr4/svr4_filio.c --- svr4.orig/svr4_filio.c Tue Jan 3 16:41:01 2006 +++ svr4/svr4_filio.c Tue Jan 3 20:15:13 2006 @@ -209,6 +209,8 @@ *retval = 0; + if ((fp = fd_getfile(fdp, fd)) == NULL) + return EBADF; switch (cmd) { case SVR4_FIOCLEX: FILEDESC_LOCK_FAST(fdp); diff -ru svr4.orig/svr4_misc.c svr4/svr4_misc.c --- svr4.orig/svr4_misc.c Tue Jan 3 16:41:01 2006 +++ svr4/svr4_misc.c Tue Jan 3 21:33:41 2006 @@ -369,7 +369,7 @@ svr4_dirent.d_off = (svr4_off_t)(off + reclen); svr4_dirent.d_reclen = (u_short) svr4reclen; } - strcpy(svr4_dirent.d_name, bdp->d_name); + strlcpy(svr4_dirent.d_name, bdp->d_name, sizeof(svr4_dirent.d_name)); if ((error = copyout((caddr_t)&svr4_dirent, outp, svr4reclen))) goto out; inp += reclen; @@ -483,7 +483,10 @@ reclen = bdp->d_reclen; if (reclen & 3) panic("svr4_sys_getdents64: bad reclen"); - off = *cookie++; /* each entry points to the next */ + if (cookie) + off = *cookie++; /* each entry points to the next */ + else + off += reclen; if ((off >> 32) != 0) { uprintf("svr4_sys_getdents64: dir offset too large for emulated program"); error = EINVAL; @@ -507,7 +510,7 @@ idb.d_ino = (svr4_ino_t)bdp->d_fileno; idb.d_off = (svr4_off_t)off; idb.d_reclen = (u_short)svr4_reclen; - strcpy(idb.d_name, bdp->d_name); + strlcpy(idb.d_name, bdp->d_name,sizeof(idb.d_name)); if ((error = copyout((caddr_t)&idb, outp, svr4_reclen))) goto out; /* advance past this real entry */ @@ -781,7 +784,45 @@ #endif break; #endif /* NOTYET */ - + case SVR4_CONFIG_COHERENCY: + *retval = 0; /* XXX */ + break; + case SVR4_CONFIG_SPLIT_CACHE: + *retval = 0; /* XXX */ + break; + case SVR4_CONFIG_ICACHESZ: + *retval = 256; /* XXX */ + break; + case SVR4_CONFIG_DCACHESZ: + *retval = 256; /* XXX */ + break; + case SVR4_CONFIG_ICACHELINESZ: + *retval = 64; /* XXX */ + break; + case SVR4_CONFIG_DCACHELINESZ: + *retval = 64; /* XXX */ + break; + case SVR4_CONFIG_ICACHEBLKSZ: + *retval = 64; /* XXX */ + break; + case SVR4_CONFIG_DCACHEBLKSZ: + *retval = 64; /* XXX */ + break; + case SVR4_CONFIG_DCACHETBLKSZ: + *retval = 64; /* XXX */ + break; + case SVR4_CONFIG_ICACHE_ASSOC: + *retval = 1; /* XXX */ + break; + case SVR4_CONFIG_DCACHE_ASSOC: + *retval = 1; /* XXX */ + break; + case SVR4_CONFIG_MAXPID: + *retval = PID_MAX; + break; + case SVR4_CONFIG_STACK_PROT: + *retval = PROT_READ|PROT_WRITE|PROT_EXEC; + break; default: return EINVAL; } @@ -1254,16 +1295,16 @@ sx_xlock(&proctree_lock); PROC_LOCK(q); if (q->p_flag & P_TRACED) { - if (q->p_oppid != q->p_pptr->p_pid) { + if (q->p_opptr != q->p_pptr) { PROC_UNLOCK(q); - t = pfind(q->p_oppid); + t = q->p_opptr; if (t == NULL) { t = initproc; PROC_LOCK(initproc); } PROC_LOCK(q); proc_reparent(q, t); - q->p_oppid = 0; + q->p_opptr = NULL; q->p_flag &= ~(P_TRACED | P_WAITED); PROC_UNLOCK(q); psignal(t, SIGCHLD); @@ -1664,6 +1705,6 @@ *retval = ncopy; bad: NDFREE(&nd, NDF_ONLY_PNBUF); - vput(nd.ni_vp); + vrele(nd.ni_vp); return error; } diff -ru svr4.orig/svr4_resource.c svr4/svr4_resource.c --- svr4.orig/svr4_resource.c Tue Jan 3 16:41:01 2006 +++ svr4/svr4_resource.c Tue Jan 3 18:27:46 2006 @@ -127,7 +127,7 @@ int svr4_sys_getrlimit(td, uap) - register struct thread *td; + struct thread *td; struct svr4_sys_getrlimit_args *uap; { int rl = svr4_to_native_rl(uap->which); @@ -174,7 +174,7 @@ int svr4_sys_setrlimit(td, uap) - register struct thread *td; + struct thread *td; struct svr4_sys_setrlimit_args *uap; { int rl = svr4_to_native_rl(uap->which); @@ -225,7 +225,7 @@ int svr4_sys_getrlimit64(td, uap) - register struct thread *td; + struct thread *td; struct svr4_sys_getrlimit64_args *uap; { int rl = svr4_to_native_rl(uap->which); @@ -272,7 +272,7 @@ int svr4_sys_setrlimit64(td, uap) - register struct thread *td; + struct thread *td; struct svr4_sys_setrlimit64_args *uap; { int rl = svr4_to_native_rl(uap->which); diff -ru svr4.orig/svr4_signal.c svr4/svr4_signal.c --- svr4.orig/svr4_signal.c Tue Jan 3 16:41:01 2006 +++ svr4/svr4_signal.c Tue Jan 3 21:59:52 2006 @@ -560,7 +560,6 @@ uap->uc)); return ENOSYS; } - return 0; } int diff -ru svr4.orig/svr4_socket.c svr4/svr4_socket.c --- svr4.orig/svr4_socket.c Tue Jan 3 16:41:01 2006 +++ svr4/svr4_socket.c Tue Jan 3 18:44:04 2006 @@ -114,7 +114,8 @@ struct stat *st; { struct svr4_sockcache_entry *e; - int len, error; + size_t len; + int error; mtx_lock(&Giant); diff -ru svr4.orig/svr4_stat.c svr4/svr4_stat.c --- svr4.orig/svr4_stat.c Tue Jan 3 16:41:01 2006 +++ svr4/svr4_stat.c Tue Jan 3 19:33:39 2006 @@ -444,9 +450,21 @@ case SVR4_SI_ARCHITECTURE: str = machine; break; + case SVR4_SI_ISALIST: +#if defined(__sparc__) + str = "sparcv9 sparcv9-fsmuld sparcv8 sparcv8-fsmuld sparcv7 sparc"; +#elif defined(__i386__) + str = "i386"; +#elif defined(__amd64__) + str = "amd64"; +#else + str = "unknown"; + #endif + break; case SVR4_SI_HW_SERIAL: - str = "0"; + snprintf(buf, sizeof(buf), "%lu", hostid); + str = buf; break; case SVR4_SI_HW_PROVIDER: @@ -543,7 +561,6 @@ default: return ENOSYS; } - return ENOSYS; } diff -ru svr4.orig/svr4_sysconfig.h svr4/svr4_sysconfig.h --- svr4.orig/svr4_sysconfig.h Tue Jan 3 16:41:01 2006 +++ svr4/svr4_sysconfig.h Tue Jan 3 22:25:50 2006 @@ -43,20 +43,36 @@ #define SVR4_CONFIG_PROF_TCK 0x0a #define SVR4_CONFIG_NPROC_CONF 0x0b #define SVR4_CONFIG_NPROC_ONLN 0x0c -#define SVR4_CONFIG_AIO_LISTIO_MAX 0x0e -#define SVR4_CONFIG_AIO_MAX 0x0f -#define SVR4_CONFIG_AIO_PRIO_DELTA_MAX 0x10 -#define SVR4_CONFIG_DELAYTIMER_MAX 0x11 -#define SVR4_CONFIG_MQ_OPEN_MAX 0x12 -#define SVR4_CONFIG_MQ_PRIO_MAX 0x13 -#define SVR4_CONFIG_RTSIG_MAX 0x14 -#define SVR4_CONFIG_SEM_NSEMS_MAX 0x15 -#define SVR4_CONFIG_SEM_VALUE_MAX 0x16 -#define SVR4_CONFIG_SIGQUEUE_MAX 0x17 -#define SVR4_CONFIG_SIGRT_MIN 0x18 -#define SVR4_CONFIG_SIGRT_MAX 0x19 -#define SVR4_CONFIG_TIMER_MAX 0x20 -#define SVR4_CONFIG_PHYS_PAGES 0x21 -#define SVR4_CONFIG_AVPHYS_PAGES 0x22 +#define SVR4_CONFIG_AIO_LISTIO_MAX 0x0d +#define SVR4_CONFIG_AIO_MAX 0x0e +#define SVR4_CONFIG_AIO_PRIO_DELTA_MAX 0x0f +#define SVR4_CONFIG_DELAYTIMER_MAX 0x10 +#define SVR4_CONFIG_MQ_OPEN_MAX 0x11 +#define SVR4_CONFIG_MQ_PRIO_MAX 0x12 +#define SVR4_CONFIG_RTSIG_MAX 0x13 +#define SVR4_CONFIG_SEM_NSEMS_MAX 0x14 +#define SVR4_CONFIG_SEM_VALUE_MAX 0x15 +#define SVR4_CONFIG_SIGQUEUE_MAX 0x16 +#define SVR4_CONFIG_SIGRT_MIN 0x17 +#define SVR4_CONFIG_SIGRT_MAX 0x18 +#define SVR4_CONFIG_TIMER_MAX 0x19 +#define SVR4_CONFIG_PHYS_PAGES 0x1a +#define SVR4_CONFIG_AVPHYS_PAGES 0x1b +#define SVR4_CONFIG_COHERENCY 0x1c +#define SVR4_CONFIG_SPLIT_CACHE 0x1d +#define SVR4_CONFIG_ICACHESZ 0x1e +#define SVR4_CONFIG_DCACHESZ 0x1f +#define SVR4_CONFIG_ICACHELINESZ 0x20 +#define SVR4_CONFIG_DCACHELINESZ 0x21 +#define SVR4_CONFIG_ICACHEBLKSZ 0x22 +#define SVR4_CONFIG_DCACHEBLKSZ 0x23 +#define SVR4_CONFIG_DCACHETBLKSZ 0x24 +#define SVR4_CONFIG_ICACHE_ASSOC 0x25 +#define SVR4_CONFIG_DCACHE_ASSOC 0x26 +#define SVR4_CONFIG_UNUSED_2 0x27 +#define SVR4_CONFIG_UNUSED_3 0x28 +#define SVR4_CONFIG_UNUSED_4 0x29 +#define SVR4_CONFIG_MAXPID 0x2a +#define SVR4_CONFIG_STACK_PROT 0x2b #endif /* !_SVR4_SYSCONFIG_H_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200603042120.k24LK7a0049207>