Do not allow kqueues to be passed via unix domain sockets.

This commit is contained in:
Alfred Perlstein 2003-02-15 06:04:55 +00:00
parent 8484cf9776
commit e7d6662f1b
7 changed files with 18 additions and 5 deletions

View File

@ -2181,7 +2181,8 @@ struct fileops badfileops = {
badfo_poll,
badfo_kqfilter,
badfo_stat,
badfo_close
badfo_close,
0
};
static int

View File

@ -74,7 +74,8 @@ static struct fileops kqueueops = {
kqueue_poll,
kqueue_kqfilter,
kqueue_stat,
kqueue_close
kqueue_close,
0
};
static void knote_attach(struct knote *kn, struct filedesc *fdp);

View File

@ -104,7 +104,7 @@ static fo_close_t pipe_close;
static struct fileops pipeops = {
pipe_read, pipe_write, pipe_ioctl, pipe_poll, pipe_kqfilter,
pipe_stat, pipe_close
pipe_stat, pipe_close, DFLAG_PASSABLE
};
static void filt_pipedetach(struct knote *kn);

View File

@ -57,7 +57,7 @@
struct fileops socketops = {
soo_read, soo_write, soo_ioctl, soo_poll, soo_kqfilter,
soo_stat, soo_close
soo_stat, soo_close, DFLAG_PASSABLE
};
/* ARGSUSED */

View File

@ -1171,6 +1171,13 @@ unp_internalize(controlp, td)
error = EBADF;
goto out;
}
fp = fdescp->fd_ofiles[fd];
if (!(fp->f_ops->fo_flags & DFLAG_PASSABLE)) {
FILEDESC_UNLOCK(fdescp);
error = EOPNOTSUPP;
goto out;
}
}
/*
* Now replace the integer FDs with pointers to

View File

@ -73,7 +73,7 @@ static fo_close_t vn_closefile;
struct fileops vnops = {
vn_read, vn_write, vn_ioctl, vn_poll, vn_kqfilter,
vn_statfile, vn_closefile
vn_statfile, vn_closefile, DFLAG_PASSABLE
};
int

View File

@ -80,6 +80,7 @@ typedef int fo_kqfilter_t(struct file *fp, struct knote *kn);
typedef int fo_stat_t(struct file *fp, struct stat *sb,
struct ucred *active_cred, struct thread *td);
typedef int fo_close_t(struct file *fp, struct thread *td);
typedef int fo_flags_t;
struct fileops {
fo_rdwr_t *fo_read;
@ -89,8 +90,11 @@ struct fileops {
fo_kqfilter_t *fo_kqfilter;
fo_stat_t *fo_stat;
fo_close_t *fo_close;
fo_flags_t fo_flags; /* DFLAG_* below */
};
#define DFLAG_PASSABLE 0x01 /* may be passed via unix sockets. */
/*
* Kernel descriptor table.
* One entry for each open kernel vnode and socket.