public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
From: "Günther Noack" <gnoack@google.com>
To: Alejandro Colomar <alx.manpages@gmail.com>
Cc: "Matt Bobrowski" <repnop@google.com>,
	linux-man@vger.kernel.org, "Günther Noack" <gnoack@google.com>
Subject: [PATCH] proc.5: Clarify the format of /proc/$PID/cmdline
Date: Wed, 24 May 2023 16:33:07 +0200	[thread overview]
Message-ID: <20230524143307.1076366-1-gnoack@google.com> (raw)

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


             reply	other threads:[~2023-05-24 14:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-24 14:33 Günther Noack [this message]
2023-05-24 23:31 ` [PATCH] proc.5: Clarify the format of /proc/$PID/cmdline Alejandro Colomar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230524143307.1076366-1-gnoack@google.com \
    --to=gnoack@google.com \
    --cc=alx.manpages@gmail.com \
    --cc=linux-man@vger.kernel.org \
    --cc=repnop@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox