Date: Mon, 8 Aug 2016 18:10:59 +0000 (UTC) From: Bryan Drewery <bdrewery@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303843 - stable/10/sys/kern Message-ID: <201608081810.u78IAxGl097378@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bdrewery Date: Mon Aug 8 18:10:59 2016 New Revision: 303843 URL: https://svnweb.freebsd.org/changeset/base/303843 Log: MFC r280330,r282567: r280330: fork: assign refed credentials earlier r282567: Fix up panics when fork fails due to hitting proc limit PR: D7431 Modified: stable/10/sys/kern/kern_fork.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_fork.c ============================================================================== --- stable/10/sys/kern/kern_fork.c Mon Aug 8 18:10:30 2016 (r303842) +++ stable/10/sys/kern/kern_fork.c Mon Aug 8 18:10:59 2016 (r303843) @@ -412,9 +412,6 @@ do_fork(struct thread *td, int flags, st p2->p_treeflag = 0; p2->p_filemon = NULL; - crhold(td->td_ucred); - proc_set_cred(p2, td->td_ucred); - /* Tell the prison that we exist. */ prison_proc_hold(p2->p_ucred->cr_prison); @@ -875,7 +872,7 @@ fork1(struct thread *td, int flags, int td2 = thread_alloc(pages); if (td2 == NULL) { error = ENOMEM; - goto fail1; + goto fail2; } proc_linkup(newproc, td2); } else { @@ -884,7 +881,7 @@ fork1(struct thread *td, int flags, int vm_thread_dispose(td2); if (!thread_alloc_stack(td2, pages)) { error = ENOMEM; - goto fail1; + goto fail2; } } } @@ -893,7 +890,7 @@ fork1(struct thread *td, int flags, int vm2 = vmspace_fork(p1->p_vmspace, &mem_charged); if (vm2 == NULL) { error = ENOMEM; - goto fail1; + goto fail2; } if (!swap_reserve(mem_charged)) { /* @@ -904,7 +901,7 @@ fork1(struct thread *td, int flags, int */ swap_reserve_force(mem_charged); error = ENOMEM; - goto fail1; + goto fail2; } } else vm2 = NULL; @@ -913,7 +910,7 @@ fork1(struct thread *td, int flags, int * XXX: This is ugly; when we copy resource usage, we need to bump * per-cred resource counters. */ - proc_set_cred(newproc, p1->p_ucred); + proc_set_cred(newproc, crhold(td->td_ucred)); /* * Initialize resource accounting for the child process. @@ -974,6 +971,9 @@ fork1(struct thread *td, int flags, int #endif racct_proc_exit(newproc); fail1: + crfree(newproc->p_ucred); + newproc->p_ucred = NULL; +fail2: if (vm2 != NULL) vmspace_free(vm2); uma_zfree(proc_zone, newproc);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201608081810.u78IAxGl097378>