[Toybox] Chromium's producing even _more_ insane ps data.

enh enh at google.com
Mon Jun 6 14:51:39 PDT 2016


(fwiw, the Android security folks have wanted something like this in
the past. i've always tried to suggest they don't parse the output of
tools for security stuff, though, so they know exactly what they're
looking at, and exactly what transformations it's undergone.)

On Thu, Jun 2, 2016 at 12:40 PM, Rob Landley <rob at landley.net> wrote:
> It's good to have stress tests, but I've already built the 0.7.1 release
> binaries. :P
>
> Those strange "chro" processes chromium-browser produces on Ubuntu 14.04
> are even weirder than I thought, I was trying to get ps to show them and
> it instead decided to say:
>
> $ ./ps -O args -p 11322
>   PID TTY          TIME ARGS                        CMD
> 11322 ?        00:04:09 o                           chromium-browse
>
> Investigating why ARGS is showing up as "o", I find this:
>
> $ hexdump -C /proc/11322/cmdline
> 00000000  2f 75 73 72 2f 6c 69 62  2f 63 68 72 6f 6d 69 75  |/usr/lib/chromiu|
> 00000010  6d 2d 62 72 6f 77 73 65  72 2f 63 68 72 6f 00 00  |m-browser/chro..|
> 00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
> 00000030  00 00 00 00 00 00 00 00  00                       |.........       |
>
> That's a lotta null bytes appended to the truncated command line.
>
> What ps is doing is treating each of those as appended "" arguments, so
> it thinks it should display:
>
> chro "" "" "" "" "" "" "" "" "" "" ""
>
> And so on. It's turning each NUL into a space, and then showing the
> rightmost 30-ish bytes (whatever the field width is), and that leaves
> just enough space for the last letter of the truncated "chro".
>
> So now that I've worked out why it's doing that... what IS the right
> behavior here? I can truncate trailing nuls but how do I distinguish
> them from _actual_ trailing "" "" "" "" arguments I might really want
> to display somehow? (Possibly in a less ambiguous way than just
> as trailing spaces...)
>
> Sigh. Not that ps is going to distinguish between echo "" "" "" "" "" and
> echo "     " at the best of times. (You'd think with the amount of
> effort Jorg Schilling's posix committee has put into language lawyering
> and arguing they'd have explored some actual edge cases, but no.)
>
> Maybe I should add -o QUOTARGS to unambigously represent command line
> contents with quotes argument arguments and %XX hex escapes similar to
> URL quoting? (In this case screw utf8: surround each argument with
> quotes and %escape anything <32, >=127 (plus % and ").
>
> Sigh, I hate making up new "standards". Any opinions here?
>
> Rob
> _______________________________________________
> Toybox mailing list
> Toybox at lists.landley.net
> http://lists.landley.net/listinfo.cgi/toybox-landley.net



-- 
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.


More information about the Toybox mailing list