From cb07db94bba25f87536fa0d3648e9fc17fdad649 Mon Sep 17 00:00:00 2001 From: Lauri Tirkkonen Date: Mon, 11 Mar 2019 21:54:41 +0200 Subject: [PATCH] kernel: remove unused lseek32,getrlimit32,setrlimit32,getdents32,smmap32 --- kernel/os/grow.c | 27 ------ kernel/os/sysent.c | 5 - kernel/syscall/getdents.c | 136 -------------------------- kernel/syscall/lseek.c | 37 +------ kernel/syscall/rlimit.c | 182 ----------------------------------- usr/src/uts/common/io/drm/drm_bufs.c | 7 +- 6 files changed, 2 insertions(+), 392 deletions(-) diff --git a/kernel/os/grow.c b/kernel/os/grow.c index e922f44b93..03316342f0 100644 --- a/kernel/os/grow.c +++ b/kernel/os/grow.c @@ -884,33 +884,6 @@ smmap64(caddr_t addr, size_t len, int prot, int flags, int fd, off_t pos) #if defined(_SYSCALL32_IMPL) || defined(_ILP32) /* - * ILP32 mmap(2) system call: 32-bit offset, 32-bit address. - */ -caddr_t -smmap32(caddr32_t addr, size32_t len, int prot, int flags, int fd, off32_t pos) -{ - struct file *fp; - int error; - caddr_t a = (caddr_t)(uintptr_t)addr; - - if (flags & _MAP_LOW32) - error = EINVAL; - else if (fd == -1 && (flags & MAP_ANON) != 0) - error = smmap_common(&a, (size_t)len, prot, - flags | _MAP_LOW32, NULL, (offset_t)pos); - else if ((fp = getf(fd)) != NULL) { - error = smmap_common(&a, (size_t)len, prot, - flags | _MAP_LOW32, fp, (offset_t)pos); - releasef(fd); - } else - error = EBADF; - - ASSERT(error != 0 || (uintptr_t)(a + len) < (uintptr_t)UINT32_MAX); - - return (error ? (caddr_t)(uintptr_t)set_errno(error) : a); -} - -/* * ILP32 mmap64(2) system call: 64-bit offset, 32-bit address. * * Now things really get ugly because we can't use the C-style diff --git a/kernel/os/sysent.c b/kernel/os/sysent.c index f55b183fe8..a06ac96a56 100644 --- a/kernel/os/sysent.c +++ b/kernel/os/sysent.c @@ -86,7 +86,6 @@ int hrtsys(struct hrtsysa *, rval_t *); int ioctl(int, int, intptr_t); int kill(); int linkat(int, char *, int, char *, int); -off32_t lseek32(int32_t, off32_t, int32_t); off_t lseek64(int, off_t, int); int lgrpsys(int, long, void *); int mmapobjsys(int, uint_t, mmapobj_result_t *, uint_t *, void *); @@ -125,8 +124,6 @@ int syssync(); int sysacct(char *); clock_t times(struct tms *); long ulimit(int, long); -int getrlimit32(int, struct rlimit32 *); -int setrlimit32(int, struct rlimit32 *); int umask(int); int umount2(char *, int); int unlinkat(int, char *, int); @@ -142,7 +139,6 @@ ssize_t preadv(int, struct iovec *, int, off_t, off_t); ssize_t pwritev(int, struct iovec *, int, off_t, off_t); int syslwp_park(int, uintptr_t, uintptr_t); int mkdirat(int, char *, int); -int getdents32(int, void *, size_t); int statfs32(char *, struct statfs32 *, int32_t, int32_t); int fstatfs32(int32_t, struct statfs32 *, int32_t, int32_t); int sysfs(int, long, long); @@ -172,7 +168,6 @@ int waitsys(idtype_t, id_t, siginfo_t *, int); int sigsendsys(procset_t *, int); int mincore(caddr_t, size_t, char *); caddr_t smmap64(caddr_t, size_t, int, int, int, off_t); -caddr_t smmap32(caddr32_t, size32_t, int, int, int, off32_t); int smmaplf32(struct mmaplf32a *, rval_t *); int mprotect(caddr_t, size_t, int); int munmap(caddr_t, size_t); diff --git a/kernel/syscall/getdents.c b/kernel/syscall/getdents.c index 7a45fc86ae..314b2d6e1c 100644 --- a/kernel/syscall/getdents.c +++ b/kernel/syscall/getdents.c @@ -49,142 +49,6 @@ #include #include -#if defined(_SYSCALL32_IMPL) || defined(_ILP32) - -/* - * Get directory entries in a file system-independent format. - * - * The 32-bit version of this function now allocates a buffer to grab the - * directory entries in dirent64 formats from fop_readdir routines. - * The dirent64 structures are converted to dirent32 structures and - * copied to the user space. - * - * Both 32-bit and 64-bit versions of libc use getdents64() and therefore - * we don't expect any major performance impact due to the extra kmem_alloc's - * and copying done in this routine. - */ - -/* - * Native 32-bit system call for non-large-file applications. - */ -int -getdents32(int fd, void *buf, size_t count) -{ - vnode_t *vp; - file_t *fp; - struct uio auio; - struct iovec aiov; - register int error; - int sink; - char *newbuf; - char *obuf; - int bufsize; - int osize, nsize; - struct dirent64 *dp; - struct dirent32 *op; - - if (count < sizeof (struct dirent32)) - return (set_errno(EINVAL)); - - if ((fp = getf(fd)) == NULL) - return (set_errno(EBADF)); - vp = fp->f_vnode; - if (vp->v_type != VDIR) { - releasef(fd); - return (set_errno(ENOTDIR)); - } - if (!(fp->f_flag & FREAD)) { - releasef(fd); - return (set_errno(EBADF)); - } - - /* - * Don't let the user overcommit kernel resources. - */ - if (count > MAXGETDENTS_SIZE) - count = MAXGETDENTS_SIZE; - - bufsize = count; - newbuf = kmem_alloc(bufsize, KM_SLEEP); - obuf = kmem_alloc(bufsize, KM_SLEEP); - - aiov.iov_base = newbuf; - aiov.iov_len = count; - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - auio.uio_loffset = fp->f_offset; - auio.uio_segflg = UIO_SYSSPACE; - auio.uio_resid = count; - auio.uio_fmode = 0; - auio.uio_extflg = UIO_COPY_CACHED; - (void) fop_rwlock(vp, V_WRITELOCK_FALSE, NULL); - error = fop_readdir(vp, &auio, fp->f_cred, &sink, NULL, 0); - fop_rwunlock(vp, V_WRITELOCK_FALSE, NULL); - if (error) - goto out; - count = count - auio.uio_resid; - fp->f_offset = auio.uio_loffset; - - dp = (struct dirent64 *)newbuf; - op = (struct dirent32 *)obuf; - osize = 0; - nsize = 0; - - while (nsize < count) { - uint32_t reclen, namlen; - - /* - * This check ensures that the 64 bit d_ino and d_off - * fields will fit into their 32 bit equivalents. - * - * Although d_off is a signed value, the check is done - * against the full 32 bits because certain file systems, - * NFS for one, allow directory cookies to use the full - * 32 bits. We use uint64_t because there is no exact - * unsigned analog to the off64_t type of dp->d_off. - */ - if (dp->d_ino > (ino64_t)UINT32_MAX || - dp->d_off > (uint64_t)UINT32_MAX) { - error = EOVERFLOW; - goto out; - } - op->d_ino = (ino32_t)dp->d_ino; - op->d_off = (off32_t)dp->d_off; - namlen = strlen(dp->d_name); - reclen = DIRENT32_RECLEN(namlen); - op->d_reclen = (uint16_t)reclen; - - /* use strncpy(9f) to zero out uninitialized bytes */ - - (void) strncpy(op->d_name, dp->d_name, - DIRENT32_NAMELEN(reclen)); - nsize += (uint_t)dp->d_reclen; - osize += (uint_t)op->d_reclen; - dp = (struct dirent64 *)((char *)dp + (uint_t)dp->d_reclen); - op = (struct dirent32 *)((char *)op + (uint_t)op->d_reclen); - } - - ASSERT(osize <= count); - ASSERT((char *)op <= (char *)obuf + bufsize); - ASSERT((char *)dp <= (char *)newbuf + bufsize); - - if ((error = copyout(obuf, buf, osize)) < 0) - error = EFAULT; -out: - kmem_free(newbuf, bufsize); - kmem_free(obuf, bufsize); - - if (error) { - releasef(fd); - return (set_errno(error)); - } - - releasef(fd); - return (osize); -} - -#endif /* _SYSCALL32 || _ILP32 */ - int getdents64(int fd, void *buf, size_t count) { diff --git a/kernel/syscall/lseek.c b/kernel/syscall/lseek.c index 488fd099e8..b262dc52ee 100644 --- a/kernel/syscall/lseek.c +++ b/kernel/syscall/lseek.c @@ -61,7 +61,7 @@ #if defined(_SYSCALL32_IMPL) || defined(_ILP32) /* - * Workhorse for the 32-bit seek variants: lseek32 and llseek32 + * Workhorse for 32-bit llseek32 * * 'max' represents the maximum possible representation of offset * in the data type corresponding to lseek and llseek. It is @@ -202,41 +202,6 @@ out: return (error); } -off32_t -lseek32(int32_t fdes, off32_t off, int32_t stype) -{ - file_t *fp; - int error; - offset_t retoff; - - if ((fp = getf(fdes)) == NULL) - return ((off32_t)set_errno(EBADF)); - - /* - * lseek32 returns EOVERFLOW if we cannot represent the resulting - * offset from seek in a 32-bit off_t. - * The following routines are sensitive to sign extensions and - * calculations and if ever you change this make sure it works for - * special files. - * - * When VREG is not set we do the check for stype != SEEK_SET - * to send the unsigned value to lseek_common and not the sign - * extended value. (The maximum representable value is not - * checked by lseek_common for special files.) - */ - if (fp->f_vnode->v_type == VREG || stype != SEEK_SET) - error = lseek32_common(fp, stype, (offset_t)off, - (offset_t)MAXOFF32_T, &retoff); - else if (stype == SEEK_SET) - error = lseek32_common(fp, stype, (offset_t)(uint_t)off, - (offset_t)(uint_t)UINT_MAX, &retoff); - - releasef(fdes); - if (!error) - return ((off32_t)retoff); - return ((off32_t)set_errno(error)); -} - /* * 64-bit seeks from 32-bit applications */ diff --git a/kernel/syscall/rlimit.c b/kernel/syscall/rlimit.c index 9b7b6ffee6..f23ea7c430 100644 --- a/kernel/syscall/rlimit.c +++ b/kernel/syscall/rlimit.c @@ -256,188 +256,6 @@ ulimit32(int cmd, int arg) #endif /* _SYSCALL32_IMPL */ -#if defined(_ILP32) || defined(_SYSCALL32_IMPL) - -/* - * Large Files: getrlimit returns RLIM_SAVED_CUR or RLIM_SAVED_MAX when - * rlim_cur or rlim_max is not representable in 32-bit rlim_t. These - * values are just tokens which will be used in setrlimit to set the - * correct limits. The current limits are saved in the saved_rlimit members - * in user structures when the token is returned. setrlimit restores - * the limit values to these saved values when the token is passed. - * Consider the following common scenario of the apps: - * - * limit = getrlimit(); - * savedlimit = limit; - * limit = limit1; - * setrlimit(limit) - * // execute all processes in the new rlimit state. - * setrlimit(savedlimit) // restore the old values. - * - * Most apps don't check error returns from getrlimit or setrlimit - * and this is why we return tokens when the correct value - * cannot be represented in rlim_t. For more discussion refer to - * the LFS API document. - * - * In the 64-bit kernel, all existing resource limits are treated in this - * manner. In the 32-bit kernel, CPU time is treated equivalently to the - * file size limit above; the VM-related limits are not. The macro, - * RLIM_SAVED(x), returns true if the resource limit should be handled in - * this way on the current kernel. - */ -int -getrlimit32(int resource, struct rlimit32 *rlp) -{ - struct rlimit32 rlim32; - struct rlimit64 rlim64; - struct proc *p = curproc; - struct user *up = PTOU(p); - int savecur = 0; - int savemax = 0; - - if (resource < 0 || resource >= RLIM_NLIMITS) - return (set_errno(EINVAL)); - - mutex_enter(&p->p_lock); - (void) rctl_rlimit_get(rctlproc_legacy[resource], p, &rlim64); - mutex_exit(&p->p_lock); - - if (rlim64.rlim_max > (rlim64_t)UINT32_MAX) { - - if (rlim64.rlim_max == RLIM64_INFINITY) - rlim32.rlim_max = RLIM32_INFINITY; - else { - savemax = 1; - rlim32.rlim_max = RLIM32_SAVED_MAX; - /*CONSTCOND*/ - ASSERT(RLIM_SAVED(resource)); - } - - if (rlim64.rlim_cur == RLIM64_INFINITY) - rlim32.rlim_cur = RLIM32_INFINITY; - else if (rlim64.rlim_cur == rlim64.rlim_max) { - savecur = 1; - rlim32.rlim_cur = RLIM32_SAVED_MAX; - /*CONSTCOND*/ - ASSERT(RLIM_SAVED(resource)); - } else if (rlim64.rlim_cur > (rlim64_t)UINT32_MAX) { - savecur = 1; - rlim32.rlim_cur = RLIM32_SAVED_CUR; - /*CONSTCOND*/ - ASSERT(RLIM_SAVED(resource)); - } else - rlim32.rlim_cur = rlim64.rlim_cur; - - /* - * save the current limits in user structure. - */ - /*CONSTCOND*/ - if (RLIM_SAVED(resource)) { - mutex_enter(&p->p_lock); - if (savemax) - up->u_saved_rlimit[resource].rlim_max = - rlim64.rlim_max; - if (savecur) - up->u_saved_rlimit[resource].rlim_cur = - rlim64.rlim_cur; - mutex_exit(&p->p_lock); - } - } else { - ASSERT(rlim64.rlim_cur <= (rlim64_t)UINT32_MAX); - rlim32.rlim_max = rlim64.rlim_max; - rlim32.rlim_cur = rlim64.rlim_cur; - } - - if (copyout(&rlim32, rlp, sizeof (rlim32))) - return (set_errno(EFAULT)); - - return (0); -} - -/* - * See comments above getrlimit32(). When the tokens are passed in the - * rlimit structure the values are considered equal to the values - * stored in saved_rlimit members of user structure. - * When the user passes RLIM_INFINITY to set the resource limit to - * unlimited internally understand this value as RLIM64_INFINITY and - * let rlimit() do the job. - */ -int -setrlimit32(int resource, struct rlimit32 *rlp) -{ - struct rlimit32 rlim32; - struct rlimit64 rlim64; - struct rlimit64 saved_rlim; - int error; - struct proc *p = ttoproc(curthread); - struct user *up = PTOU(p); - rctl_alloc_gp_t *gp; - - if (resource < 0 || resource >= RLIM_NLIMITS) - return (set_errno(EINVAL)); - if (copyin(rlp, &rlim32, sizeof (rlim32))) - return (set_errno(EFAULT)); - - gp = rctl_rlimit_set_prealloc(1); - - /* - * Disallow resource limit tunnelling - */ - /*CONSTCOND*/ - if (RLIM_SAVED(resource)) { - mutex_enter(&p->p_lock); - saved_rlim = up->u_saved_rlimit[resource]; - mutex_exit(&p->p_lock); - } else { - saved_rlim.rlim_max = (rlim64_t)rlim32.rlim_max; - saved_rlim.rlim_cur = (rlim64_t)rlim32.rlim_cur; - } - - switch (rlim32.rlim_cur) { - case RLIM32_INFINITY: - rlim64.rlim_cur = RLIM64_INFINITY; - break; - case RLIM32_SAVED_CUR: - rlim64.rlim_cur = saved_rlim.rlim_cur; - break; - case RLIM32_SAVED_MAX: - rlim64.rlim_cur = saved_rlim.rlim_max; - break; - default: - rlim64.rlim_cur = (rlim64_t)rlim32.rlim_cur; - break; - } - - switch (rlim32.rlim_max) { - case RLIM32_INFINITY: - rlim64.rlim_max = RLIM64_INFINITY; - break; - case RLIM32_SAVED_MAX: - rlim64.rlim_max = saved_rlim.rlim_max; - break; - case RLIM32_SAVED_CUR: - rlim64.rlim_max = saved_rlim.rlim_cur; - break; - default: - rlim64.rlim_max = (rlim64_t)rlim32.rlim_max; - break; - } - - mutex_enter(&p->p_lock); - if (error = rctl_rlimit_set(rctlproc_legacy[resource], p, &rlim64, gp, - rctlproc_flags[resource], rctlproc_signals[resource], CRED())) { - mutex_exit(&p->p_lock); - rctl_prealloc_destroy(gp); - return (set_errno(error)); - } - mutex_exit(&p->p_lock); - rctl_prealloc_destroy(gp); - - return (0); -} - -#endif /* _ILP32 && _SYSCALL32_IMPL */ - int getrlimit64(int resource, struct rlimit64 *rlp) { diff --git a/usr/src/uts/common/io/drm/drm_bufs.c b/usr/src/uts/common/io/drm/drm_bufs.c index c00a714f59..517acbbb0a 100644 --- a/usr/src/uts/common/io/drm/drm_bufs.c +++ b/usr/src/uts/common/io/drm/drm_bufs.c @@ -763,12 +763,7 @@ drm_freebufs(DRM_IOCTL_ARGS) extern caddr_t smmap64(caddr_t, size_t, int, int, int, off_t); #define drm_smmap smmap64 #else -#if defined(_SYSCALL32_IMPL) || defined(_ILP32) -extern caddr_t smmap32(caddr32_t, size32_t, int, int, int, off32_t); -#define drm_smmap smmap32 -#else -#error "No define for _LP64, _SYSCALL32_IMPL or _ILP32" -#endif +#error "No define for _LP64" #endif -- 2.11.4.GIT