]>
Commit | Line | Data |
---|---|---|
aa372fad GKH |
1 | From 9903a91c763ecdae333a04a9d89d79d2b8966503 Mon Sep 17 00:00:00 2001 |
2 | From: Eric Biggers <ebiggers@google.com> | |
3 | Date: Tue, 6 Feb 2018 15:41:56 -0800 | |
4 | Subject: pipe: fix off-by-one error when checking buffer limits | |
5 | ||
6 | From: Eric Biggers <ebiggers@google.com> | |
7 | ||
8 | commit 9903a91c763ecdae333a04a9d89d79d2b8966503 upstream. | |
9 | ||
10 | With pipe-user-pages-hard set to 'N', users were actually only allowed up | |
11 | to 'N - 1' buffers; and likewise for pipe-user-pages-soft. | |
12 | ||
13 | Fix this to allow up to 'N' buffers, as would be expected. | |
14 | ||
15 | Link: http://lkml.kernel.org/r/20180111052902.14409-5-ebiggers3@gmail.com | |
16 | Fixes: b0b91d18e2e9 ("pipe: fix limit checking in pipe_set_size()") | |
17 | Signed-off-by: Eric Biggers <ebiggers@google.com> | |
18 | Acked-by: Willy Tarreau <w@1wt.eu> | |
19 | Acked-by: Kees Cook <keescook@chromium.org> | |
20 | Acked-by: Joe Lawrence <joe.lawrence@redhat.com> | |
21 | Cc: Alexander Viro <viro@zeniv.linux.org.uk> | |
22 | Cc: "Luis R . Rodriguez" <mcgrof@kernel.org> | |
23 | Cc: Michael Kerrisk <mtk.manpages@gmail.com> | |
24 | Cc: Mikulas Patocka <mpatocka@redhat.com> | |
25 | Signed-off-by: Andrew Morton <akpm@linux-foundation.org> | |
26 | Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> | |
27 | Signed-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) |