|
|
Log in / Subscribe / Register

Process ids again

Process ids again

Posted Jun 7, 2025 5:38 UTC (Sat) by epa (subscriber, #39769)
In reply to: Process ids again by Nahor
Parent article: Slowing the flow of core-dump-related CVEs

A shell script needs no update for 64-bit process ids. It’s just a slightly longer string than before. A C program using pid_t may just need a recompile, though of course there will be some code putting a process id into an int (I imagine a compiler warning can mostly catch this).

Rewriting a C program to use pidfds is a much bigger task, and rewriting a shell script with them is essentially impossible.

Scripting languages like Perl, Python, and Tcl would usually just need the interpreter itself recompiled for 64-bit pids and existing scripts will work unchanged.


to post comments

Process ids again

Posted Jun 7, 2025 18:58 UTC (Sat) by Nahor (subscriber, #51583) [Link]

> A shell script needs no update for 64-bit process ids

Most won't, but a script can still make assumption on the pid size, e.g. it only contains 10 digits.

> A C program using pid_t may just need a recompile

Keyword "may".
And even for the simple cases, this depends a lot on how 64-bits pids would be implemented, e.g. would this be a compilation flag? Or a "#define USE_PID64"? Or would this be changing all the "pid_t"/"getpid()"/... to "pid64_t"/"getpid64()"/...?

And in the non-simple cases, the issues are the same for 64-bits pids and pidfds (apps using pid in a "smart" way will be majorly broken, pid64/pidfd cannot be passed as-is when communicating a 32-bit pid apps, ...).

> I imagine a compiler warning can mostly catch this

Only in simple cases, maybe. And AFAIK, currently, compilers will not complain when storing a in64_t in an int32_t without the "-Wconversion" flag (which is not enabled even when using "-Wall -Wextra -pedantic"). And even "-Wconversion" will not complain if there is a cast involved. https://godbolt.org/z/z3jGbYb86

> there will be some code putting a process id into an int

Or putting it in the low bits of an int64_t then use the high bits for something else.
Or assume that a struct containing a pid has a specific size. Or that fields in that struct after the pid are at specific offsets.
Or ... (don't underestimate what people do when they assume something will be true forever)...

Basically, one can look at what happened during then transition from 32-bit to 64-bit platforms, the switch to large file (>4GB), and the Y38 problems, to see all the possible issues than can arise.

> Rewriting a C program to use pidfds is a much bigger task

I'm not so sure. Since a pidfd is actually a pid_t type, and depending on what pid/pidfd are used for, updating could boil down to calling "pidfd_xyz()" instead of "xyz()", or passing a "XYZ_PIDFD" flag.

For the rest, that can be a big task to fix in either case. For instance, if the problem is someone combining the pid with something else in an int64_t, then a pidfd will still work fine, while the pid64 will need a redesign.
Or people might make the same assumption that you did, that pid64 is just a recompilation, then spend a lot of time tracking down bugs. While with pidfs, they would spend time looking at each call sites first, fixing the problems before they arise and need tracking.
Which one will take more time will depend on the applications. Sometimes it's faster to think things through first, some others it faster to just try&fix. This very much apply here IMHO.

Process ids again

Posted Jul 4, 2025 13:51 UTC (Fri) by judas_iscariote (guest, #47386) [Link]

> A C program using pid_t may just need a recompile

You are assuming a properly carefully wrritten program..there is still code out there that assumes pids are 16 bit and store them in a ushort..There is incorrect casting, there is code not using pid_t at all.. I mean there is a lot of buggy software out there...


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds