From: Andrew Morton Subject: Re: fs/locks.c: Fix sys_flock() race Date: Wed, 29 Mar 2006 16:41:25 -0800 Message-ID: <20060329164125.04c66c6b.akpm@osdl.org> References: <1143651308.8697.10.camel@lade.trondhjem.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Return-path: Received: from smtp.osdl.org ([65.172.181.4]:37251 "EHLO smtp.osdl.org") by vger.kernel.org with ESMTP id S1751305AbWC3AjH (ORCPT ); Wed, 29 Mar 2006 19:39:07 -0500 To: Trond Myklebust In-Reply-To: <1143651308.8697.10.camel@lade.trondhjem.org> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Trond Myklebust wrote: > > - unlock_kernel(); > > - if (new_fl->fl_type == F_UNLCK) > - return 0; > + if (request->fl_type == F_UNLCK) > + goto out; > > + new_fl = locks_alloc_lock(); > + if (new_fl == NULL) > + goto out; > /* > * If a higher-priority process was blocked on the old file lock, > * give it the opportunity to lock the file. > @@ -769,26 +772,27 @@ static int flock_lock_file(struct file * > if (found) > cond_resched(); > > - lock_kernel(); hm, you've extended lock_kernel() coverage (why? Does this help fix the race??) but we still have a cond_resched() inside the now-newly-locked region. If that cond_resched() drops the bkl, is the race reopened?