Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932074AbeAKFcJ (ORCPT + 1 other); Thu, 11 Jan 2018 00:32:09 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:34160 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753515AbeAKFbC (ORCPT ); Thu, 11 Jan 2018 00:31:02 -0500 X-Google-Smtp-Source: ACJfBotx+/uJPWu8NEMX3hCC2NvoHTup6BedCWw6oSpr3AE3pquRIUzkp+JGVqUpqceBw7qVvTSqXw== From: Eric Biggers To: linux-fsdevel@vger.kernel.org Cc: Alexander Viro , Joe Lawrence , Michael Kerrisk , Willy Tarreau , Mikulas Patocka , "Luis R . Rodriguez" , Kees Cook , linux-kernel@vger.kernel.org, Eric Biggers , stable@vger.kernel.org Subject: [PATCH v2 4/7] pipe: fix off-by-one error when checking buffer limits Date: Wed, 10 Jan 2018 21:28:59 -0800 Message-Id: <20180111052902.14409-5-ebiggers3@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180111052902.14409-1-ebiggers3@gmail.com> References: <20180111052902.14409-1-ebiggers3@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: From: Eric Biggers With pipe-user-pages-hard set to 'N', users were actually only allowed up to 'N - 1' buffers; and likewise for pipe-user-pages-soft. Fix this to allow up to 'N' buffers, as would be expected. Fixes: b0b91d18e2e9 ("pipe: fix limit checking in pipe_set_size()") Cc: stable@vger.kernel.org Acked-by: Willy Tarreau Signed-off-by: Eric Biggers --- fs/pipe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/pipe.c b/fs/pipe.c index 847ecc388820..9f20e7128578 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -605,12 +605,12 @@ static unsigned long account_pipe_buffers(struct user_struct *user, static bool too_many_pipe_buffers_soft(unsigned long user_bufs) { - return pipe_user_pages_soft && user_bufs >= pipe_user_pages_soft; + return pipe_user_pages_soft && user_bufs > pipe_user_pages_soft; } static bool too_many_pipe_buffers_hard(unsigned long user_bufs) { - return pipe_user_pages_hard && user_bufs >= pipe_user_pages_hard; + return pipe_user_pages_hard && user_bufs > pipe_user_pages_hard; } static bool is_unprivileged_user(void) -- 2.15.1