Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752593AbdGGUXy (ORCPT ); Fri, 7 Jul 2017 16:23:54 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37144 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752553AbdGGUXx (ORCPT ); Fri, 7 Jul 2017 16:23:53 -0400 Date: Fri, 7 Jul 2017 13:23:51 -0700 From: Andrew Morton To: Alexander Potapenko Cc: dvyukov@google.com, kcc@google.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Pekka Enberg , David Rientjes , Christoph Lameter , Joonsoo Kim Subject: Re: [PATCH] slub: make sure struct kmem_cache_node is initialized before publication Message-Id: <20170707132351.4f10cd778fc5eb58e9cc5513@linux-foundation.org> In-Reply-To: <20170707083408.40410-1-glider@google.com> References: <20170707083408.40410-1-glider@google.com> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 841 Lines: 33 On Fri, 7 Jul 2017 10:34:08 +0200 Alexander Potapenko wrote: > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -3389,8 +3389,8 @@ static int init_kmem_cache_nodes(struct kmem_cache *s) > return 0; > } > > - s->node[node] = n; > init_kmem_cache_node(n); > + s->node[node] = n; > } > return 1; > } If this matters then I have bad feelings about free_kmem_cache_nodes(): static void free_kmem_cache_nodes(struct kmem_cache *s) { int node; struct kmem_cache_node *n; for_each_kmem_cache_node(s, node, n) { kmem_cache_free(kmem_cache_node, n); s->node[node] = NULL; } } Inviting a use-after-free? I guess not, as there should be no way to look up these items at this stage. Could the slab maintainers please take a look at these and also have a think about Alexander's READ_ONCE/WRITE_ONCE question?