From patchwork Mon Jan 8 05:35:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10149039 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4CB16601BE for ; Mon, 8 Jan 2018 05:39:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 414B6287A6 for ; Mon, 8 Jan 2018 05:39:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 360D8287BE; Mon, 8 Jan 2018 05:39:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF907287A6 for ; Mon, 8 Jan 2018 05:39:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755584AbeAHFi7 (ORCPT ); Mon, 8 Jan 2018 00:38:59 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:40539 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755521AbeAHFiy (ORCPT ); Mon, 8 Jan 2018 00:38:54 -0500 Received: by mail-pg0-f66.google.com with SMTP id q12so4880544pgt.7; Sun, 07 Jan 2018 21:38:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rAyoKm5zBAgD+aK+FzdV+fqlfCF5L+RvTu9zoWyiNZk=; b=ll5JNLJJeaw55EclaB4fnTHa4t7Thozw852EdzJ92X4yBsxVkFm2zi4YPEGvTU3UEn hND1WoWaR4TNE32reWFa82uIOeIpWuHaSGKxyDi3cv/l74uqnbItAFcP1IOmdmg209jQ Kkmvj6PQvClHzwlVYYsmakMp3wU6diFUd8tOwIxFMT6bhRIkMWInTBEbvKFpYEUojXcQ GxiT2CTGLxyhN6/IWCvzE70nS2AxqWOBpcQT0IpdtT4XSS+NbjtGnPJS0F82MGxOMZfh COoC2QvYQsKyOR2m5ElAvR9kOxtTf5KFVLiGh5CtPsTgQZeIp3oG3mBb6HuFfZ96FIb8 Pezg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rAyoKm5zBAgD+aK+FzdV+fqlfCF5L+RvTu9zoWyiNZk=; b=Flc7ljpflCeKBBPhyr357mrn/dBty7/mQdOFUjmAoDTs4Y05llLAGnQMoVwJkY9ijg iuG6e5fdRjjuKRbOQqe/2CJN9zF9xAGVr9X3TTbl42gRMGSJ2+LGycCaaAPKS2ldxQeU LMaA6r7nZzeYvzsiMkAi/bbmCg5sSAC3qmCYUojZWkwWJhkC60Ih6bYamUTX/9BegSGr rFlmIKZzyD+GlnPmdbju7Oim0bfKZIHcXP5A69WV+g/sxjrQF7GkoM4aKzhadhbXFu9n XVrne7tFdwrALWMwc/ZiWSQesn7vo7Tm+0sJhkgxOprq9rS8VjuUA7bZ6S4w1/4yMLb7 6rMw== X-Gm-Message-State: AKGB3mJC2ZhY5NCI4+EQ96s/kDxGZWy8E4UKxX/RUbO+SU9geWJyAost iL+xqq4/TA8Bc+HrkCMlKxvEUr0R X-Google-Smtp-Source: ACJfBov1xIqGLwLHFGg5s5vv2paVagFneSaG3F534CPRw0fVVHO5nC/nD0D0pwyLzskaFdob4+4/fg== X-Received: by 10.101.66.12 with SMTP id c12mr8914767pgq.105.1515389933536; Sun, 07 Jan 2018 21:38:53 -0800 (PST) Received: from zzz.localdomain (c-67-185-97-198.hsd1.wa.comcast.net. [67.185.97.198]) by smtp.gmail.com with ESMTPSA id w84sm26611743pfk.16.2018.01.07.21.38.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Jan 2018 21:38:53 -0800 (PST) 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 Subject: [PATCH 4/7] pipe: fix off-by-one error when checking buffer limits Date: Sun, 7 Jan 2018 21:35:39 -0800 Message-Id: <20180108053542.6472-5-ebiggers3@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180108053542.6472-1-ebiggers3@gmail.com> References: <20180108053542.6472-1-ebiggers3@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Eric Biggers Acked-by: Willy Tarreau --- 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)