]> git.baikalelectronics.ru Git - kernel.git/commit
/proc/<pid>/cmdline: add back the setproctitle() special case
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 13 Jul 2019 21:27:14 +0000 (14:27 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 16 Jul 2019 16:57:52 +0000 (09:57 -0700)
commitb008c7813ad3a6451be7a98c54e357c1f1000d46
tree3e68c8c7d4fc8d42021a7747e79591e2a3028701
parente84833a8c8b24e12a6c2a354b52b62597946d435
/proc/<pid>/cmdline: add back the setproctitle() special case

This makes the setproctitle() special case very explicit indeed, and
handles it with a separate helper function entirely.  In the process, it
re-instates the original semantics of simply stopping at the first NUL
character when the original last NUL character is no longer there.

[ The original semantics can still be seen in mm/util.c: get_cmdline()
  that is limited to a fixed-size buffer ]

This makes the logic about when we use the string lengths etc much more
obvious, and makes it easier to see what we do and what the two very
different cases are.

Note that even when we allow walking past the end of the argument array
(because the setproctitle() might have overwritten and overflowed the
original argv[] strings), we only allow it when it overflows into the
environment region if it is immediately adjacent.

[ Fixed for missing 'count' checks noted by Alexey Izbyshev ]

Link: https://lore.kernel.org/lkml/alpine.LNX.2.21.1904052326230.3249@kich.toxcorp.com/
Fixes: 29fda38fd0f6 ("fs/proc: simplify and clarify get_mm_cmdline() function")
Cc: Jakub Jankowski <shasta@toxcorp.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Alexey Izbyshev <izbyshev@ispras.ru>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/proc/base.c