Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/kern Pull up following revision(s) (requested by chri...



details:   https://anonhg.NetBSD.org/src/rev/aaeb75cafa24
branches:  netbsd-9
changeset: 369942:aaeb75cafa24
user:      martin <martin%NetBSD.org@localhost>
date:      Fri Sep 09 18:20:51 2022 +0000

description:
Pull up following revision(s) (requested by christos in ticket #1516):

        sys/kern/kern_core.c: revision 1.36

Don't forget to free the cred we just held.
Thanks to Chris J-D (chris at accessvector dot net)

While here, de-duplicate the mutex exit sequence.

diffstat:

 sys/kern/kern_core.c |  24 ++++++++++--------------
 1 files changed, 10 insertions(+), 14 deletions(-)

diffs (80 lines):

diff -r fee8b0c4be9c -r aaeb75cafa24 sys/kern/kern_core.c
--- a/sys/kern/kern_core.c      Wed Sep 07 10:07:43 2022 +0000
+++ b/sys/kern/kern_core.c      Fri Sep 09 18:20:51 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_core.c,v 1.24.22.1 2019/11/11 17:11:07 martin Exp $       */
+/*     $NetBSD: kern_core.c,v 1.24.22.2 2022/09/09 18:20:51 martin 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.24.22.1 2019/11/11 17:11:07 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.24.22.2 2022/09/09 18:20:51 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/vnode.h>
@@ -97,7 +97,7 @@
        struct vnode            *vp;
        struct proc             *p;
        struct vmspace          *vm;
-       kauth_cred_t            cred;
+       kauth_cred_t            cred = NULL;
        struct pathbuf          *pb;
        struct nameidata        nd;
        struct vattr            vattr;
@@ -122,9 +122,7 @@
        if (USPACE + ctob(vm->vm_dsize + vm->vm_ssize) >=
            p->p_rlimit[RLIMIT_CORE].rlim_cur) {
                error = EFBIG;          /* better error code? */
-               mutex_exit(p->p_lock);
-               mutex_exit(proc_lock);
-               goto done;
+               goto release;
        }
 
        /*
@@ -141,9 +139,7 @@
        if (p->p_flag & PK_SUGID) {
                if (!security_setidcore_dump) {
                        error = EPERM;
-                       mutex_exit(p->p_lock);
-                       mutex_exit(proc_lock);
-                       goto done;
+                       goto release;
                }
                pattern = security_setidcore_path;
        }
@@ -157,11 +153,8 @@
        error = coredump_buildname(p, name, pattern, MAXPATHLEN);
        mutex_exit(&lim->pl_lock);
 
-       if (error) {
-               mutex_exit(p->p_lock);
-               mutex_exit(proc_lock);
-               goto done;
-       }
+       if (error)
+               goto release;
 
        /*
         * On a simple filename, see if the filesystem allow us to write
@@ -175,6 +168,7 @@
                        error = EPERM;
        }
 
+release:
        mutex_exit(p->p_lock);
        mutex_exit(proc_lock);
        if (error)
@@ -262,6 +256,8 @@
        if (error == 0)
                error = error1;
 done:
+       if (cred != NULL)
+               kauth_cred_free(cred);
        if (name != NULL)
                PNBUF_PUT(name);
        return error;



Home | Main Index | Thread Index | Old Index