Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F136965459
D25293.id73182.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D25293.id73182.diff
View Options
Index: sys/compat/linux/linux_emul.c
===================================================================
--- sys/compat/linux/linux_emul.c
+++ sys/compat/linux/linux_emul.c
@@ -291,22 +291,13 @@
void
linux_proc_exec(void *arg __unused, struct proc *p, struct image_params *imgp)
{
- struct thread *td = curthread;
+ struct thread *td;
struct thread *othertd;
#if defined(__amd64__)
struct linux_pemuldata *pem;
#endif
- /*
- * In a case of execing from Linux binary properly detach
- * other threads from the user space.
- */
- if (__predict_false(SV_PROC_ABI(p) == SV_ABI_LINUX)) {
- FOREACH_THREAD_IN_PROC(p, othertd) {
- if (td != othertd)
- (p->p_sysent->sv_thread_detach)(othertd);
- }
- }
+ td = curthread;
/*
* In a case of execing to Linux binary we create Linux
@@ -314,11 +305,32 @@
*/
if (__predict_false((imgp->sysent->sv_flags & SV_ABI_MASK) ==
SV_ABI_LINUX)) {
-
- if (SV_PROC_ABI(p) == SV_ABI_LINUX)
+ if (SV_PROC_ABI(p) == SV_ABI_LINUX) {
+ /*
+ * Process already was under Linuxolator
+ * before exec. Update emuldata to reflect
+ * single-threaded cleaned state after exec.
+ */
linux_proc_init(td, NULL, 0);
- else
+ } else {
+ /*
+ * We are switching the process to Linux emulator.
+ */
linux_proc_init(td, td, 0);
+
+ /*
+ * Create a transient td_emuldata for all suspended
+ * threads, so that p->p_sysent->sv_thread_detach() ==
+ * linux_thread_detach() can find expected but unused
+ * emuldata.
+ */
+ FOREACH_THREAD_IN_PROC(td->td_proc, othertd) {
+ if (othertd != td) {
+ linux_proc_init(td, othertd,
+ LINUX_CLONE_THREAD);
+ }
+ }
+ }
#if defined(__amd64__)
/*
* An IA32 executable which has executable stack will have the
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 21, 8:51 PM (12 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25802418
Default Alt Text
D25293.id73182.diff (1 KB)
Attached To
Mode
D25293: Fix execution of linux binary from multithreaded process.
Attached
Detach File
Event Timeline
Log In to Comment