Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Fix of panic that was introduced since ktrace-lwp branch...



details:   https://anonhg.NetBSD.org/src/rev/f2bfce06b87e
branches:  trunk
changeset: 586309:f2bfce06b87e
user:      reinoud <reinoud%NetBSD.org@localhost>
date:      Tue Dec 13 13:12:18 2005 +0000

description:
Fix of panic that was introduced since ktrace-lwp branch was merged. The
shortcut to the process of the passed lwp paniced the kernel since lwp
could/can be passwd as NULL in VOP_WRITE().

This was happening when ktracing to NFS. The function ktrwrite() set the
uio_lwp to NULL and then calls VOP_WRITE() with this argument. nfs_write()
then accessed lwp *l->l_proc wich paniced.

Thanks to David Laight for his help on tracking it down.

diffstat:

 sys/kern/kern_ktrace.c |   6 +++---
 sys/nfs/nfs_bio.c      |  11 +++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diffs (66 lines):

diff -r f28084c961b5 -r f2bfce06b87e sys/kern/kern_ktrace.c
--- a/sys/kern/kern_ktrace.c    Tue Dec 13 12:59:48 2005 +0000
+++ b/sys/kern/kern_ktrace.c    Tue Dec 13 13:12:18 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_ktrace.c,v 1.98 2005/12/11 12:24:29 christos Exp $        */
+/*     $NetBSD: kern_ktrace.c,v 1.99 2005/12/13 13:12:18 reinoud Exp $ */
 
 /*
  * Copyright (c) 1989, 1993
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_ktrace.c,v 1.98 2005/12/11 12:24:29 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_ktrace.c,v 1.99 2005/12/13 13:12:18 reinoud Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_compat_mach.h"
@@ -1127,7 +1127,7 @@
        auio.uio_rw = UIO_WRITE;
        auio.uio_resid = 0;
        auio.uio_iovcnt = 0;
-       auio.uio_lwp = NULL;
+       auio.uio_lwp = curlwp;
        do {
                kth = &kte->kte_kth;
 
diff -r f28084c961b5 -r f2bfce06b87e sys/nfs/nfs_bio.c
--- a/sys/nfs/nfs_bio.c Tue Dec 13 12:59:48 2005 +0000
+++ b/sys/nfs/nfs_bio.c Tue Dec 13 13:12:18 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfs_bio.c,v 1.139 2005/12/11 12:25:16 christos Exp $   */
+/*     $NetBSD: nfs_bio.c,v 1.140 2005/12/13 13:12:18 reinoud Exp $    */
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.139 2005/12/11 12:25:16 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.140 2005/12/13 13:12:18 reinoud Exp $");
 
 #include "opt_nfs.h"
 #include "opt_ddb.h"
@@ -499,7 +499,6 @@
        } */ *ap = v;
        struct uio *uio = ap->a_uio;
        struct lwp *l = uio->uio_lwp;
-       struct proc *p = l->l_proc;
        struct vnode *vp = ap->a_vp;
        struct nfsnode *np = VTONFS(vp);
        struct ucred *cred = ap->a_cred;
@@ -552,9 +551,9 @@
         * Maybe this should be above the vnode op call, but so long as
         * file servers have no limits, i don't think it matters
         */
-       if (p && uio->uio_offset + uio->uio_resid >
-             p->p_rlimit[RLIMIT_FSIZE].rlim_cur) {
-               psignal(p, SIGXFSZ);
+       if (l && l->l_proc && uio->uio_offset + uio->uio_resid >
+             l->l_proc->p_rlimit[RLIMIT_FSIZE].rlim_cur) {
+               psignal(l->l_proc, SIGXFSZ);
                return (EFBIG);
        }
 



Home | Main Index | Thread Index | Old Index