Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern fork(2): Plug leaks in proc_alloc error branch.
details: https://anonhg.NetBSD.org/src/rev/a5bc357ccb1a
branches: trunk
changeset: 368237:a5bc357ccb1a
user: riastradh <riastradh%NetBSD.org@localhost>
date: Fri Jul 01 01:05:21 2022 +0000
description:
fork(2): Plug leaks in proc_alloc error branch.
diffstat:
sys/kern/kern_fork.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diffs (32 lines):
diff -r 72d6bd8f453b -r a5bc357ccb1a sys/kern/kern_fork.c
--- a/sys/kern/kern_fork.c Fri Jul 01 01:04:59 2022 +0000
+++ b/sys/kern/kern_fork.c Fri Jul 01 01:05:21 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_fork.c,v 1.227 2021/10/10 18:07:51 thorpej Exp $ */
+/* $NetBSD: kern_fork.c,v 1.228 2022/07/01 01:05:21 riastradh Exp $ */
/*-
* Copyright (c) 1999, 2001, 2004, 2006, 2007, 2008, 2019
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.227 2021/10/10 18:07:51 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.228 2022/07/01 01:05:21 riastradh Exp $");
#include "opt_ktrace.h"
#include "opt_dtrace.h"
@@ -309,6 +309,13 @@
p2 = proc_alloc();
if (p2 == NULL) {
/* We were unable to allocate a process ID. */
+ uvm_uarea_free(uaddr);
+ mutex_enter(p1->p_lock);
+ cred = p1->p_cred;
+ uid = kauth_cred_getuid(cred);
+ (void)chgproccnt(uid, -1);
+ mutex_exit(p1->p_lock);
+ atomic_dec_uint(&nprocs);
return EAGAIN;
}
Home |
Main Index |
Thread Index |
Old Index