From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751434AbbEGXx6 (ORCPT ); Thu, 7 May 2015 19:53:58 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46402 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751023AbbEGXx5 (ORCPT ); Thu, 7 May 2015 19:53:57 -0400 Date: Thu, 7 May 2015 16:53:56 -0700 From: Andrew Morton To: "Reese Faucette" Cc: , Subject: Re: [PATCH] overflow check calculation in mm/mmap.c is incorrect linux-3.12.38 Message-Id: <20150507165356.6efa045e5e1179ef4f46fdb9@linux-foundation.org> In-Reply-To: <007301d08304$85881420$90983c60$@gmail.com> References: <007301d08304$85881420$90983c60$@gmail.com> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 29 Apr 2015 22:14:19 -0700 "Reese Faucette" wrote: > When checking for overflow, the code in mm/mmap.c compares the first byte > *after* the end of mapped region to the start of the region instead of the > last byte of the mapped region. This prevents mapping a region which abuts > the end of physical space, as mmap() incorrectly rejects the region with > -EOVERFLOW, because pgoff + (len >> PAGE_SHIFT) will be 0, which is < pgoff. > -reese > > Reese Faucette > Cisco Systems, Inc. > > ==================================================== > --- mm/mmap.c > +++ mm/mmap.c > @@ -1241,7 +1241,7 @@ > return -ENOMEM; > > /* offset overflow? */ > - if ((pgoff + (len >> PAGE_SHIFT)) < pgoff) > + if ((pgoff + (len >> PAGE_SHIFT) - 1) < pgoff) > return -EOVERFLOW; > > /* Too many mappings? */ Looks right. Please send a Signed-off-by: for this patch, as per Documentation/SubmittingPatches, section 11. Please also let me know whether the authorship should be you@gmail.com or some Cisco address, as people often prefer.