From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:44972 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932189AbdJ3OPY (ORCPT ); Mon, 30 Oct 2017 10:15:24 -0400 Subject: Re: [PATCH v7 10/10] lib/dlock-list: Fix use-after-unlock problem in dlist_for_each_entry_safe() To: Davidlohr Bueso Cc: Alexander Viro , Jan Kara , Jeff Layton , "J. Bruce Fields" , Tejun Heo , Christoph Lameter , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Andi Kleen , Dave Chinner , Boqun Feng References: <1507229008-20569-1-git-send-email-longman@redhat.com> <1509135053-19214-1-git-send-email-longman@redhat.com> <20171030141147.leqcsaxebwiq6dq6@linux-n805> From: Waiman Long Message-ID: <0fc66521-2a5f-1dc3-bd37-784a1435c7a8@redhat.com> Date: Mon, 30 Oct 2017 10:15:04 -0400 MIME-Version: 1.0 In-Reply-To: <20171030141147.leqcsaxebwiq6dq6@linux-n805> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On 10/30/2017 10:11 AM, Davidlohr Bueso wrote: > On Fri, 27 Oct 2017, Waiman Long wrote: > >> The dlist_for_each_entry_safe() macro in include/linux/dlock-list has >> a use-after-unlock problem where racing condition can happen because >> of a lack of spinlock protection. Fortunately, this macro is not >> currently being used in the kernel. >> >> This patch changes the dlist_for_each_entry_safe() macro so that the >> call to __dlock_list_next_list() is deferred until the next entry is >> being used. That should eliminate the use-after-unlock problem. >> >> Reported-by: Boqun Feng >> Signed-off-by: Waiman Long > > Reviewed-by: Davidlohr Bueso > > But would it not be better to merge this patch (among others) into 1/N? > Specifically the newer patches 7-10 should be in the original dlock > implementation instead of adding fixes to incorrect code in the original > commit. Also less of a pita for backporting. > > Thanks, > Davidlohr +191,17 @@ extern void dlock_list_add(struct dlock_list_node > *node, Yes, that is true. I will send out a new version with all the fixes integrated later this week. Cheers, Longman