remarkable-linux/include
Willy Tarreau 2612a949cf pipe: limit the per-user amount of pages allocated in pipes
[ Upstream commit 759c01142a ]

On no-so-small systems, it is possible for a single process to cause an
OOM condition by filling large pipes with data that are never read. A
typical process filling 4000 pipes with 1 MB of data will use 4 GB of
memory. On small systems it may be tricky to set the pipe max size to
prevent this from happening.

This patch makes it possible to enforce a per-user soft limit above
which new pipes will be limited to a single page, effectively limiting
them to 4 kB each, as well as a hard limit above which no new pipes may
be created for this user. This has the effect of protecting the system
against memory abuse without hurting other users, and still allowing
pipes to work correctly though with less data at once.

The limit are controlled by two new sysctls : pipe-user-pages-soft, and
pipe-user-pages-hard. Both may be disabled by setting them to zero. The
default soft limit allows the default number of FDs per process (1024)
to create pipes of the default size (64kB), thus reaching a limit of 64MB
before starting to create only smaller pipes. With 256 processes limited
to 1024 FDs each, this results in 1024*64kB + (256*1024 - 1024) * 4kB =
1084 MB of memory allocated for a user. The hard limit is disabled by
default to avoid breaking existing applications that make intensive use
of pipes (eg: for splicing).

Reported-by: socketpair@gmail.com
Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Mitigates: CVE-2013-4312 (Linux 2.0+)
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
2016-07-10 23:07:27 -04:00
..
acpi ACPICA: Tables: Enable default 64-bit FADT addresses favor 2015-08-03 09:29:14 -07:00
asm-generic SIGNAL: Move generic copy_siginfo() to signal.h 2016-06-06 19:12:20 -04:00
clocksource
crypto crypto: af_alg - Allow af_af_alg_release_parent to be called on nokey path 2016-02-03 16:23:19 -05:00
drm drm: Loongson-3 doesn't fully support wc memory 2016-05-10 12:17:32 -04:00
dt-bindings Merge branch 'for-linus' of git://git.infradead.org/users/vkoul/slave-dma 2015-04-24 09:49:37 -07:00
keys
kvm KVM/ARM changes for v4.1: 2015-04-07 18:09:20 +02:00
linux pipe: limit the per-user amount of pages allocated in pipes 2016-07-10 23:07:27 -04:00
math-emu
media Merge branch 'patchwork' into v4l_for_linus 2015-04-21 06:12:35 -03:00
memory
misc
net net_sched: update hierarchical backlog too 2016-07-10 23:07:23 -04:00
pcmcia
ras
rdma IB/security: Restrict use of the write() interface 2016-05-17 13:42:48 -04:00
rxrpc
scsi Revert "libata-eh: Set 'information' field for autosense" 2015-09-13 09:07:46 -07:00
soc iommu/tegra-smmu: Parameterize number of TLB lines 2015-09-29 19:26:14 +02:00
sound ALSA: hda - Fix possible race on regmap bypass flip 2016-07-10 20:19:59 -04:00
target target: Fix remote-port TMR ABORT + se_cmd fabric stop 2016-03-05 22:11:42 -05:00
trace net: sunrpc: fix tracepoint Warning: unknown op '->' 2015-09-29 19:26:10 +02:00
uapi [media] v4l2-dv-timings.h: fix polarity for 4k formats 2016-05-17 13:42:40 -04:00
video fbdev changes for v4.1 2015-04-20 15:16:25 -07:00
xen x86/xen: Support kexec/kdump in HVM guests by doing a soft reset 2015-10-22 14:43:14 -07:00
Kbuild