getrlimit.2, mmap.2, malloc.3: RLIMIT_DATA affects mmap (2) since Linux 4.7

Starting with Linux kernel 4.5 and 84638335900f1995
(mm: rework virtual memory accounting) RLIMIT_DATA affects
mmap(2).  With d977d56ce5b3e88 (mm: warn about VmData over
RLIMIT_DATA) only warnings are emmitted when going over the
specified RLIMIT_DATA in 4.5.

As of 4.7 and f4fcd55841fc9 (mm: enable RLIMIT_DATA by default
with workaround for valgrind) going over RLIMIT_DATA through
mmap(2) is forbidden.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Jonas Grabber 2017-09-14 17:47:12 +02:00 committed by Michael Kerrisk
parent d341ed5693
commit c87d084b87
3 changed files with 16 additions and 3 deletions

View File

@ -182,9 +182,14 @@ of the process's data segment (initialized data,
uninitialized data, and heap).
The limit is specified in bytes, and is rounded down to the system page size.
This limit affects calls to
.BR brk (2)
and
.BR brk (2),
.BR sbrk (2),
and as of Linux 4.7 also
.BR mmap (2),
.\" commits 84638335900f1995495838fe1bd4870c43ec1f67
.\" ("mm: rework virtual memory accounting"),
.\" f4fcd55841fc9e46daac553b39361572453c2b88
.\" (mm: enable RLIMIT_DATA by default with workaround for valgrind).
which fail with the error
.B ENOMEM
upon encountering the soft limit of this resource.

View File

@ -493,6 +493,14 @@ when unmapping a region in the middle of an existing mapping,
since this results in two smaller mappings on either side of
the region being unmapped.
.TP
.B ENOMEM
(since Linux 4.7)
The process's
.B RLIMIT_DATA
limit, described in
.BR getrlimit (2),
would have been exceeded.
.TP
.B EOVERFLOW
On 32-bit architecture together with the large file extension
(i.e., using 64-bit

View File

@ -292,7 +292,7 @@ Allocations performed using
.BR mmap (2)
are unaffected by the
.B RLIMIT_DATA
resource limit (see
resource limit only prior to Linux kernel 4.7 (see
.BR getrlimit (2)).
.PP
To avoid corruption in multithreaded applications,