From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750862AbdAOA6B (ORCPT ); Sat, 14 Jan 2017 19:58:01 -0500 Received: from gum.cmpxchg.org ([85.214.110.215]:37926 "EHLO gum.cmpxchg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750767AbdAOA6A (ORCPT ); Sat, 14 Jan 2017 19:58:00 -0500 Date: Sat, 14 Jan 2017 19:57:51 -0500 From: Johannes Weiner To: Matthew Wilcox Cc: Matthew Wilcox , Linus Torvalds , Andrew Morton , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] radix-tree: Fix private list warnings Message-ID: <20170115005751.GA28233@cmpxchg.org> References: <1484270903-24307-1-git-send-email-mawilcox@linuxonhyperv.com> <20170114154231.GA26139@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jan 14, 2017 at 09:31:51PM +0000, Matthew Wilcox wrote: > From: Johannes Weiner [mailto:hannes@cmpxchg.org] > > On Thu, Jan 12, 2017 at 05:28:23PM -0800, Matthew Wilcox wrote: > > > The newly introduced warning in radix_tree_free_nodes() was testing the > > > wrong variable; it should have been 'old' instead of 'node'. Rather > > > than replace that one instance, I noticed that we can simply put the > > > WARN_ON_ONCE in radix_tree_node_free() and it will be just as effective. > > > > > > Fixes: ea07b862ac8e ("mm: workingset: fix use-after-free in shadow node > > shrinker") > > > Signed-off-by: Matthew Wilcox > > > > Thanks for the fix in radix_tree_free_nodes(). But I intentionally > > spread out the warnings to retain the line numbers. The inlining in > > that code will obscure which tree operation ends up triggering. > > The backtrace should make that fairly obvious though; even if > radix_tree_node_free() gets inlined, the caller of > radix_tree_free_nodes() probably doesn't also call > radix_tree_shrink() or delete_node(). You're really looking for the > caller in the backtrace that's outside of radix-tree.c. Distinguishing between the radix_tree_shrink() and the delete_node() sites was essential to find the bug whose fix added these warnings. The former gets inlined into the latter. Not impossible to figure out which one triggered from a full dump, but certainly less robust. > By the way, if you'd run the radix tree test-suite, the WARN_ON_ONCE > would have triggered (that's how I spotted the bug). The test-suite > is getting pretty useful these days; would you mind running it in > future? Thanks, I'll keep that in mind for future radix tree changes.