php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77044 Process Name has lots of null appended
Submitted: 2018-10-21 22:10 UTC Modified: 2024-03-28 19:00 UTC
From: d28b312d at opayq dot com Assigned: bukka (profile)
Status: Not a bug Package: FPM related
PHP Version: Irrelevant OS: CentOS
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
38 + 14 = ?
Subscribe to this entry?

 
 [2018-10-21 22:10 UTC] d28b312d at opayq dot com
Description:
------------
When php-fpm starts it seems to set a wild command line which causes problems with tools such as `pgrep -xf`.

Using: `cat /proc/<procid>/cmdline | hexdump -C`

For example, most normal tools:
00000000  2f 75 73 72 2f 6c 69 62  2f 70 6f 6c 6b 69 74 2d  |/usr/lib/polkit-|
00000010  31 2f 70 6f 6c 6b 69 74  64 00 2d 2d 6e 6f 2d 64  |1/polkitd.--no-d|
00000020  65 62 75 67 00                                    |ebug.|

But php-fpm processes:
00000000  70 68 70 2d 66 70 6d 3a  20 6d 61 73 74 65 72 20  |php-fpm: master |
00000010  70 72 6f 63 65 73 73 20  28 2f 65 74 63 2f 70 68  |process (/etc/ph|
00000020  70 2d 66 70 6d 2e 63 6f  6e 66 29 00 00 00 00 00  |p-fpm.conf).....|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00     |...............|

This applies to all php-fpm processes, and so far, _no_ other processes on my system , which leads me to believe it's a bug in php-fpm.

Expected result:
----------------
00000000  70 68 70 2d 66 70 6d 3a  20 6d 61 73 74 65 72 20  |php-fpm: master |
00000010  70 72 6f 63 65 73 73 20  28 2f 65 74 63 2f 70 68  |process (/etc/ph|
00000020  70 2d 66 70 6d 2e 63 6f  6e 66 29 00              |p-fpm.conf).|

Actual result:
--------------
00000000  70 68 70 2d 66 70 6d 3a  20 6d 61 73 74 65 72 20  |php-fpm: master |
00000010  70 72 6f 63 65 73 73 20  28 2f 65 74 63 2f 70 68  |process (/etc/ph|
00000020  70 2d 66 70 6d 2e 63 6f  6e 66 29 00 00 00 00 00  |p-fpm.conf).....|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00     |...............|

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-10-21 22:31 UTC] requinix@php.net
If this is to hide the argument list, which I suspect is the case, then a better trick may be to zero out all but the last byte.
http://netsplit.com/hiding-arguments-from-ps
If the kernel does what the article says then only argv[0] will be exposed, but if not then everything was still deleted.
 [2024-03-28 18:25 UTC] bukka@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: bukka
 [2024-03-28 18:25 UTC] bukka@php.net
I have been looking into this and checking other apps (specifically nginx) as well and the logic seemed pretty similar to me. The problem with getting this fixed is that I'm actually unable to recreate it. I have been checking the kernel implementation of cmdline in fs/proc/base.c and and there are some changes that are changing things back from the previous refactoring: https://github.com/torvalds/linux/commit/3d71254 . It looks like there could be some change that made this visible but it is no longer there.

So I will close this but if you see it still happening anywhere, please open a new GitHub issue and I will investigate.
 [2024-03-28 19:00 UTC] bukka@php.net
Seems like this also happened later on Ubuntu 22.04 actually so not sure if the mentioned commit is the actual fix. There is more discussion here: https://github.com/php/php-src/issues/10204 .
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 16:01:30 2024 UTC