* [PATCH] proc(5): clarify /proc/pid/environ behavior
@ 2017-02-15 22:16 Mike Frysinger
[not found] ` <20170215221654.10293-1-vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Mike Frysinger @ 2017-02-15 22:16 UTC (permalink / raw)
To: Michael Kerrisk; +Cc: linux-man-u79uwXL29TY76Z2rM5mHXA
From: Mike Frysinger <vapier-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Make sure people don't try to rely on this when there are no guarantees
the target process respects it.
Signed-off-by: Mike Frysinger <vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
---
man5/proc.5 | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/man5/proc.5 b/man5/proc.5
index 0a3503f99360..89a7c09ad5af 100644
--- a/man5/proc.5
+++ b/man5/proc.5
@@ -477,7 +477,7 @@ check; see
.BR ptrace (2).
.TP
.I /proc/[pid]/environ
-This file contains the environment for the process.
+This file contains the initial environment for the process.
The entries are separated by null bytes (\(aq\\0\(aq),
and there may be a null byte at the end.
Thus, to print out the environment of process 1, you would do:
@@ -488,6 +488,19 @@ Thus, to print out the environment of process 1, you would do:
.fi
.in
+Once a process starts modifying its environment
+(e.g. by calling functions such as
+.BR putenv (3)
+or modifying the
+.BR environ (7)
+variable directly),
+this file will not be kept up to date.
+
+Further, a process may change the memory this points to by calling
+.BR prctl (2)
+and using operations such as
+.BR PR_SET_MM_ENV_START .
+
Permission to access this file is governed by a ptrace access mode
.B PTRACE_MODE_READ_FSCREDS
check; see
--
2.11.0
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] proc(5): clarify /proc/pid/environ behavior
[not found] ` <20170215221654.10293-1-vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
@ 2017-02-20 14:16 ` Michael Kerrisk (man-pages)
[not found] ` <a6982b2f-7cd6-ad1d-d375-0a41ab539084-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Michael Kerrisk (man-pages) @ 2017-02-20 14:16 UTC (permalink / raw)
To: Mike Frysinger
Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w, linux-man-u79uwXL29TY76Z2rM5mHXA
Hi Mike,
On 02/15/2017 11:16 PM, Mike Frysinger wrote:
> From: Mike Frysinger <vapier-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
>
> Make sure people don't try to rely on this when there are no guarantees
> the target process respects it.
>
> Signed-off-by: Mike Frysinger <vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
> ---
> man5/proc.5 | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/man5/proc.5 b/man5/proc.5
> index 0a3503f99360..89a7c09ad5af 100644
> --- a/man5/proc.5
> +++ b/man5/proc.5
> @@ -477,7 +477,7 @@ check; see
> .BR ptrace (2).
> .TP
> .I /proc/[pid]/environ
> -This file contains the environment for the process.
> +This file contains the initial environment for the process.
> The entries are separated by null bytes (\(aq\\0\(aq),
> and there may be a null byte at the end.
> Thus, to print out the environment of process 1, you would do:
> @@ -488,6 +488,19 @@ Thus, to print out the environment of process 1, you would do:
> .fi
> .in
>
> +Once a process starts modifying its environment
> +(e.g. by calling functions such as
> +.BR putenv (3)
> +or modifying the
> +.BR environ (7)
> +variable directly),
> +this file will not be kept up to date.
> +
> +Further, a process may change the memory this points to by calling
> +.BR prctl (2)
> +and using operations such as
> +.BR PR_SET_MM_ENV_START .
> +
> Permission to access this file is governed by a ptrace access mode
> .B PTRACE_MODE_READ_FSCREDS
> check; see
Thanks! Patch applied. I tweaked somewhat, in particular to further clarify
the file content is set at execve(2) time. Does the following look okay
to you?
/proc/[pid]/environ
This file contains the initial environment that was set
when the currently executing program was started via
execve(2). The entries are separated by null bytes ('\0'),
and there may be a null byte at the end. Thus, to print
out the environment of process 1, you would do:
$ strings /proc/1/environ
If, after an execve(2), the process modifies its environ‐
ment (e.g., by calling functions such as putenv(3) or modi‐
fying the environ(7) variable directly), this file will not
reflect those changes.
Furthermore, a process may change the memory location that
this file refers via prctl(2) operations such as
PR_SET_MM_ENV_START.
Cheers,
Michael
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] proc(5): clarify /proc/pid/environ behavior
[not found] ` <a6982b2f-7cd6-ad1d-d375-0a41ab539084-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2017-02-20 18:54 ` Mike Frysinger
2017-02-20 21:01 ` Michael Kerrisk (man-pages)
0 siblings, 1 reply; 4+ messages in thread
From: Mike Frysinger @ 2017-02-20 18:54 UTC (permalink / raw)
To: Michael Kerrisk (man-pages); +Cc: linux-man-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1: Type: text/plain, Size: 245 bytes --]
On 20 Feb 2017 15:16, Michael Kerrisk (man-pages) wrote:
> Thanks! Patch applied. I tweaked somewhat, in particular to further clarify
> the file content is set at execve(2) time. Does the following look okay
> to you?
looks good, thanks
-mike
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] proc(5): clarify /proc/pid/environ behavior
2017-02-20 18:54 ` Mike Frysinger
@ 2017-02-20 21:01 ` Michael Kerrisk (man-pages)
0 siblings, 0 replies; 4+ messages in thread
From: Michael Kerrisk (man-pages) @ 2017-02-20 21:01 UTC (permalink / raw)
To: linux-man-u79uwXL29TY76Z2rM5mHXA
Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w, Mike Frysinger
On 02/20/2017 07:54 PM, Mike Frysinger wrote:
> On 20 Feb 2017 15:16, Michael Kerrisk (man-pages) wrote:
>> Thanks! Patch applied. I tweaked somewhat, in particular to further clarify
>> the file content is set at execve(2) time. Does the following look okay
>> to you?
Thanks for checkining, Mike.
Cheers,
Michael
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-02-20 21:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-15 22:16 [PATCH] proc(5): clarify /proc/pid/environ behavior Mike Frysinger
[not found] ` <20170215221654.10293-1-vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
2017-02-20 14:16 ` Michael Kerrisk (man-pages)
[not found] ` <a6982b2f-7cd6-ad1d-d375-0a41ab539084-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-20 18:54 ` Mike Frysinger
2017-02-20 21:01 ` Michael Kerrisk (man-pages)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.