The trouble with symbolic links
The trouble with symbolic links
Posted Jul 18, 2022 10:17 UTC (Mon) by ras (subscriber, #33059)Parent article: The trouble with symbolic links
Parallelism is the hardest thing to get right in the programming world. POSIX offers no help whatsoever. It doesn't have transactions, and it doesn't have mandatory locks. Even the simplest of things like doing an atomic set of writes to a single file so hard we have the SQLite designer tell us to use it like fwrite(). Using an entire SQL library just to do reliable writes should be an absurd recommendation, but as things stand: he's right.
Because it's near impossible to get right, there are many bugs, some have security implications, and thus POSIX's total non-support of transactions has the cause of CVE after CVE for literally decades. It's not just symlinks. We seen streams of CVE's over the downright trivial operation of creating a temporary file, and surprise surprise hard links have their share of CVE's too. Renames, copies, moves, deletes are all the same. If you can't be 100% sure of what the file system looks like when you execute them (and POSIX ensures you can never be sure if there is more than one thread), then the end result is likely to be a gamble.
Or to put it another way, if POSIX did support transactions, most of the symlink CVE's he mentions, and all the need for all these xxxxat() operations would just vanish. Ergo, symlink's aren't the problem, and getting rid of them won't fix it.
