From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Morton Subject: Re: [PATCH 1/3] fsnotify: Fix oops in fsnotify_clear_marks_by_group_flags() Date: Wed, 15 Jul 2015 13:41:15 -0700 Message-ID: <20150715134115.245dff27ab37c746a3ee8a21@linux-foundation.org> References: <1436966481-12517-1-git-send-email-jack@suse.com> <1436966481-12517-2-git-send-email-jack@suse.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org, Jan Kara To: Jan Kara Return-path: Received: from mail.linuxfoundation.org ([140.211.169.12]:55982 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753362AbbGOUlQ (ORCPT ); Wed, 15 Jul 2015 16:41:16 -0400 In-Reply-To: <1436966481-12517-2-git-send-email-jack@suse.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Wed, 15 Jul 2015 15:21:19 +0200 Jan Kara wrote: > fsnotify_clear_marks_by_group_flags() can race with > fsnotify_destroy_marks() so when fsnotify_destroy_mark_locked() drops > mark_mutex, a mark from the list iterated by > fsnotify_clear_marks_by_group_flags() can be freed and we dereference > free memory in the loop there. > > Fix the problem by keeping mark_mutex held in > fsnotify_destroy_mark_locked(). The reason why we drop that mutex is > that we need to call a ->freeing_mark() callback which may acquire > mark_mutex again. To avoid this and similar lock inversion issues, we > move the call to ->freeing_mark() callback to the kthread destroying the > mark. > > Reported-by: Ashish Sangwan > Suggested-by: Lino Sanfilippo > Signed-off-by: Jan Kara I added a cc:stable. Please let me know if you omitted this deliberately.