From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S261206AbVALQDz (ORCPT ); Wed, 12 Jan 2005 11:03:55 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S261229AbVALQDz (ORCPT ); Wed, 12 Jan 2005 11:03:55 -0500 Received: from fw.osdl.org ([65.172.181.6]:30381 "EHLO mail.osdl.org") by vger.kernel.org with ESMTP id S261206AbVALQDt (ORCPT ); Wed, 12 Jan 2005 11:03:49 -0500 Date: Wed, 12 Jan 2005 08:03:44 -0800 (PST) From: Linus Torvalds To: Marcelo Tosatti cc: Alan Cox , Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH] do_brk() needs mmap_sem write-locked In-Reply-To: <20050112002117.GA27653@logos.cnet> Message-ID: References: <20050112002117.GA27653@logos.cnet> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Looks good, except for a small nit: On Tue, 11 Jan 2005, Marcelo Tosatti wrote: > diff -Nur linux-2.6-curr.orig/mm/mmap.c linux-2.6-curr/mm/mmap.c > --- linux-2.6-curr.orig/mm/mmap.c 2005-01-11 22:48:49.000000000 -0200 > +++ linux-2.6-curr/mm/mmap.c 2005-01-11 23:43:10.704800272 -0200 > @@ -1891,6 +1891,12 @@ > } > > /* > + * mm->mmap_sem is required to protect against another thread > + * changing the mappings in case we sleep. > + */ > + WARN_ON(down_read_trylock(&mm->mmap_sem)); > + > + /* > * Clear old maps. this also does some error checking for us > */ > munmap_back: > if that warning ever triggers, mmap_sem will now be locked, and that will cause problems. So I suspect it's better to do if (down_read_trylock(&mm->mmap_sem)) { WARN_ON(1); up_read(&mm->mmap_sem); } and move that into a helper function of its own (something like "verify_mmap_write_lock_held()"). Linus