summaryrefslogtreecommitdiffstats
path: root/sys/compat
diff options
context:
space:
mode:
authordchagin <dchagin@FreeBSD.org>2016-01-09 18:24:53 +0000
committerdchagin <dchagin@FreeBSD.org>2016-01-09 18:24:53 +0000
commit236dbed3f3c05f1332475d05c1f7c4b6fb28ce14 (patch)
tree150fe4625a44c169368fd0e0617c305d97df0300 /sys/compat
parent0fba4d31404955c6babb54c71c7642cce9ead7d3 (diff)
downloadFreeBSD-src-236dbed3f3c05f1332475d05c1f7c4b6fb28ce14.zip
FreeBSD-src-236dbed3f3c05f1332475d05c1f7c4b6fb28ce14.tar.gz
MFC r287395 (by trasz):
Fixes a panic triggered by threaded Linux applications when running with RACCT/RCTL enabled.
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/linux/linux_fork.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/sys/compat/linux/linux_fork.c b/sys/compat/linux/linux_fork.c
index 280b406..e7b2c62 100644
--- a/sys/compat/linux/linux_fork.c
+++ b/sys/compat/linux/linux_fork.c
@@ -286,10 +286,20 @@ linux_clone_thread(struct thread *td, struct linux_clone_args *args)
p = td->td_proc;
+#ifdef RACCT
+ if (racct_enable) {
+ PROC_LOCK(p);
+ error = racct_add(p, RACCT_NTHR, 1);
+ PROC_UNLOCK(p);
+ if (error != 0)
+ return (EPROCLIM);
+ }
+#endif
+
/* Initialize our td */
error = kern_thr_alloc(p, 0, &newtd);
if (error)
- return (error);
+ goto fail;
cpu_set_upcall(newtd, td);
@@ -370,6 +380,16 @@ linux_clone_thread(struct thread *td, struct linux_clone_args *args)
td->td_retval[0] = newtd->td_tid;
return (0);
+
+fail:
+#ifdef RACCT
+ if (racct_enable) {
+ PROC_LOCK(p);
+ racct_sub(p, RACCT_NTHR, 1);
+ PROC_UNLOCK(p);
+ }
+#endif
+ return (error);
}
int
OpenPOWER on IntegriCloud