←back to thread

Against /Tmp

(dotat.at)
143 points todsacerdoti | 2 comments | | HN request time: 0.013s | source
Show context
Aardwolf ◴[] No.41913873[source]
I like /tmp in RAM myself, it's truly temporary that way

EDIT: I do this more for avoiding certain disk reads/writes than security actually

replies(6): >>41913905 #>>41913910 #>>41913918 #>>41914627 #>>41916103 #>>41916856 #
nullindividual ◴[] No.41913905[source]
You'd need to pin pages in physical memory to guarantee it stays in physical memory. What happens if an 'attacker' (or accidental user) exceeds available physical memory? OOM Kill other applications? Just don't accept temp data, leading to failures in operations requested by the user or system?

Pages in physical memory are not typically zero'ed out upon disuse. Yes, they're temporary... but only guaranteed temporary if you turn the system off and the DRAM cells bleed out their voltage.

replies(3): >>41913943 #>>41913945 #>>41915792 #
noirscape ◴[] No.41913945[source]
By default a tmpfs has a really low RAM priority so the OS will try to move it in swapspace if memory gets low. tmpfs size is specified on creation of the tmpfs (and cant be larger than the total memory available, which is swap + RAM) but it's only "occupied" when files begin to fill the tmpfs.

If it gets too full for regular OS operations, you get the fun of the OOM Killer shutting down services (tmpfs is never targeted by the OOM Killer) until the entire OS just deadlocks if you somehow manage to fill the tmpfs up entirely.

replies(1): >>41913983 #
nullindividual ◴[] No.41913983{3}[source]
> OS will try to move it in swapspace if memory gets low

That defeats the idea GP presented.

replies(2): >>41914042 #>>41914260 #
noirscape ◴[] No.41914042{4}[source]
That depends on how you view swapspace; on most devices, swapspace is either created as a separate partition on the disk or as a file living somewhere on the filesystem.

For practical reasons, swapspace isn't really the same thing as keeping it in an actual storage folder - the OS treats swapspace as essentially being empty data on each reboot. (You'd probably be able to extract data from swapspace with disk recovery tools though.)

On a literal level it's not the same as "keep it in RAM", but practically speaking swapspace is treated as a seamless (but slower) extension of installed RAM.

replies(1): >>41914155 #
1. nullindividual ◴[] No.41914155{5}[source]
> On a literal level it's not the same as "keep it in RAM"

I read the GP as 'literal level' in-RAM. If I interpreted that incorrectly, apologies to GP.

replies(1): >>41915723 #
2. marcosdumay ◴[] No.41915723[source]
It may or may not be what the OP was talking about, depending on your threat model.