Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Don't dump core on an existing core file we don't o...



details:   https://anonhg.NetBSD.org/src/rev/c1e4e047dfb9
branches:  trunk
changeset: 769852:c1e4e047dfb9
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Sep 24 22:53:50 2011 +0000

description:
Don't dump core on an existing core file we don't own. From OpenBSD, suggested
by Greg Woods.

diffstat:

 sys/kern/kern_core.c |  16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diffs (38 lines):

diff -r 064f494f3b1c -r c1e4e047dfb9 sys/kern/kern_core.c
--- a/sys/kern/kern_core.c      Sat Sep 24 22:40:46 2011 +0000
+++ b/sys/kern/kern_core.c      Sat Sep 24 22:53:50 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_core.c,v 1.19 2011/09/23 00:03:29 christos Exp $  */
+/*     $NetBSD: kern_core.c,v 1.20 2011/09/24 22:53:50 christos Exp $  */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.19 2011/09/23 00:03:29 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.20 2011/09/24 22:53:50 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/vnode.h>
@@ -217,10 +217,16 @@
        vp = nd.ni_vp;
        pathbuf_destroy(pb);
 
-       /* Don't dump to non-regular files or files with links. */
+       /*
+        * Don't dump to:
+        *      - non-regular files
+        *      - files with links
+        *      - files we don't own
+        */
        if (vp->v_type != VREG ||
-           VOP_GETATTR(vp, &vattr, cred) || vattr.va_nlink != 1) {
-               error = EINVAL;
+           VOP_GETATTR(vp, &vattr, cred) || vattr.va_nlink != 1 ||
+           vattr.va_uid != kauth_cred_geteuid(cred)) {
+               error = EACCES;
                goto out;
        }
        vattr_null(&vattr);



Home | Main Index | Thread Index | Old Index