]> git.baikalelectronics.ru Git - kernel.git/commit
proc: fix missing final NUL in get_mm_cmdline() rewrite
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 20 Jun 2018 00:47:20 +0000 (09:47 +0900)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 20 Jun 2018 06:38:28 +0000 (15:38 +0900)
commita4048c03d73823599a19564a9e06e58f84d470af
tree2b7843426934e646643fff30cb9608ce574e6cc6
parentca3f89b93f005a019a1f7ffefd441085c0f2ae63
proc: fix missing final NUL in get_mm_cmdline() rewrite

The rewrite of the cmdline fetching missed the fact that we used to also
return the final terminating NUL character of the last argument.  I
hadn't noticed, and none of the tools I tested cared, but something
obviously must care, because Michal Kubecek noticed the change in
behavior.

Tweak the "find the end" logic to actually include the NUL character,
and once past the eend of argv, always start the strnlen() at the
expected (original) argument end.

This whole "allow people to rewrite their arguments in place" is a nasty
hack and requires that odd slop handling at the end of the argv array,
but it's our traditional model, so we continue to support it.

Repored-and-bisected-by: Michal Kubecek <mkubecek@suse.cz>
Reviewed-and-tested-by: Michal Kubecek <mkubecek@suse.cz>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/proc/base.c