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 chs ...



details:   https://anonhg.NetBSD.org/src/rev/958fe9d00fcd
branches:  netbsd-9
changeset: 369441:958fe9d00fcd
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Aug 17 16:43:01 2022 +0000

description:
Pull up following revision(s) (requested by chs in ticket #1501):

        sys/kern/uipc_sem.c: revision 1.60

when updating the per-uid "semcnt", decrement the counter for the uid
that created the ksem, not the uid of the process freeing the ksem.
fixes PR 55509.

diffstat:

 sys/kern/uipc_sem.c |  15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diffs (58 lines):

diff -r e6b95c4cf85e -r 958fe9d00fcd sys/kern/uipc_sem.c
--- a/sys/kern/uipc_sem.c       Fri Aug 12 15:19:24 2022 +0000
+++ b/sys/kern/uipc_sem.c       Wed Aug 17 16:43:01 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_sem.c,v 1.55.4.2 2020/05/05 20:12:37 martin Exp $ */
+/*     $NetBSD: uipc_sem.c,v 1.55.4.3 2022/08/17 16:43:01 martin Exp $ */
 
 /*-
  * Copyright (c) 2011, 2019 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.55.4.2 2020/05/05 20:12:37 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.55.4.3 2022/08/17 16:43:01 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -470,8 +470,6 @@
                len = 0;
        }
 
-       chgsemcnt(kauth_cred_getuid(l->l_cred), 1);
-
        ks = kmem_zalloc(sizeof(ksem_t), KM_SLEEP);
        mutex_init(&ks->ks_lock, MUTEX_DEFAULT, IPL_NONE);
        cv_init(&ks->ks_cv, "psem");
@@ -484,8 +482,9 @@
        uc = l->l_cred;
        ks->ks_uid = kauth_cred_geteuid(uc);
        ks->ks_gid = kauth_cred_getegid(uc);
+       chgsemcnt(ks->ks_uid, 1);
+       atomic_inc_uint(&nsems_total);
 
-       atomic_inc_uint(&nsems_total);
        *ksret = ks;
        return 0;
 }
@@ -496,6 +495,9 @@
 
        KASSERT(!cv_has_waiters(&ks->ks_cv));
 
+       chgsemcnt(ks->ks_uid, -1);
+       atomic_dec_uint(&nsems_total);
+
        if (ks->ks_pshared_id) {
                KASSERT(ks->ks_pshared_proc == NULL);
                ksem_remove_pshared(ks);
@@ -507,9 +509,6 @@
        mutex_destroy(&ks->ks_lock);
        cv_destroy(&ks->ks_cv);
        kmem_free(ks, sizeof(ksem_t));
-
-       atomic_dec_uint(&nsems_total);
-       chgsemcnt(kauth_cred_getuid(curproc->p_cred), -1);
 }
 
 #define        KSEM_ID_IS_PSHARED(id)          \



Home | Main Index | Thread Index | Old Index