From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753517AbcHUVPo (ORCPT ); Sun, 21 Aug 2016 17:15:44 -0400 Received: from mail-pa0-f66.google.com ([209.85.220.66]:33709 "EHLO mail-pa0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753371AbcHUVPm (ORCPT ); Sun, 21 Aug 2016 17:15:42 -0400 Subject: Re: [PATCH 4/8] pipe: fix limit checking in pipe_set_size() To: Willy Tarreau References: <67ce15aa-cf43-0c89-d079-2d966177c56d@gmail.com> <7f0732a9-6172-e92d-7c5b-473b769fe37e@gmail.com> <20160819054818.GH17944@1wt.eu> Cc: mtk.manpages@gmail.com, Andrew Morton , Vegard Nossum , socketpair@gmail.com, Tetsuo Handa , Jens Axboe , Al Viro , linux-api@vger.kernel.org, linux-kernel@vger.kernel.org From: "Michael Kerrisk (man-pages)" Message-ID: <60022222-ced6-85d4-77bb-bf8bf8ce668b@gmail.com> Date: Mon, 22 Aug 2016 09:15:35 +1200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20160819054818.GH17944@1wt.eu> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Willy, Might you have a chance to further review of this patch series? It would be great if you could, since much of it touches changes made by you earlier. Thanks, Michael On 08/19/2016 05:48 PM, Willy Tarreau wrote: > Hi Michael, > > Since you're changing this code, it's probably worth swapping the size > check and capable() below to save a function call in the normal path : > > On Fri, Aug 19, 2016 at 05:25:35PM +1200, Michael Kerrisk (man-pages) wrote: >> + if (nr_pages > pipe->buffers) { >> + if (!capable(CAP_SYS_RESOURCE) && size > pipe_max_size) { > > => if (size > pipe_max_size && !capable(CAP_SYS_RESOURCE)) { > >> + ret = -EPERM; >> + goto out_revert_acct; >> + } else if ((too_many_pipe_buffers_hard(pipe->user) || >> + too_many_pipe_buffers_soft(pipe->user)) && >> + !capable(CAP_SYS_RESOURCE) && >> + !capable(CAP_SYS_ADMIN)) { >> + ret = -EPERM; >> + goto out_revert_acct; >> + } >> + } > (...) > > Cheers, > Willy > -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/