Received: by 10.223.185.116 with SMTP id b49csp187356wrg; Thu, 15 Feb 2018 19:34:01 -0800 (PST) X-Google-Smtp-Source: AH8x226SC2yPQv7kCcxYg7FQcRAHIEVcEvR0NeeVnthfo79QYh/zluMkaLHOdvDrejZBtAWfKFTe X-Received: by 10.98.46.70 with SMTP id u67mr4712928pfu.16.1518752041394; Thu, 15 Feb 2018 19:34:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518752041; cv=none; d=google.com; s=arc-20160816; b=ePvPIXGhYBrNWn6SQqes8XnL6KiL9/w9rlr1Mux5j0W4oyejZ4pUaTzMvR646JizWW ZE3l/iGL+TGaKR///VHXgp44lRn2LF7fPUbDSLMtAO/bGTCyNyWuirhIKvRf5woraOK2 pRtTnqeNo4jnMZeBSTkoTH3WIxrAiJqhMJKt4cOGJHSBLK/Wn46vZ3qtAd1nZVhtHDqO O/b8rij8Amlarr7BJnFJNm0ffM8n5f2XW02qatBpuROebynB8iRTzqE7rIxs02c6adZg PIpCmKFWCyOtgm/ojeUINp+P9e07RJAUMoNxJAk4zaspNSW7Z/YfvgVBqNwa/cNNwR8D DETQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=VV8yCdFHA/XpPqGSnY1pmS8WQw7dPf2+06rUoakpwFk=; b=HYGBOZpWxMMCE5aDcjx01oILii4vM8PsGJBmtCJBNRaniXUWk8QfVdZ2quiVyMjULH EDGImK3HJwX70BQlzKegGSCluB7lu/xEBwylx6XkT6382FFOYohUhU0GqNKxTdpUaj1Q cNVgwITh4htNw2rkqZOPq3wKfoMwf5Tez+4H1MkI9z0doIgm4SAKbiwsEQhy75MwCoZC B76dqWihZCHXbu08cMgF6NZj4ygWvITgd6/8FCmRtHTLLtiq1aOXhhe//xG7+PFC0qck gr8R1cq85x4xuC/KfQz0bJQQ7y+3lZJCBRkCMEjfBLN0xKdAAMUG22SiLiCZHGDhKwqU yCUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a19si2170168pfh.122.2018.02.15.19.33.46; Thu, 15 Feb 2018 19:34:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1424600AbeBOPqE (ORCPT + 99 others); Thu, 15 Feb 2018 10:46:04 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:35212 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424588AbeBOPqB (ORCPT ); Thu, 15 Feb 2018 10:46:01 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 0837511D7; Thu, 15 Feb 2018 15:46:01 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Biggers , Willy Tarreau , Kees Cook , Joe Lawrence , Alexander Viro , "Luis R . Rodriguez" , Michael Kerrisk , Mikulas Patocka , Andrew Morton , Linus Torvalds Subject: [PATCH 4.15 160/202] pipe: fix off-by-one error when checking buffer limits Date: Thu, 15 Feb 2018 16:17:40 +0100 Message-Id: <20180215151721.258637616@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151712.768794354@linuxfoundation.org> References: <20180215151712.768794354@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Biggers commit 9903a91c763ecdae333a04a9d89d79d2b8966503 upstream. 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. Link: http://lkml.kernel.org/r/20180111052902.14409-5-ebiggers3@gmail.com Fixes: b0b91d18e2e9 ("pipe: fix limit checking in pipe_set_size()") Signed-off-by: Eric Biggers Acked-by: Willy Tarreau Acked-by: Kees Cook Acked-by: Joe Lawrence Cc: Alexander Viro Cc: "Luis R . Rodriguez" Cc: Michael Kerrisk Cc: Mikulas Patocka Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- fs/pipe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/fs/pipe.c +++ b/fs/pipe.c @@ -610,12 +610,12 @@ static unsigned long account_pipe_buffer 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)