[Toybox] [PATCH] taskset: fix buffer overflow from long mask
Jesse Rosenstock
jmr at google.com
Tue Jun 24 00:21:52 PDT 2025
On Mon, Jun 23, 2025 at 10:22 PM Rob Landley <rob at landley.net> wrote:
> tl;dr: commit 105a72fd53c2
This handles long masks differently than util-linux:
% ./toybox taskset $( printf %99999s | tr ' ' 0 )f echo ok
taskset: failed to set pid 1580999's affinity: Invalid argument
% taskset $( printf %99999s | tr ' ' 0 )f echo ok
ok
Do you want a patch?
> > Use sizeof(toybuf) rather than 4096 when calling sched_getaffinity;
> > maybe toybuf's size will change.
>
> To be honest, I'm pretty sure I used 4096 there so I wouldn't have to
> wrap the line at 80 chars. :)
Seems likely, since sizeof(toybox) is used above and the formatting is
scrunched.
> Fuzz? Ah, your first hunk starts with a blank line instead of the
> comment added in commit 5afab26b9c98 three years ago.
I'm sorry for that. I made the patch against a version in our
monorepo that I had
assumed was up-to-date. It won't happen again.
> So the next obvious thing to do is "taskset 2 taskset", which doesn't
> work because running taskset with no arguments doesn't tell you the
> current process's mask (inherited from the parent process)
I would like this, too. I can try sending util-linux a patch if you
don't want to.
More information about the Toybox
mailing list