3 ms·
Yes, you're right. It's been a while, I didn't think of that edge case. For the purposes of that code it's still OK. It would read a kernel thread's file, fail
by avar 4y ago
Yes, you're right. It's been a while, I didn't think of that edge case.
For the purposes of that code it's still OK. It would read a kernel thread's file, fail to find the ending ")", and stop looking.
It's possible in principle that the kernel could a crafted kernel thread name that contained ")", followed by e.g. " X 12345 ". In that case I'd misinterpret that "12345" as the parent PID, and continue walking up that parent chain.
But in practice the kernel doesn't have, and is exceeding unlikely to have such "comm" fields.
Still, it's annoying that this was silently changed in v4.18 without a corresponding documentation update. It's easy to imagine C code written to assume its promises are true that would misbehave or segfault in the face of these longer kernel thread names.
Edit: I submitted linux-man patches to clarify this point: https://lore.kernel.org/linux-man/cover-0.2-000000000-20221223T174835Z-avarab@gmail.com/ https://lore.kernel.org/linux-man/cover-0.2-000000000-202212...