summaryrefslogtreecommitdiff
path: root/fs/pipe.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@google.com>2021-08-15 13:06:25 +0200
committerGreg Kroah-Hartman <gregkh@google.com>2021-08-15 13:06:25 +0200
commit77e0acef0c1ee450a6925c70473cb64381c800f0 (patch)
treec54d05321b64ee6150ae3297ea5b185ee526e323 /fs/pipe.c
parentc5c38d81d47414adc49be96b02987da14f755a6a (diff)
parentc13f051b7fc041d3163a96b10441b421ddecd123 (diff)
Merge 4.4.281 into android-4.4-p
Changes in 4.4.281 ALSA: seq: Fix racy deletion of subscriber scsi: sr: Return correct event when media event code is 3 media: videobuf2-core: dequeue if start_streaming fails net: natsemi: Fix missing pci_disable_device() in probe and remove mips: Fix non-POSIX regexp bnx2x: fix an error code in bnx2x_nic_load() net: pegasus: fix uninit-value in get_interrupt_interval net: vxge: fix use-after-free in vxge_device_unregister Bluetooth: defer cleanup of resources in hci_unregister_dev() USB: serial: option: add Telit FD980 composition 0x1056 USB: serial: ch341: fix character loss at high transfer rates USB: serial: ftdi_sio: add device ID for Auto-M3 OP-COM v2 scripts/tracing: fix the bug that can't parse raw_trace_func media: rtl28xxu: fix zero-length control request serial: 8250: Mask out floating 16/32-bit bus bits MIPS: Malta: Do not byte-swap accesses to the CBUS UART pcmcia: i82092: fix a null pointer dereference bug reiserfs: add check for root_inode in reiserfs_fill_super reiserfs: check directory items on read from disk alpha: Send stop IPI to send to online CPUs net/qla3xxx: fix schedule while atomic in ql_wait_for_drvr_lock and ql_adapter_reset pipe: increase minimum default pipe size to 2 pages USB:ehci:fix Kunpeng920 ehci hardware problem net: xilinx_emaclite: Do not print real IOMEM pointer ovl: prevent private clone if bind mount is not allowed Linux 4.4.281 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I23014eec5c0648b030387cc4469a1cdfaa2c14a1
Diffstat (limited to 'fs/pipe.c')
-rw-r--r--fs/pipe.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/fs/pipe.c b/fs/pipe.c
index 6534470a6c19..37a003b645ef 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -28,6 +28,21 @@
#include "internal.h"
/*
+ * New pipe buffers will be restricted to this size while the user is exceeding
+ * their pipe buffer quota. The general pipe use case needs at least two
+ * buffers: one for data yet to be read, and one for new data. If this is less
+ * than two, then a write to a non-empty pipe may block even if the pipe is not
+ * full. This can occur with GNU make jobserver or similar uses of pipes as
+ * semaphores: multiple processes may be waiting to write tokens back to the
+ * pipe before reading tokens: https://lore.kernel.org/lkml/1628086770.5rn8p04n6j.none@localhost/.
+ *
+ * Users can reduce their pipe buffers with F_SETPIPE_SZ below this at their
+ * own risk, namely: pipe writes to non-full pipes may block until the pipe is
+ * emptied.
+ */
+#define PIPE_MIN_DEF_BUFFERS 2
+
+/*
* The max size that a non-root user is allowed to grow the pipe. Can
* be set by root in /proc/sys/fs/pipe-max-size
*/
@@ -621,7 +636,7 @@ struct pipe_inode_info *alloc_pipe_info(void)
if (!too_many_pipe_buffers_hard(user)) {
if (too_many_pipe_buffers_soft(user))
- pipe_bufs = 1;
+ pipe_bufs = PIPE_MIN_DEF_BUFFERS;
pipe->bufs = kzalloc(sizeof(struct pipe_buffer) * pipe_bufs, GFP_KERNEL);
}