PERFORCE change 15946 for review
Robert Watson
rwatson at freebsd.org
Wed Aug 14 00:06:36 GMT 2002
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=15946
Change 15946 by rwatson at rwatson_paprika on 2002/08/13 17:05:37
When I added active_cred arguments to the file op function
prototypes, I figured I'd add one to fo_close() also for
consistency. As it turns out, this wasn't such a good idea:
there isn't always an active credential available due to the
way the current code is constructed (td==NULL may get passed
into higher level file descriptor code, resulting in a NULL
pointer dereference in a couple of odd-ball cases, such as
the NFS server code). Since the MAC implementation doesn't
currently have a close-related event, back out the addition
of active_cred to fo_close() its implementations. Keep
the use of active_cred in vn_close() while removing it from
vn_closefile() as similar credential code already existed
there and keeping the new naming scheme increases
consistency. This should fix the panic on shutdown when the
NFS server is running.
Affected files ...
.. //depot/projects/trustedbsd/mac/sys/dev/streams/streams.c#7 edit
.. //depot/projects/trustedbsd/mac/sys/kern/kern_descrip.c#24 edit
.. //depot/projects/trustedbsd/mac/sys/kern/kern_event.c#9 edit
.. //depot/projects/trustedbsd/mac/sys/kern/sys_pipe.c#19 edit
.. //depot/projects/trustedbsd/mac/sys/kern/sys_socket.c#10 edit
.. //depot/projects/trustedbsd/mac/sys/kern/vfs_vnops.c#48 edit
.. //depot/projects/trustedbsd/mac/sys/sys/file.h#10 edit
.. //depot/projects/trustedbsd/mac/sys/sys/socketvar.h#21 edit
Differences ...
==== //depot/projects/trustedbsd/mac/sys/dev/streams/streams.c#7 (text+ko) ====
@@ -61,7 +61,7 @@
#include <compat/svr4/svr4_stropts.h>
#include <compat/svr4/svr4_socket.h>
-static int svr4_soo_close(struct file *, struct ucred *, struct thread *);
+static int svr4_soo_close(struct file *, struct thread *);
static int svr4_ptm_alloc(struct thread *);
static d_open_t streamsopen;
@@ -416,7 +416,7 @@
}
static int
-svr4_soo_close(struct file *fp, struct ucred *active_cred, struct thread *td)
+svr4_soo_close(struct file *fp, struct thread *td)
{
struct socket *so = (struct socket *)fp->f_data;
@@ -424,5 +424,5 @@
svr4_delete_socket(td->td_proc, fp);
free(so->so_emuldata, M_TEMP);
- return soo_close(fp, active_cred, td);
+ return soo_close(fp, td);
}
==== //depot/projects/trustedbsd/mac/sys/kern/kern_descrip.c#24 (text+ko) ====
@@ -109,8 +109,7 @@
static int badfo_kqfilter(struct file *fp, struct knote *kn);
static int badfo_stat(struct file *fp, struct stat *sb,
struct ucred *active_cred, struct thread *td);
-static int badfo_close(struct file *fp, struct ucred *active_cred,
- struct thread *td);
+static int badfo_close(struct file *fp, struct thread *td);
/*
* Descriptor management.
@@ -1848,7 +1847,7 @@
} else
FILE_UNLOCK(fp);
if (fp->f_ops != &badfileops)
- error = fo_close(fp, td->td_ucred, td);
+ error = fo_close(fp, td);
else
error = 0;
ffree(fp);
@@ -2234,9 +2233,8 @@
}
static int
-badfo_close(fp, active_cred, td)
+badfo_close(fp, td)
struct file *fp;
- struct ucred *active_cred;
struct thread *td;
{
==== //depot/projects/trustedbsd/mac/sys/kern/kern_event.c#9 (text+ko) ====
@@ -67,8 +67,7 @@
static int kqueue_kqfilter(struct file *fp, struct knote *kn);
static int kqueue_stat(struct file *fp, struct stat *st,
struct ucred *active_cred, struct thread *td);
-static int kqueue_close(struct file *fp, struct ucred *active_cred,
- struct thread *td);
+static int kqueue_close(struct file *fp, struct thread *td);
static void kqueue_wakeup(struct kqueue *kq);
static struct fileops kqueueops = {
@@ -840,7 +839,7 @@
/*ARGSUSED*/
static int
-kqueue_close(struct file *fp, struct ucred *active_cred, struct thread *td)
+kqueue_close(struct file *fp, struct thread *td)
{
struct kqueue *kq = (struct kqueue *)fp->f_data;
struct filedesc *fdp = td->td_proc->p_fd;
==== //depot/projects/trustedbsd/mac/sys/kern/sys_pipe.c#19 (text+ko) ====
@@ -98,8 +98,7 @@
struct ucred *active_cred, int flags, struct thread *td);
static int pipe_write(struct file *fp, struct uio *uio,
struct ucred *active_cred, int flags, struct thread *td);
-static int pipe_close(struct file *fp, struct ucred *active_cred,
- struct thread *td);
+static int pipe_close(struct file *fp, struct thread *td);
static int pipe_poll(struct file *fp, int events, struct ucred *active_cred,
struct thread *td);
static int pipe_kqfilter(struct file *fp, struct knote *kn);
@@ -1305,9 +1304,8 @@
/* ARGSUSED */
static int
-pipe_close(fp, active_cred, td)
+pipe_close(fp, td)
struct file *fp;
- struct ucred *active_cred;
struct thread *td;
{
struct pipe *cpipe = (struct pipe *)fp->f_data;
==== //depot/projects/trustedbsd/mac/sys/kern/sys_socket.c#10 (text+ko) ====
@@ -203,9 +203,8 @@
*/
/* ARGSUSED */
int
-soo_close(fp, active_cred, td)
+soo_close(fp, td)
struct file *fp;
- struct ucred *active_cred;
struct thread *td;
{
int error = 0;
==== //depot/projects/trustedbsd/mac/sys/kern/vfs_vnops.c#48 (text+ko) ====
@@ -63,8 +63,7 @@
#include <machine/limits.h>
-static int vn_closefile(struct file *fp, struct ucred *active_cred,
- struct thread *td);
+static int vn_closefile(struct file *fp, struct thread *td);
static int vn_ioctl(struct file *fp, u_long com, void *data,
struct ucred *active_cred, struct thread *td);
static int vn_read(struct file *fp, struct uio *uio,
@@ -883,9 +882,8 @@
* File table vnode close routine.
*/
static int
-vn_closefile(fp, active_cred, td)
+vn_closefile(fp, td)
struct file *fp;
- struct ucred *active_cred;
struct thread *td;
{
==== //depot/projects/trustedbsd/mac/sys/sys/file.h#10 (text+ko) ====
@@ -94,8 +94,7 @@
int (*fo_kqfilter)(struct file *fp, struct knote *kn);
int (*fo_stat)(struct file *fp, struct stat *sb,
struct ucred *active_cred, struct thread *td);
- int (*fo_close)(struct file *fp,
- struct ucred *active_cred, struct thread *td);
+ int (*fo_close)(struct file *fp, struct thread *td);
} *f_ops;
int f_seqcount; /*
* count of sequential accesses -- cleared
@@ -186,8 +185,7 @@
struct ucred *active_cred, struct thread *td);
static __inline int fo_stat(struct file *fp, struct stat *sb,
struct ucred *active_cred, struct thread *td);
-static __inline int fo_close(struct file *fp, struct ucred *active_cred,
- struct thread *td);
+static __inline int fo_close(struct file *fp, struct thread *td);
static __inline int fo_kqfilter(struct file *fp, struct knote *kn);
struct proc;
@@ -196,12 +194,11 @@
struct file *fp;
struct uio *uio;
struct ucred *active_cred;
+ int flags;
struct thread *td;
- int flags;
{
- return ((*fp->f_ops->fo_read)(fp, uio, active_cred, flags,
- td));
+ return ((*fp->f_ops->fo_read)(fp, uio, active_cred, flags, td));
}
static __inline int
@@ -251,13 +248,12 @@
}
static __inline int
-fo_close(fp, active_cred, td)
+fo_close(fp, td)
struct file *fp;
- struct ucred *active_cred;
struct thread *td;
{
- return ((*fp->f_ops->fo_close)(fp, active_cred, td));
+ return ((*fp->f_ops->fo_close)(fp, td));
}
static __inline int
==== //depot/projects/trustedbsd/mac/sys/sys/socketvar.h#21 (text+ko) ====
@@ -349,8 +349,7 @@
int flags, struct thread *td);
int soo_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
int flags, struct thread *td);
-int soo_close(struct file *fp, struct ucred *active_cred,
- struct thread *td);
+int soo_close(struct file *fp, struct thread *td);
int soo_ioctl(struct file *fp, u_long cmd, void *data,
struct ucred *active_cred, struct thread *td);
int soo_poll(struct file *fp, int events, struct ucred *active_cred,
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message
More information about the trustedbsd-cvs
mailing list