[Toybox] [PATCH] taskset: fix buffer overflow from long mask

Rob Landley rob at landley.net
Mon Aug 4 10:58:31 PDT 2025


On 7/7/25 10:29, Jesse Rosenstock wrote:
> On Mon, Jun 23, 2025 at 10:22 PM Rob Landley <rob at landley.net> wrote:
>> Oh, and here's another fun one. If I tell a process to run on a specific
>> processor and then try to ask ps -o cpu= what processor it's running on,
>> toybox ps tells me but gnu ps always says "-".
> 
> You can use psr=, which both procps and toybox support.

I initially didn't use this because:

$ ps -o PSR $$
error: unknown user-defined format specifier "PSR"

Usage:
  ps [options]

  Try 'ps --help <simple|list|output|threads|misc|all>'
   or 'ps --help <s|l|o|t|m|a>'
  for additional help text.

For more details see ps(1).
$ toybox ps -o PSR $$
PSR
   0

But you're right, psr= produces different output for both. (Avoiding an 
error for debian and taking out the useless header line in toybox.)

Hmmm, toybox is still producing a blank line (which isn't blank, it's 
three spaces then a newline), which $() would presumably eat and it 
_has_ to do that because both have leading spaces for three character 
field alignment, but still... Commit b8186ba3c4d9

That said, A) taskset is still a linux-only command using a Linux API, 
B) $$ is still the parent shell not the new child task. The advantage of 
cat /proc/self/stat is the child process is opening the file at that 
path so the "self" symlink points to the child process...

> What to call this seems like something POSIX could standardize.
> 
> There's "cpu" (FreeBSD), "psr" (Solaris), "lastcpu" (DragonFly BSD),
> "cpuid" (NetBSD/OpenBSD).

Let's see, SUSv2 was 1997, SUSv3 was 2001 (4 years later), SUSv4 was 
2008 (7 years later), SUSv4 was 2024 (16 years later)... If we're both 
still here in 2058, remind me to look up this issue.

Rob


More information about the Toybox mailing list