Date: Wed, 18 Sep 2013 18:48:33 +0000 (UTC) From: Roman Divacky <rdivacky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r255675 - in head/sys: amd64/linux32 compat/linux conf i386/linux kern modules/linux sys Message-ID: <201309181848.r8IImXfi081608@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rdivacky Date: Wed Sep 18 18:48:33 2013 New Revision: 255675 URL: http://svnweb.freebsd.org/changeset/base/255675 Log: Revert r255672, it has some serious flaws, leaking file references etc. Approved by: re (delphij) Deleted: head/sys/compat/linux/linux_epoll.c head/sys/compat/linux/linux_epoll.h Modified: head/sys/amd64/linux32/linux32_dummy.c head/sys/amd64/linux32/syscalls.master head/sys/conf/files.amd64 head/sys/conf/files.i386 head/sys/conf/files.pc98 head/sys/i386/linux/linux_dummy.c head/sys/i386/linux/syscalls.master head/sys/kern/kern_event.c head/sys/modules/linux/Makefile head/sys/sys/event.h head/sys/sys/file.h head/sys/sys/syscallsubr.h Modified: head/sys/amd64/linux32/linux32_dummy.c ============================================================================== --- head/sys/amd64/linux32/linux32_dummy.c Wed Sep 18 18:02:01 2013 (r255674) +++ head/sys/amd64/linux32/linux32_dummy.c Wed Sep 18 18:48:33 2013 (r255675) @@ -70,6 +70,9 @@ DUMMY(pivot_root); DUMMY(mincore); DUMMY(ptrace); DUMMY(lookup_dcookie); +DUMMY(epoll_create); +DUMMY(epoll_ctl); +DUMMY(epoll_wait); DUMMY(remap_file_pages); DUMMY(timer_create); DUMMY(timer_settime); @@ -126,6 +129,7 @@ DUMMY(timerfd_gettime); /* linux 2.6.27: */ DUMMY(signalfd4); DUMMY(eventfd2); +DUMMY(epoll_create1); DUMMY(dup3); DUMMY(inotify_init1); /* linux 2.6.30: */ Modified: head/sys/amd64/linux32/syscalls.master ============================================================================== --- head/sys/amd64/linux32/syscalls.master Wed Sep 18 18:02:01 2013 (r255674) +++ head/sys/amd64/linux32/syscalls.master Wed Sep 18 18:48:33 2013 (r255675) @@ -430,11 +430,9 @@ 251 AUE_NULL UNIMPL 252 AUE_EXIT STD { int linux_exit_group(int error_code); } 253 AUE_NULL STD { int linux_lookup_dcookie(void); } -254 AUE_NULL STD { int linux_epoll_create(l_int size); } -255 AUE_NULL STD { int linux_epoll_ctl(l_int epfd, l_int op, l_int fd, \ - struct linux_epoll_event *event); } -256 AUE_NULL STD { int linux_epoll_wait(l_int epfd, struct linux_epoll_event *events, \ - l_int maxevents, l_int timeout); } +254 AUE_NULL STD { int linux_epoll_create(void); } +255 AUE_NULL STD { int linux_epoll_ctl(void); } +256 AUE_NULL STD { int linux_epoll_wait(void); } 257 AUE_NULL STD { int linux_remap_file_pages(void); } 258 AUE_NULL STD { int linux_set_tid_address(int *tidptr); } 259 AUE_NULL STD { int linux_timer_create(void); } @@ -536,7 +534,7 @@ ; linux 2.6.27: 327 AUE_NULL STD { int linux_signalfd4(void); } 328 AUE_NULL STD { int linux_eventfd2(void); } -329 AUE_NULL STD { int linux_epoll_create1(l_int flags); } +329 AUE_NULL STD { int linux_epoll_create1(void); } 330 AUE_NULL STD { int linux_dup3(void); } 331 AUE_NULL STD { int linux_pipe2(l_int *pipefds, l_int flags); } 332 AUE_NULL STD { int linux_inotify_init1(void); } Modified: head/sys/conf/files.amd64 ============================================================================== --- head/sys/conf/files.amd64 Wed Sep 18 18:02:01 2013 (r255674) +++ head/sys/conf/files.amd64 Wed Sep 18 18:48:33 2013 (r255675) @@ -467,7 +467,6 @@ amd64/linux32/linux32_support.s optional dependency "linux32_assym.h" amd64/linux32/linux32_sysent.c optional compat_linux32 amd64/linux32/linux32_sysvec.c optional compat_linux32 -compat/linux/linux_epoll.c optional compat_linux32 compat/linux/linux_emul.c optional compat_linux32 compat/linux/linux_file.c optional compat_linux32 compat/linux/linux_fork.c optional compat_linux32 Modified: head/sys/conf/files.i386 ============================================================================== --- head/sys/conf/files.i386 Wed Sep 18 18:02:01 2013 (r255674) +++ head/sys/conf/files.i386 Wed Sep 18 18:48:33 2013 (r255675) @@ -80,7 +80,6 @@ hptrr_lib.o optional hptrr \ cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S optional zfs compile-with "${ZFS_S}" compat/linprocfs/linprocfs.c optional linprocfs compat/linsysfs/linsysfs.c optional linsysfs -compat/linux/linux_epoll.c optional compat_linux compat/linux/linux_emul.c optional compat_linux compat/linux/linux_file.c optional compat_linux compat/linux/linux_fork.c optional compat_linux Modified: head/sys/conf/files.pc98 ============================================================================== --- head/sys/conf/files.pc98 Wed Sep 18 18:02:01 2013 (r255674) +++ head/sys/conf/files.pc98 Wed Sep 18 18:48:33 2013 (r255675) @@ -41,7 +41,6 @@ ukbdmap.h optional ukbd_dflt_keymap \ cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S optional zfs compile-with "${ZFS_S}" compat/linprocfs/linprocfs.c optional linprocfs compat/linsysfs/linsysfs.c optional linsysfs -compat/linux/linux_epoll.c optional compat_linux compat/linux/linux_emul.c optional compat_linux compat/linux/linux_file.c optional compat_linux compat/linux/linux_fork.c optional compat_linux Modified: head/sys/i386/linux/linux_dummy.c ============================================================================== --- head/sys/i386/linux/linux_dummy.c Wed Sep 18 18:02:01 2013 (r255674) +++ head/sys/i386/linux/linux_dummy.c Wed Sep 18 18:48:33 2013 (r255675) @@ -72,6 +72,9 @@ DUMMY(setfsgid); DUMMY(pivot_root); DUMMY(mincore); DUMMY(lookup_dcookie); +DUMMY(epoll_create); +DUMMY(epoll_ctl); +DUMMY(epoll_wait); DUMMY(remap_file_pages); DUMMY(fstatfs64); DUMMY(mbind); @@ -117,6 +120,7 @@ DUMMY(timerfd_gettime); /* linux 2.6.27: */ DUMMY(signalfd4); DUMMY(eventfd2); +DUMMY(epoll_create1); DUMMY(dup3); DUMMY(inotify_init1); /* linux 2.6.30: */ Modified: head/sys/i386/linux/syscalls.master ============================================================================== --- head/sys/i386/linux/syscalls.master Wed Sep 18 18:02:01 2013 (r255674) +++ head/sys/i386/linux/syscalls.master Wed Sep 18 18:48:33 2013 (r255675) @@ -432,11 +432,9 @@ 251 AUE_NULL UNIMPL 252 AUE_EXIT STD { int linux_exit_group(int error_code); } 253 AUE_NULL STD { int linux_lookup_dcookie(void); } -254 AUE_NULL STD { int linux_epoll_create(l_int size); } -255 AUE_NULL STD { int linux_epoll_ctl(l_int epfd, l_int op, l_int fd, \ - struct linux_epoll_event *event); } -256 AUE_NULL STD { int linux_epoll_wait(l_int epfd, struct linux_epoll_event *events, \ - l_int maxevents, l_int timeout); } +254 AUE_NULL STD { int linux_epoll_create(void); } +255 AUE_NULL STD { int linux_epoll_ctl(void); } +256 AUE_NULL STD { int linux_epoll_wait(void); } 257 AUE_NULL STD { int linux_remap_file_pages(void); } 258 AUE_NULL STD { int linux_set_tid_address(int *tidptr); } 259 AUE_NULL STD { int linux_timer_create(clockid_t clock_id, \ @@ -546,7 +544,7 @@ ; linux 2.6.27: 327 AUE_NULL STD { int linux_signalfd4(void); } 328 AUE_NULL STD { int linux_eventfd2(void); } -329 AUE_NULL STD { int linux_epoll_create1(l_int flags); } +329 AUE_NULL STD { int linux_epoll_create1(void); } 330 AUE_NULL STD { int linux_dup3(void); } 331 AUE_NULL STD { int linux_pipe2(l_int *pipefds, l_int flags); } 332 AUE_NULL STD { int linux_inotify_init1(void); } Modified: head/sys/kern/kern_event.c ============================================================================== --- head/sys/kern/kern_event.c Wed Sep 18 18:02:01 2013 (r255674) +++ head/sys/kern/kern_event.c Wed Sep 18 18:48:33 2013 (r255675) @@ -107,7 +107,16 @@ static void kqueue_wakeup(struct kqueue static struct filterops *kqueue_fo_find(int filt); static void kqueue_fo_release(int filt); -struct fileops kqueueops = { +static fo_rdwr_t kqueue_read; +static fo_rdwr_t kqueue_write; +static fo_truncate_t kqueue_truncate; +static fo_ioctl_t kqueue_ioctl; +static fo_poll_t kqueue_poll; +static fo_kqfilter_t kqueue_kqfilter; +static fo_stat_t kqueue_stat; +static fo_close_t kqueue_close; + +static struct fileops kqueueops = { .fo_read = kqueue_read, .fo_write = kqueue_write, .fo_truncate = kqueue_truncate, @@ -294,7 +303,7 @@ filt_fileattach(struct knote *kn) } /*ARGSUSED*/ -int +static int kqueue_kqfilter(struct file *fp, struct knote *kn) { struct kqueue *kq = kn->kn_fp->f_data; @@ -679,7 +688,34 @@ filt_usertouch(struct knote *kn, struct int sys_kqueue(struct thread *td, struct kqueue_args *uap) { - return (kern_kqueue(td)); + struct filedesc *fdp; + struct kqueue *kq; + struct file *fp; + int fd, error; + + fdp = td->td_proc->p_fd; + error = falloc(td, &fp, &fd, 0); + if (error) + goto done2; + + /* An extra reference on `fp' has been held for us by falloc(). */ + kq = malloc(sizeof *kq, M_KQUEUE, M_WAITOK | M_ZERO); + mtx_init(&kq->kq_lock, "kqueue", NULL, MTX_DEF|MTX_DUPOK); + TAILQ_INIT(&kq->kq_head); + kq->kq_fdp = fdp; + knlist_init_mtx(&kq->kq_sel.si_note, &kq->kq_lock); + TASK_INIT(&kq->kq_task, 0, kqueue_task, kq); + + FILEDESC_XLOCK(fdp); + TAILQ_INSERT_HEAD(&fdp->fd_kqlist, kq, kq_list); + FILEDESC_XUNLOCK(fdp); + + finit(fp, FREAD | FWRITE, DTYPE_KQUEUE, kq, &kqueueops); + fdrop(fp, td); + + td->td_retval[0] = fd; +done2: + return (error); } #ifndef _SYS_SYSPROTO_H_ @@ -781,75 +817,19 @@ kevent_copyin(void *arg, struct kevent * } int -kern_kqueue(struct thread *td) -{ - struct file *fp; - int error; - - error = kern_kqueue_locked(td, &fp); - - fdrop(fp, td); - return (error); -} - -int -kern_kqueue_locked(struct thread *td, struct file **fpp) -{ - struct filedesc *fdp; - struct kqueue *kq; - struct file *fp; - int fd, error; - - fdp = td->td_proc->p_fd; - error = falloc(td, &fp, &fd, 0); - if (error) - return (error); - - /* An extra reference on `fp' has been held for us by falloc(). */ - kq = malloc(sizeof *kq, M_KQUEUE, M_WAITOK | M_ZERO); - mtx_init(&kq->kq_lock, "kqueue", NULL, MTX_DEF|MTX_DUPOK); - TAILQ_INIT(&kq->kq_head); - kq->kq_fdp = fdp; - knlist_init_mtx(&kq->kq_sel.si_note, &kq->kq_lock); - TASK_INIT(&kq->kq_task, 0, kqueue_task, kq); - - FILEDESC_XLOCK(fdp); - TAILQ_INSERT_HEAD(&fdp->fd_kqlist, kq, kq_list); - FILEDESC_XUNLOCK(fdp); - - finit(fp, FREAD | FWRITE, DTYPE_KQUEUE, kq, &kqueueops); - - td->td_retval[0] = fd; - *fpp = fp; - return (0); -} - -int kern_kevent(struct thread *td, int fd, int nchanges, int nevents, struct kevent_copyops *k_ops, const struct timespec *timeout) { - struct file *fp; - cap_rights_t rights; - int error; - - if ((error = fget(td, fd, cap_rights_init(&rights, CAP_POST_EVENT), &fp)) != 0) - return (error); - - error = kern_kevent_locked(td, fp, nchanges, nevents, k_ops, timeout); - - fdrop(fp, td); - return (error); -} - -int -kern_kevent_locked(struct thread *td, struct file *fp, int nchanges, int nevents, - struct kevent_copyops *k_ops, const struct timespec *timeout) -{ struct kevent keva[KQ_NEVENTS]; struct kevent *kevp, *changes; struct kqueue *kq; + struct file *fp; + cap_rights_t rights; int i, n, nerrors, error; + error = fget(td, fd, cap_rights_init(&rights, CAP_POST_EVENT), &fp); + if (error != 0) + return (error); if ((error = kqueue_acquire(fp, &kq)) != 0) goto done_norel; @@ -892,6 +872,7 @@ kern_kevent_locked(struct thread *td, st done: kqueue_release(kq, 0); done_norel: + fdrop(fp, td); return (error); } @@ -1545,7 +1526,7 @@ done_nl: * This could be expanded to call kqueue_scan, if desired. */ /*ARGSUSED*/ -int +static int kqueue_read(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td) { @@ -1553,7 +1534,7 @@ kqueue_read(struct file *fp, struct uio } /*ARGSUSED*/ -int +static int kqueue_write(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td) { @@ -1561,7 +1542,7 @@ kqueue_write(struct file *fp, struct uio } /*ARGSUSED*/ -int +static int kqueue_truncate(struct file *fp, off_t length, struct ucred *active_cred, struct thread *td) { @@ -1570,7 +1551,7 @@ kqueue_truncate(struct file *fp, off_t l } /*ARGSUSED*/ -int +static int kqueue_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred, struct thread *td) { @@ -1618,7 +1599,7 @@ kqueue_ioctl(struct file *fp, u_long cmd } /*ARGSUSED*/ -int +static int kqueue_poll(struct file *fp, int events, struct ucred *active_cred, struct thread *td) { @@ -1645,7 +1626,7 @@ kqueue_poll(struct file *fp, int events, } /*ARGSUSED*/ -int +static int kqueue_stat(struct file *fp, struct stat *st, struct ucred *active_cred, struct thread *td) { @@ -1663,7 +1644,7 @@ kqueue_stat(struct file *fp, struct stat } /*ARGSUSED*/ -int +static int kqueue_close(struct file *fp, struct thread *td) { struct kqueue *kq = fp->f_data; Modified: head/sys/modules/linux/Makefile ============================================================================== --- head/sys/modules/linux/Makefile Wed Sep 18 18:02:01 2013 (r255674) +++ head/sys/modules/linux/Makefile Wed Sep 18 18:48:33 2013 (r255675) @@ -9,7 +9,7 @@ CFLAGS+=-DCOMPAT_FREEBSD32 -DCOMPAT_LINU KMOD= linux SRCS= linux_fork.c linux${SFX}_dummy.c linux_emul.c linux_file.c \ - linux_futex.c linux_getcwd.c linux_ioctl.c linux_ipc.c linux_epoll.c \ + linux_futex.c linux_getcwd.c linux_ioctl.c linux_ipc.c \ linux${SFX}_machdep.c linux_mib.c linux_misc.c linux_signal.c \ linux_socket.c linux_stats.c linux_sysctl.c linux${SFX}_sysent.c \ linux${SFX}_sysvec.c linux_uid16.c linux_util.c linux_time.c \ Modified: head/sys/sys/event.h ============================================================================== --- head/sys/sys/event.h Wed Sep 18 18:02:01 2013 (r255674) +++ head/sys/sys/event.h Wed Sep 18 18:48:33 2013 (r255675) @@ -236,9 +236,6 @@ struct proc; struct knlist; struct mtx; struct rwlock; -struct uio; -struct stat; -struct ucred; extern void knote(struct knlist *list, long hint, int lockflags); extern void knote_fork(struct knlist *list, int pid); @@ -264,21 +261,6 @@ extern int kqfd_register(int fd, struct extern int kqueue_add_filteropts(int filt, struct filterops *filtops); extern int kqueue_del_filteropts(int filt); -int kqueue_read(struct file *fp, struct uio *uio, struct ucred *active_cred, - int flags, struct thread *td); -int kqueue_write(struct file *fp, struct uio *uio, struct ucred *active_cred, - int flags, struct thread *td); -int kqueue_truncate(struct file *fp, off_t length, struct ucred *active_cred, - struct thread *td); -int kqueue_ioctl(struct file *fp, u_long cmd, void *data, - struct ucred *active_cred, struct thread *td); -int kqueue_poll(struct file *fp, int events, struct ucred *active_cred, - struct thread *td); -int kqueue_kqfilter(struct file *fp, struct knote *kn); -int kqueue_stat(struct file *fp, struct stat *st, struct ucred *active_cred, - struct thread *td); -int kqueue_close(struct file *fp, struct thread *td); - #else /* !_KERNEL */ #include <sys/cdefs.h> Modified: head/sys/sys/file.h ============================================================================== --- head/sys/sys/file.h Wed Sep 18 18:02:01 2013 (r255674) +++ head/sys/sys/file.h Wed Sep 18 18:48:33 2013 (r255675) @@ -169,8 +169,6 @@ struct file { union { struct cdev_privdata *fvn_cdevpriv; /* (d) Private data for the cdev. */ - void *fvn_epollpriv; - /* (d) Private data for the epoll. */ struct fadvise_info *fvn_advice; } f_vnun; /* Modified: head/sys/sys/syscallsubr.h ============================================================================== --- head/sys/sys/syscallsubr.h Wed Sep 18 18:02:01 2013 (r255674) +++ head/sys/sys/syscallsubr.h Wed Sep 18 18:48:33 2013 (r255675) @@ -121,13 +121,8 @@ int kern_ioctl(struct thread *td, int fd int kern_jail(struct thread *td, struct jail *j); int kern_jail_get(struct thread *td, struct uio *options, int flags); int kern_jail_set(struct thread *td, struct uio *options, int flags); -int kern_kqueue(struct thread *td); -int kern_kqueue_locked(struct thread *td, struct file **fpp); int kern_kevent(struct thread *td, int fd, int nchanges, int nevents, struct kevent_copyops *k_ops, const struct timespec *timeout); -int kern_kevent_locked(struct thread *td, struct file *fp, int nchanges, - int nevents, - struct kevent_copyops *k_ops, const struct timespec *timeout); int kern_kldload(struct thread *td, const char *file, int *fileid); int kern_kldstat(struct thread *td, int fileid, struct kld_file_stat *stat); int kern_kldunload(struct thread *td, int fileid, int flags); @@ -253,8 +248,6 @@ int kern_utimes(struct thread *td, char struct timeval *tptr, enum uio_seg tptrseg); int kern_utimesat(struct thread *td, int fd, char *path, enum uio_seg pathseg, struct timeval *tptr, enum uio_seg tptrseg); -int kern_utimensat(struct thread *td, int fd, char *path, - enum uio_seg pathseg, struct timespec *tptr, enum uio_seg tptrseg); int kern_wait(struct thread *td, pid_t pid, int *status, int options, struct rusage *rup); int kern_wait6(struct thread *td, enum idtype idtype, id_t id, int *status,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201309181848.r8IImXfi081608>