From a1529410768d67db8edac37088183378a17ff951 Mon Sep 17 00:00:00 2001 From: bdrewery Date: Mon, 7 Mar 2016 21:39:29 +0000 Subject: Require kldunload -f to unload. Code may still be executing from the wrappers at unload time and thus is not generally safe to unload. Converting the wrappers to use EVENTHANDLER(9) will allow this to safely drain on active threads in hooks. More work on EVENTHANDLER(9) is needed first. MFC after: 1 week Sponsored by: EMC / Isilon Storage Division --- sys/dev/filemon/filemon.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'sys/dev/filemon/filemon.c') diff --git a/sys/dev/filemon/filemon.c b/sys/dev/filemon/filemon.c index ed0ead5..78bfbb3 100644 --- a/sys/dev/filemon/filemon.c +++ b/sys/dev/filemon/filemon.c @@ -68,8 +68,6 @@ extern struct sysentvec elf64_freebsd_sysvec; static d_close_t filemon_close; static d_ioctl_t filemon_ioctl; static d_open_t filemon_open; -static int filemon_unload(void); -static void filemon_load(void *); static struct cdevsw filemon_cdevsw = { .d_version = D_VERSION, @@ -301,6 +299,13 @@ filemon_modevent(module_t mod __unused, int type, void *data) error = filemon_unload(); break; + case MOD_QUIESCE: + /* + * The wrapper implementation is unsafe for reliable unload. + * Require forcing an unload. + */ + error = EBUSY; + case MOD_SHUTDOWN: break; -- cgit v1.1 From 064eabeacba9d8ebad23759ef5d66b042435247b Mon Sep 17 00:00:00 2001 From: bdrewery Date: Mon, 7 Mar 2016 21:45:24 +0000 Subject: Add missing break for r296472. This was lost in git rebasing, though it has no functional change. X-MFC-With: r296472 MFC after: 1 week --- sys/dev/filemon/filemon.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sys/dev/filemon/filemon.c') diff --git a/sys/dev/filemon/filemon.c b/sys/dev/filemon/filemon.c index 78bfbb3..9ece66d 100644 --- a/sys/dev/filemon/filemon.c +++ b/sys/dev/filemon/filemon.c @@ -305,6 +305,7 @@ filemon_modevent(module_t mod __unused, int type, void *data) * Require forcing an unload. */ error = EBUSY; + break; case MOD_SHUTDOWN: break; -- cgit v1.1 From bce1a80ea1b9642bca27ca3a5954a5ba91b93e53 Mon Sep 17 00:00:00 2001 From: bdrewery Date: Wed, 9 Mar 2016 19:50:35 +0000 Subject: FILEMON_SET_FD: Disallow changing the fd. MFC after: 1 week Suggested by: mjg Sponsored by: EMC / Isilon Storage Division --- sys/dev/filemon/filemon.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sys/dev/filemon/filemon.c') diff --git a/sys/dev/filemon/filemon.c b/sys/dev/filemon/filemon.c index 9ece66d..cd40c5a 100644 --- a/sys/dev/filemon/filemon.c +++ b/sys/dev/filemon/filemon.c @@ -163,8 +163,10 @@ filemon_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag __unused, switch (cmd) { /* Set the output file descriptor. */ case FILEMON_SET_FD: - if (filemon->fp != NULL) - fdrop(filemon->fp, td); + if (filemon->fp != NULL) { + error = EEXIST; + break; + } error = fget_write(td, *(int *)data, cap_rights_init(&rights, CAP_PWRITE), -- cgit v1.1