Date: Thu, 1 Jun 2017 16:49:48 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r319444 - in head/sys/compat/linuxkpi/common: include/linux src Message-ID: <201706011649.v51GnmT5029670@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hselasky Date: Thu Jun 1 16:49:48 2017 New Revision: 319444 URL: https://svnweb.freebsd.org/changeset/base/319444 Log: Make sure the selrecord() function is only called from within system polling contexts in the LinuxKPI. After the kqueue() support was added to the LinuxKPI in r319409 the Linux poll file operation will be used outside the system file polling callback function, which can cause a NULL-pointer panic inside selrecord() because curthread->td_sel is set to NULL. This patch moves the selrecord() call away from poll_wait() and to the system file poll callback function in the LinuxKPI, which essentially wraps the Linux one. This is similar to what the cuse(3) module is currently doing. Refer to sys/fs/cuse/*.[ch] for more details. MFC after: 1 week Sponsored by: Mellanox Technologies Modified: head/sys/compat/linuxkpi/common/include/linux/poll.h head/sys/compat/linuxkpi/common/src/linux_compat.c Modified: head/sys/compat/linuxkpi/common/include/linux/poll.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/poll.h Thu Jun 1 16:44:39 2017 (r319443) +++ head/sys/compat/linuxkpi/common/include/linux/poll.h Thu Jun 1 16:49:48 2017 (r319444) @@ -43,7 +43,7 @@ typedef struct poll_table_struct { static inline void poll_wait(struct linux_file *filp, wait_queue_head_t *wait_address, poll_table *p) { - selrecord(curthread, &filp->f_selinfo); + /* NOP */ } extern void linux_poll_wakeup(struct linux_file *); Modified: head/sys/compat/linuxkpi/common/src/linux_compat.c ============================================================================== --- head/sys/compat/linuxkpi/common/src/linux_compat.c Thu Jun 1 16:44:39 2017 (r319443) +++ head/sys/compat/linuxkpi/common/src/linux_compat.c Thu Jun 1 16:49:48 2017 (r319444) @@ -956,9 +956,10 @@ linux_dev_poll(struct cdev *dev, int events, struct th file = td->td_fpop; filp->f_flags = file->f_flag; linux_set_current(td); - if (filp->f_op->poll) + if (filp->f_op->poll != NULL) { + selrecord(td, &filp->f_selinfo); revents = filp->f_op->poll(filp, NULL) & events; - else + } else revents = 0; return (revents); @@ -1263,9 +1264,10 @@ linux_file_poll(struct file *file, int events, struct filp = (struct linux_file *)file->f_data; filp->f_flags = file->f_flag; linux_set_current(td); - if (filp->f_op->poll) + if (filp->f_op->poll != NULL) { + selrecord(td, &filp->f_selinfo); revents = filp->f_op->poll(filp, NULL) & events; - else + } else revents = 0; return (revents);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201706011649.v51GnmT5029670>