From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f68.google.com ([74.125.83.68]:41932 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754033AbeAJCwF (ORCPT ); Tue, 9 Jan 2018 21:52:05 -0500 Date: Tue, 9 Jan 2018 18:52:01 -0800 From: Eric Biggers To: Kees Cook Cc: "linux-fsdevel@vger.kernel.org" , Alexander Viro , Joe Lawrence , Michael Kerrisk , Willy Tarreau , Mikulas Patocka , "Luis R . Rodriguez" , LKML , Eric Biggers Subject: Re: [PATCH 6/7] pipe: simplify round_pipe_size() Message-ID: <20180110025201.GC931@zzz.localdomain> References: <20180108053542.6472-1-ebiggers3@gmail.com> <20180108053542.6472-7-ebiggers3@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Tue, Jan 09, 2018 at 02:27:10PM -0800, Kees Cook wrote: > > > @@ -1054,9 +1048,6 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long arg) > > return -EINVAL; > > nr_pages = size >> PAGE_SHIFT; > > > > - if (!nr_pages) > > - return -EINVAL; > > - > > I would just leave this hunk anyway: it's defensive for any future > changes. Maybe add a comment describing why it's currently redundant? > I don't know; I find it really confusing to have two slightly different checks for the same thing, as it implies that they actually need to be there for a reason. How about just checking nr_pages? size = round_pipe_size(arg); nr_pages = size >> PAGE_SHIFT; if (nr_pages == 0) return -EINVAL; Eric