tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

ulimits and memfd(2)



Is there any mechanism that limits the memory usage of processes via
memfd(2)?

Without memfd(2), there are ulimits -- you can use RLIMIT_AS to limit
the address space size, and the number of file descriptors a process
can create to store data in pipe buffers is limited, and the amount of
data that can be stored in files is limited by file system sizes (on
tmpfs, with `-o -s1G', for instance).

But with memfd(2) it looks like, despite these limits, a process can
write arbitrarily much data into it, and have random access to read
any of it back later in small chunks with pread(2).

The process could voluntarily prevent the memfd from increasing with
F_SEAL_WRITE, but that can't be imposed from the outside, if I
understand correctly.

So is there a way to limit the memory use of memfd?  Maybe the memfd
should contribute toward RLIMIT_AS somehow, or something like that?


Home | Main Index | Thread Index | Old Index