From patchwork Tue May 10 00:44:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 772472 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4A0ik4M007180 for ; Tue, 10 May 2011 00:44:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755845Ab1EJAoo (ORCPT ); Mon, 9 May 2011 20:44:44 -0400 Received: from smtp-out.google.com ([216.239.44.51]:60202 "EHLO smtp-out.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753556Ab1EJAon (ORCPT ); Mon, 9 May 2011 20:44:43 -0400 Received: from hpaq12.eem.corp.google.com (hpaq12.eem.corp.google.com [172.25.149.12]) by smtp-out.google.com with ESMTP id p4A0igKE013562 for ; Mon, 9 May 2011 17:44:42 -0700 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1304988282; bh=BZWQEntjKqAPUhgZPxiZBclG9Ik=; h=Date:From:To:cc:Subject:Message-ID:MIME-Version:Content-Type; b=uAqu2k1zcpzdh89dG8xa7ZektiX4DhpLckptroRvide4VZ5FUTZFrtGU8R8tY4YwP ORSrQXD2OBl2j17hA6LUQ== Received: from pxi10 (pxi10.prod.google.com [10.243.27.10]) by hpaq12.eem.corp.google.com with ESMTP id p4A0iAY1019673 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Mon, 9 May 2011 17:44:40 -0700 Received: by pxi10 with SMTP id 10so4298027pxi.36 for ; Mon, 09 May 2011 17:44:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=beta; h=domainkey-signature:date:from:x-x-sender:to:cc:subject:message-id :user-agent:mime-version:content-type; bh=iKlOCZKLw3X4c8IRLjz23vrIbm6vgitqxO7UQsbyTV8=; b=KnoIXhl6E6QQQSesmbWS31B/Yl6tii4vnh022Fa+T2XKyJh5RcjwjsI6B7/6rfq/UX UlFnKveQzrP7vFoVdslQ== DomainKey-Signature: a=rsa-sha1; c=nofws; d=google.com; s=beta; h=date:from:x-x-sender:to:cc:subject:message-id:user-agent :mime-version:content-type; b=lkE6LVL3T6y1W/4BZZjn+ARqdowlmBgJ+ungutTEXnUlBskgmD4audE4NmFOxStLVV B/QZ89QFSy4LFeulntFQ== Received: by 10.68.27.170 with SMTP id u10mr10984168pbg.529.1304988280060; Mon, 09 May 2011 17:44:40 -0700 (PDT) Received: from [192.168.14.71] ([216.239.45.19]) by mx.google.com with ESMTPS id g5sm4437132pbj.62.2011.05.09.17.44.38 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 09 May 2011 17:44:39 -0700 (PDT) Date: Mon, 9 May 2011 17:44:42 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@sister.anvils To: Linus Torvalds cc: Robert Swiecki , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-parisc@vger.kernel.org, linux-ia64@vger.kernel.org Subject: [PATCH] vm: fix vm_pgoff wrap in upward expansion Message-ID: User-Agent: Alpine 2.00 (LSU 1167 2008-08-23) MIME-Version: 1.0 X-System-Of-Record: true Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 10 May 2011 00:44:47 +0000 (UTC) Commit a626ca6a6564 ("vm: fix vm_pgoff wrap in stack expansion") fixed the case of an expanding mapping causing vm_pgoff wrapping when you had downward stack expansion. But there was another case where IA64 and PA-RISC expand mappings: upward expansion. This fixes that case too. Signed-off-by: Hugh Dickins Cc: stable@kernel.org --- On April 12th you asked "Guys, can you think of any other thing that might expand a mapping?": this is the only one I thought of. mm/mmap.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-parisc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 2.6.39-rc6/mm/mmap.c 2011-05-04 12:10:31.477543104 -0700 +++ linux/mm/mmap.c 2011-05-09 17:16:34.251725877 -0700 @@ -1767,10 +1767,13 @@ int expand_upwards(struct vm_area_struct size = address - vma->vm_start; grow = (address - vma->vm_end) >> PAGE_SHIFT; - error = acct_stack_growth(vma, size, grow); - if (!error) { - vma->vm_end = address; - perf_event_mmap(vma); + error = -ENOMEM; + if (vma->vm_pgoff + (size >> PAGE_SHIFT) >= vma->vm_pgoff) { + error = acct_stack_growth(vma, size, grow); + if (!error) { + vma->vm_end = address; + perf_event_mmap(vma); + } } } vma_unlock_anon_vma(vma);