From: David Miller Subject: Re: [net 1/1] tipc: fix use-after-free in tipc_nametbl_stop Date: Wed, 18 Apr 2018 13:48:58 -0400 (EDT) Message-ID: <20180418.134858.507740622493599561.davem@davemloft.net> References: <1523993142-7202-1-git-send-email-jon.maloy@ericsson.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, mohan.krishna.ghanta.krishnamurthy@ericsson.com, tung.q.nguyen@dektech.com.au, hoang.h.le@dektech.com.au, canh.d.luu@dektech.com.au, ying.xue@windriver.com, tipc-discussion@lists.sourceforge.net To: jon.maloy@ericsson.com Return-path: Received: from shards.monkeyblade.net ([184.105.139.130]:46080 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752568AbeDRRtB (ORCPT ); Wed, 18 Apr 2018 13:49:01 -0400 In-Reply-To: <1523993142-7202-1-git-send-email-jon.maloy@ericsson.com> Sender: netdev-owner@vger.kernel.org List-ID: From: Jon Maloy Date: Tue, 17 Apr 2018 21:25:42 +0200 > When we delete a service item in tipc_nametbl_stop() we loop over > all service ranges in the service's RB tree, and for each service > range we loop over its pertaining publications while calling > tipc_service_remove_publ() for each of them. > > However, tipc_service_remove_publ() has the side effect that it also > removes the comprising service range item when there are no publications > left. This leads to a "use-after-free" access when the inner loop > continues to the next iteration, since the range item holding the list > we are looping no longer exists. > > We fix this by moving the delete of the service range item outside > the said function. Instead, we now let the two functions calling it > test if the list is empty and perform the removal when that is the > case. > > Reported-by: syzbot+d64b64afc55660106556@syzkaller.appspotmail.com > Signed-off-by: Jon Maloy Applied.