1
1
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2
2
From: David Greaves <
[email protected] >
3
3
Date: Wed, 20 Jan 2021 09:40:34 +0000
4
- Subject: [PATCH] Provide ENV controls to bypass some sb2 calls between
5
- fork exec
4
+ Subject: [PATCH] Provide ENV controls to bypass some sb2 calls between fork
5
+ exec
6
6
7
7
In threaded systems there can be deadlocks caused by calling malloc
8
8
after fork and before exec. Rust manages this but sb2 does not.
@@ -32,12 +32,13 @@ and the fallback fork/exec is used.
32
32
Note that some reworking of rust's handling of program/argv[0] was
33
33
needed to support the SHIM functionality
34
34
35
+ Co-authored-by: Ruben De Smet <
[email protected] >
35
36
Signed-off-by: David Greaves <
[email protected] >
36
37
Signed-off-by: Ruben De Smet <
[email protected] >
37
38
---
38
39
.../src/sys/unix/process/process_common.rs | 55 ++++++-
39
- .../std/src/sys/unix/process/process_unix.rs | 138 ++++++++++++++++--
40
- 2 files changed, 173 insertions(+), 20 deletions(-)
40
+ .../std/src/sys/unix/process/process_unix.rs | 137 ++++++++++++++++--
41
+ 2 files changed, 172 insertions(+), 20 deletions(-)
41
42
42
43
diff --git a/library/std/src/sys/unix/process/process_common.rs b/library/std/src/sys/unix/process/process_common.rs
43
44
index 640648e8707..f15625e0514 100644
@@ -155,7 +156,7 @@ index 640648e8707..f15625e0514 100644
155
156
// Set a new arg0
156
157
let arg = os2c(arg, &mut self.saw_nul);
157
158
diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs
158
- index 3963e7f52d5..d08e4db6199 100644
159
+ index 3963e7f52d5..b491c2ad75f 100644
159
160
--- a/library/std/src/sys/unix/process/process_unix.rs
160
161
+++ b/library/std/src/sys/unix/process/process_unix.rs
161
162
@@ -25,7 +25,7 @@
@@ -253,13 +254,12 @@ index 3963e7f52d5..d08e4db6199 100644
253
254
#[cfg(target_os = "linux")]
254
255
if self.get_create_pidfd() {
255
256
self.send_pidfd(&output);
256
- @@ -268,7 +331,48 @@ pub fn exec(&mut self, default: Stdio) -> io::Error {
257
+ @@ -268,7 +331,47 @@ pub fn exec(&mut self, default: Stdio) -> io::Error {
257
258
Err(e) => e,
258
259
}
259
260
}
260
261
-
261
- + fn unwrap_drop(&mut self, fh: sys::unix::pipe::AnonPipe) {
262
- + use crate::os::unix::io::AsRawFd;
262
+ + fn unwrap_drop(&mut self, fh: impl crate::os::unix::io::AsRawFd) {
263
263
+ // drop() simply calls libc::close(fh.fd)
264
264
+ match self.close {
265
265
+ Some(real_close) => {
@@ -303,7 +303,7 @@ index 3963e7f52d5..d08e4db6199 100644
303
303
// And at this point we've reached a special time in the life of the
304
304
// child. The child must now be considered hamstrung and unable to
305
305
// do anything other than syscalls really. Consider the following
306
- @@ -308,13 +412 ,13 @@ unsafe fn do_exec(
306
+ @@ -308,13 +411 ,13 @@ unsafe fn do_exec(
307
307
use crate::sys::{self, cvt_r};
308
308
309
309
if let Some(fd) = stdio.stdin.fd() {
@@ -320,7 +320,7 @@ index 3963e7f52d5..d08e4db6199 100644
320
320
}
321
321
322
322
#[cfg(not(target_os = "l4re"))]
323
- @@ -322,10 +426 ,10 @@ unsafe fn do_exec(
323
+ @@ -322,10 +425 ,10 @@ unsafe fn do_exec(
324
324
if let Some(_g) = self.get_groups() {
325
325
//FIXME: Redox kernel does not support setgroups yet
326
326
#[cfg(not(target_os = "redox"))]
@@ -333,7 +333,7 @@ index 3963e7f52d5..d08e4db6199 100644
333
333
}
334
334
if let Some(u) = self.get_uid() {
335
335
// When dropping privileges from root, the `setgroups` call
336
- @@ -337,13 +441 ,13 @@ unsafe fn do_exec(
336
+ @@ -337,13 +440 ,13 @@ unsafe fn do_exec(
337
337
//FIXME: Redox kernel does not support setgroups yet
338
338
#[cfg(not(target_os = "redox"))]
339
339
if libc::getuid() == 0 && self.get_groups().is_none() {
@@ -350,7 +350,7 @@ index 3963e7f52d5..d08e4db6199 100644
350
350
}
351
351
352
352
if let Some(pgroup) = self.get_pgroup() {
353
- @@ -401,8 +505 ,12 @@ fn drop(&mut self) {
353
+ @@ -401,8 +504 ,12 @@ fn drop(&mut self) {
354
354
_reset = Some(Reset(*sys::os::environ()));
355
355
*sys::os::environ() = envp.as_ptr();
356
356
}
@@ -365,15 +365,15 @@ index 3963e7f52d5..d08e4db6199 100644
365
365
Err(io::Error::last_os_error())
366
366
}
367
367
368
- @@ -429,6 +537 ,7 @@ fn posix_spawn(
368
+ @@ -429,6 +536 ,7 @@ fn posix_spawn(
369
369
_: &ChildPipes,
370
370
_: Option<&CStringArray>,
371
371
) -> io::Result<Option<Process>> {
372
372
+ eprintln!("process_unix:270: in null posix_spawn");
373
373
Ok(None)
374
374
}
375
375
376
- @@ -452,12 +561 ,15 @@ fn posix_spawn(
376
+ @@ -452,12 +560 ,15 @@ fn posix_spawn(
377
377
use crate::mem::MaybeUninit;
378
378
use crate::sys::{self, cvt_nz, unix_sigpipe_attr_specified};
379
379
@@ -390,5 +390,5 @@ index 3963e7f52d5..d08e4db6199 100644
390
390
return Ok(None);
391
391
}
392
392
- -
393
- 2.42 .0
393
+ 2.43 .0
394
394
0 commit comments