]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.82/pipe-fix-off-by-one-error-when-checking-buffer-limits.patch
drop queue-4.19/drm-amdgpu-soc15-skip-reset-on-init.patch
[thirdparty/kernel/stable-queue.git] / releases / 4.9.82 / pipe-fix-off-by-one-error-when-checking-buffer-limits.patch
CommitLineData
aa372fad
GKH
1From 9903a91c763ecdae333a04a9d89d79d2b8966503 Mon Sep 17 00:00:00 2001
2From: Eric Biggers <ebiggers@google.com>
3Date: Tue, 6 Feb 2018 15:41:56 -0800
4Subject: pipe: fix off-by-one error when checking buffer limits
5
6From: Eric Biggers <ebiggers@google.com>
7
8commit 9903a91c763ecdae333a04a9d89d79d2b8966503 upstream.
9
10With pipe-user-pages-hard set to 'N', users were actually only allowed up
11to 'N - 1' buffers; and likewise for pipe-user-pages-soft.
12
13Fix this to allow up to 'N' buffers, as would be expected.
14
15Link: http://lkml.kernel.org/r/20180111052902.14409-5-ebiggers3@gmail.com
16Fixes: b0b91d18e2e9 ("pipe: fix limit checking in pipe_set_size()")
17Signed-off-by: Eric Biggers <ebiggers@google.com>
18Acked-by: Willy Tarreau <w@1wt.eu>
19Acked-by: Kees Cook <keescook@chromium.org>
20Acked-by: Joe Lawrence <joe.lawrence@redhat.com>
21Cc: Alexander Viro <viro@zeniv.linux.org.uk>
22Cc: "Luis R . Rodriguez" <mcgrof@kernel.org>
23Cc: Michael Kerrisk <mtk.manpages@gmail.com>
24Cc: Mikulas Patocka <mpatocka@redhat.com>
25Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
26Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
27Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
28
29---
30 fs/pipe.c | 4 ++--
31 1 file changed, 2 insertions(+), 2 deletions(-)
32
33--- a/fs/pipe.c
34+++ b/fs/pipe.c
35@@ -609,12 +609,12 @@ static unsigned long account_pipe_buffer
36
37 static bool too_many_pipe_buffers_soft(unsigned long user_bufs)
38 {
39- return pipe_user_pages_soft && user_bufs >= pipe_user_pages_soft;
40+ return pipe_user_pages_soft && user_bufs > pipe_user_pages_soft;
41 }
42
43 static bool too_many_pipe_buffers_hard(unsigned long user_bufs)
44 {
45- return pipe_user_pages_hard && user_bufs >= pipe_user_pages_hard;
46+ return pipe_user_pages_hard && user_bufs > pipe_user_pages_hard;
47 }
48
49 static bool is_unprivileged_user(void)