From patchwork Thu Jan 11 05:28:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10157125 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 76A62602B3 for ; Thu, 11 Jan 2018 05:32:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67CED286AB for ; Thu, 11 Jan 2018 05:32:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5CB83286B4; Thu, 11 Jan 2018 05:32:11 +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=ham 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 A2851286AB for ; Thu, 11 Jan 2018 05:32:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754110AbeAKFcI (ORCPT ); Thu, 11 Jan 2018 00:32:08 -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 Received: by mail-pf0-f194.google.com with SMTP id e76so682501pfk.1; Wed, 10 Jan 2018 21:31:01 -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=7KwaCVWiG7svW02LPYhJHSTDYW+HMDZvmoq78KoAyf4=; b=aTXuEWnffuqm1y7i8X97MHFUCt1NYPQdt9Pz6gBHtKMgF06mg0tZDGZHVQFWzmMaj6 Owhs1TC+KhPqa7kVMapjhjvWPUJYGEfNMGzhmyjEyKdvOBkSZ3gvSOv4E4VTQFHkc7D0 OUirlc+5vsKzEi6QkZaPKSiy6uSJveQ0nJmOe/QZ4qulUbkzb/doa16VVNb00DmMebXY veJlxIH3bg7WRKPxjuJQIrSH7ljSAIIuX7cGhKTs82m3Boy86q64RI1aO+CSXCXCgi5k WtqoJP5ahk5gpGqSSmdSsaQnpXk0xboa28Ppxuo+AYrlEPxb2Tpq1mkkxdhdgNeDJEE8 vmNA== 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=7KwaCVWiG7svW02LPYhJHSTDYW+HMDZvmoq78KoAyf4=; b=BcHRs38fs4fTAOV6nUv4B0dG04pPXd1CdKbXbsgZGXf6z6MttmPPDz9/+9Px+H/08s 7KxuL+MqD9urs5mAhTW2fc4LHB+HBTV5dNn1XXkj0BNUCGsxLdnjgXmfWaA9Cl6h9P1A dgceIJ4YwVkUHMKc1klCy7hIKOKYCTMk/dELXAEN0gENyCypaKaOYMjb/BvASAsvQiyW UGKXHyePmQTz0NRpgVgCH96BBG87V0TRjS5HYiMYktOwpPcgPIqIszOobtUVgqvmTidb BUbnPeiU2YzuObiWPjdsp/YMWHzDEw2yuTW6l0kJHy7Yhq2C5pNmS86FSgKrFPuwm22G Uhog== X-Gm-Message-State: AKGB3mKMkjAAsmCYilZJGchOeNFeSPcbdFvbWIj3b9AUOQpp0MLrw1mO HZ05MqKuGKbGqGcANNjh7PoD655FySo= X-Google-Smtp-Source: ACJfBotx+/uJPWu8NEMX3hCC2NvoHTup6BedCWw6oSpr3AE3pquRIUzkp+JGVqUpqceBw7qVvTSqXw== X-Received: by 10.84.252.134 with SMTP id y6mr21535931pll.338.1515648661113; Wed, 10 Jan 2018 21:31:01 -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 h63sm32276519pgc.71.2018.01.10.21.31.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Jan 2018 21:31:00 -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 , 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-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. 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)