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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: d28b312d at opayq dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Sat Dec 14 06:01:27 2024 UTC