From 304d60e8383b8c29ca01daedd3d21169d4347997 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sat, 28 Aug 2010 09:02:47 -0700 Subject: [PATCH] kernel - Fix badfo_kqfilter for badfileops * badfo_kqfilter() must return an error to cause the kqueue registraton to drop the knote, otherwise a kernel panic will occur because the default file_filtops isn't replaced and has not detach or event functions. --- sys/kern/kern_descrip.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 508d64fe45..0887dcdf10 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -2794,9 +2794,6 @@ struct fileops badfileops = { .fo_shutdown = badfo_shutdown }; -/* - * MPSAFE - */ int badfo_readwrite( struct file *fp, @@ -2807,9 +2804,6 @@ badfo_readwrite( return (EBADF); } -/* - * MPSAFE - */ int badfo_ioctl(struct file *fp, u_long com, caddr_t data, struct ucred *cred, struct sysmsg *msgv) @@ -2817,9 +2811,6 @@ badfo_ioctl(struct file *fp, u_long com, caddr_t data, return (EBADF); } -/* - * MPSAFE - */ int badfo_poll(struct file *fp, int events, struct ucred *cred) { @@ -2827,14 +2818,18 @@ badfo_poll(struct file *fp, int events, struct ucred *cred) } /* - * MPSAFE + * Must return an error to prevent registration, typically + * due to a revoked descriptor (file_filtops assigned). */ int badfo_kqfilter(struct file *fp, struct knote *kn) { - return (0); + return (EOPNOTSUPP); } +/* + * MPSAFE + */ int badfo_stat(struct file *fp, struct stat *sb, struct ucred *cred) { -- 2.41.0