|
|
Subscribe / Log in / New account

Unique randomized wide PIDs

Unique randomized wide PIDs

Posted Jun 12, 2025 8:48 UTC (Thu) by donald.buczek (subscriber, #112892)
In reply to: Unique randomized wide PIDs by bluca
Parent article: Slowing the flow of core-dump-related CVEs

However, I wonder how userspace can easily determine whether a pidfd inode number comes from a system that guarantees uniqueness.


to post comments

Unique randomized wide PIDs

Posted Jun 12, 2025 11:15 UTC (Thu) by bluca (subscriber, #118303) [Link] (1 responses)

There was a way, I forget the details, but on systems where it's not unique it's a fixed/hardcoded/well-known inode number, because it's an anonymous inode rather than from pidfdfs? Details are fuzzy so I might be getting this wrong

Unique randomized wide PIDs

Posted Jun 14, 2025 9:45 UTC (Sat) by donald.buczek (subscriber, #112892) [Link]

I found that you can use fstatfs() on the file descriptor and see if f_type == PID_FS_MAGIC ( 0x50494446; /* "PIDF" */ ). On an elder system it is ANON_INODE_FS_MAGIC (0x09041934)

Note, that although pidfd_open(2) says opening a "/proc/[PID]" directory would be an alternative way to get a PID file descriptor, this is only half true: You can use such a file descriptor with pidfd_* calls, but it is another type of file descriptor with f_type == PROC_SUPER_MAGIC ( 0x9fa0 ) and you can't use the inode number from that kind of file descriptor as a unique process identifier.

I still wish, processes had UUIDs.


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