Received: by 10.223.185.116 with SMTP id b49csp2286529wrg; Thu, 15 Feb 2018 09:16:40 -0800 (PST) X-Google-Smtp-Source: AH8x226G0GTSE78e0V0MJc68Gh8GHG9wAB8wgwPN2B4xk40f2ooIL4md9XLyR0i/1AuHk0kV1Ln1 X-Received: by 10.101.77.134 with SMTP id p6mr2728680pgq.230.1518715000414; Thu, 15 Feb 2018 09:16:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518715000; cv=none; d=google.com; s=arc-20160816; b=d0heCOwrH1+aABMetxTC8H2Oz5g/aYv6rD4GsR3wc1fnI5fqoI3YqF8vPz8W52JYPe 80Gcmh4+1XjuzG8xp6inEgXpTYl1IE0Q1wl4jeQ0+mnLKfHv85j4tXIp+6LBIpUERDKl 1AfHPnLqtjSFRhhgKM+qTz03okZC9xwvzHMGrghxqkbdhmqEIE4THR7VBni36/fQUCy0 tWF5ws1Hj0MdTEReY3CE4hwk4boaVAR05iidITMIQBbrjwJo+Pl+w4RodhY/9Wa9fP6p Vap5BMdqL7wOxypvOeTY6nv2FT/lEWTz4lhT5PdHrFr5c2WWPRTZfG+kXTOIR2UkwHUa rfcw== 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=vGD6cKEx6DsH9kxWs3ryGeEHhanbgZoCNcwveZgqq8M=; b=wdJJ78t3qEHAhGUBd3tOoABvR2z2poZBvqCu0fy3QVlGfmMlSnafae41ZXXliR/Nkd rof0NYPoQN1ccPjJShGe4c32Wo1c+2UDlAMD+OgiYAc5aB9KZfVm1c0cQTch8WYpq/1T SyWRYyf8J43404lXho+CQjM+oKZzLvbMZetx+yVU3oqMC9SALIxZwLcGCYHbOoE9Qr4W a9d6lPXvG1B9uELc8lEqdWd+SZQAt2azjrcmr/H8a+FalNwNvbMCkW8DDeIupNTNhWqR mnyY0PhM0z93bgnBxeWyt9KO8QnlBaRaNbG/VuUVgdQUVq/FXJHyQ1HujclC743Nupd0 JCuA== 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 k67si2886290pgk.246.2018.02.15.09.16.24; Thu, 15 Feb 2018 09:16:40 -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 S1427109AbeBORP0 (ORCPT + 99 others); Thu, 15 Feb 2018 12:15:26 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:58722 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422945AbeBOPgn (ORCPT ); Thu, 15 Feb 2018 10:36:43 -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 DF4DFFE4; Thu, 15 Feb 2018 15:36:42 +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.14 156/195] pipe: fix off-by-one error when checking buffer limits Date: Thu, 15 Feb 2018 16:17:27 +0100 Message-Id: <20180215151713.710184015@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151705.738773577@linuxfoundation.org> References: <20180215151705.738773577@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.14-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)