When a process execs, looking at kernel code for environ_read(), it seems that if the mm_struct doesn't yet exist / is null or the env_end member of that mm_struct is null, environ_read() will return 0 ~immediately.
My question is, are there protections WRT fork/exec races such that (pseudo-code ahead)
if ((pid = fork) != 0) execv*("/bin/exe", {"exe", "-l"}, &envp) read("/proc/${pid}/environ") Cannot:
A: erroneously read a zero-length env due to races with execve and the subsequent read (e.g: assuming the user space program that issues the read is multi-threaded or performing asynchronous IO)
B: erroneously read a partial env (assuming user-space code is not causing a short read due to a bug in user space code)
C: erroneously read the parent's env
Are reads from /p/p/environ atomic?