Re:Where do argc and argv come from?
by segfaultbuserr on Monday August 10, 2020 @04:48PM
(#24113812)
Modifying argv is a classic trick to implement an "error log of last resort" - How can you log an error message when the I/O itself has failed (e.g. the disk is full)? You can write you message to argv. A sysadmin running ps can quickly spot a "FATAL ERROR OCCURRED" argument appears next to the program name. Famously used by DJB in his mail server.
Re:Where do argc and argv come from?
by cryptonector on Monday August 10, 2020 @05:09PM
(#24114029)
There are OSes where altering `argv[0]` changes the ps strings, and ones where it doesn't. Arranging to support this is tricky, as it can be a way to attack users of ps(1) and /proc!
Fun fact: iTerm recently had to redesign some of their APIs because the process name APIs would be susceptible to a malicious program overwriting its argv (the normal API for this has the kernel read out of the process's address space).
Chromium, for example, does this: https://source.chromium.org/chromium/chromium/src/+/master:s...