public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] proc.5: Clarify the format of /proc/$PID/cmdline
@ 2023-05-24 14:33 Günther Noack
  2023-05-24 23:31 ` Alejandro Colomar
  0 siblings, 1 reply; 2+ messages in thread
From: Günther Noack @ 2023-05-24 14:33 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: Matt Bobrowski, linux-man, Günther Noack

It is possible to produce /proc/$PID/cmdline files which do not follow
the NUL-seperated format, by using the tricks described in the
paragraph below.

Signed-off-by: Günther Noack <gnoack@google.com>
---
 man5/proc.5 | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/man5/proc.5 b/man5/proc.5
index a9bb175e8..a16479634 100644
--- a/man5/proc.5
+++ b/man5/proc.5
@@ -497,10 +497,21 @@ unless the process is a zombie.
 .\" In Linux 2.3.26, this also used to be true if the process was swapped out.
 In the latter case, there is nothing in this file:
 that is, a read on this file will return 0 characters.
-The command-line arguments appear in this file as a set of
-strings separated by null bytes (\[aq]\e0\[aq]),
+.IP
+For processes which are still running,
+the command-line arguments appear in this file
+in the same layout as they do in process memory:
+If the process is well-behaved,
+it is a set of strings separated by null bytes (\[aq]\e0\[aq]),
 with a further null byte after the last string.
 .IP
+This is the common case,
+but processes have the freedom to override
+the memory region and break assumptions
+about the contents or format of the
+.IR /proc/ pid /cmdline
+file.
+.IP
 If, after an
 .BR execve (2),
 the process modifies its

base-commit: 4ca216bacc7d185c1af3c384ab53cd1ec74830d1
-- 
2.40.1.698.g37aff9b760-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] proc.5: Clarify the format of /proc/$PID/cmdline
  2023-05-24 14:33 [PATCH] proc.5: Clarify the format of /proc/$PID/cmdline Günther Noack
@ 2023-05-24 23:31 ` Alejandro Colomar
  0 siblings, 0 replies; 2+ messages in thread
From: Alejandro Colomar @ 2023-05-24 23:31 UTC (permalink / raw)
  To: Günther Noack; +Cc: Matt Bobrowski, linux-man


[-- Attachment #1.1: Type: text/plain, Size: 1670 bytes --]

Hi Günther!

On 5/24/23 16:33, Günther Noack wrote:
> It is possible to produce /proc/$PID/cmdline files which do not follow
> the NUL-seperated format, by using the tricks described in the
> paragraph below.
> 
> Signed-off-by: Günther Noack <gnoack@google.com>

Thanks!  Patch applied.

Cheers,
Alex

> ---
>  man5/proc.5 | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/man5/proc.5 b/man5/proc.5
> index a9bb175e8..a16479634 100644
> --- a/man5/proc.5
> +++ b/man5/proc.5
> @@ -497,10 +497,21 @@ unless the process is a zombie.
>  .\" In Linux 2.3.26, this also used to be true if the process was swapped out.
>  In the latter case, there is nothing in this file:
>  that is, a read on this file will return 0 characters.
> -The command-line arguments appear in this file as a set of
> -strings separated by null bytes (\[aq]\e0\[aq]),
> +.IP
> +For processes which are still running,
> +the command-line arguments appear in this file
> +in the same layout as they do in process memory:
> +If the process is well-behaved,
> +it is a set of strings separated by null bytes (\[aq]\e0\[aq]),
>  with a further null byte after the last string.
>  .IP
> +This is the common case,
> +but processes have the freedom to override
> +the memory region and break assumptions
> +about the contents or format of the
> +.IR /proc/ pid /cmdline
> +file.
> +.IP
>  If, after an
>  .BR execve (2),
>  the process modifies its
> 
> base-commit: 4ca216bacc7d185c1af3c384ab53cd1ec74830d1

-- 
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-24 23:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-24 14:33 [PATCH] proc.5: Clarify the format of /proc/$PID/cmdline Günther Noack
2023-05-24 23:31 ` Alejandro Colomar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox