Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1684080

Re: [PATCH] slub: make sure struct kmem_cache_node is initialized before publication

From Alexander Potapenko <glider@google.com>
Newsgroups linux.kernel
Subject Re: [PATCH] slub: make sure struct kmem_cache_node is initialized before publication
Date 2017-07-10 11:30 +0200
Message-ID <u1DaV-3af-1@gated-at.bofh.it> (permalink)
References <u0wXT-1kR-3@gated-at.bofh.it> <u0I2Z-DO-7@gated-at.bofh.it> <u0KHv-2xj-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sat, Jul 8, 2017 at 1:18 AM, Christoph Lameter <cl@linux.com> wrote:
> On Fri, 7 Jul 2017, Andrew Morton wrote:
>
>> On Fri,  7 Jul 2017 10:34:08 +0200 Alexander Potapenko <glider@google.com> 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():
>
> At creation time the kmem_cache structure is private and no one can run a
> free operation.
>
>> Inviting a use-after-free?  I guess not, as there should be no way
>> to look up these items at this stage.
>
> Right.
>
>> Could the slab maintainers please take a look at these and also have a
>> think about Alexander's READ_ONCE/WRITE_ONCE question?
>
> Was I cced on these?
I've asked Andrew about READ_ONCE privately.
My concern is as follows.
Since unfreeze_partials() sees uninitialized value of n->list_lock, I
was suspecting there's a data race between unfreeze_partials() and
init_kmem_cache_nodes().
If so, reads and writes to s->node[node] must be acquire/release
atomics (not actually READ_ONCE/WRITE_ONCE, but
smp_load_acquire/smp_store_release).




-- 
Alexander Potapenko
Software Engineer

Google Germany GmbH
Erika-Mann-Straße, 33
80636 München

Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] slub: make sure struct kmem_cache_node is initialized before publication Alexander Potapenko <glider@google.com> - 2017-07-07 10:40 +0200
  Re: [PATCH] slub: make sure struct kmem_cache_node is initialized  before publication Alexander Potapenko <glider@google.com> - 2017-07-07 10:50 +0200
  Re: [PATCH] slub: make sure struct kmem_cache_node is initialized  before publication Andrew Morton <akpm@linux-foundation.org> - 2017-07-07 22:30 +0200
    Re: [PATCH] slub: make sure struct kmem_cache_node is initialized  before publication Christoph Lameter <cl@linux.com> - 2017-07-08 01:20 +0200
      Re: [PATCH] slub: make sure struct kmem_cache_node is initialized  before publication Alexander Potapenko <glider@google.com> - 2017-07-10 11:30 +0200
        Re: [PATCH] slub: make sure struct kmem_cache_node is initialized  before publication Christoph Lameter <cl@linux.com> - 2017-07-10 17:40 +0200
      Re: [PATCH] slub: make sure struct kmem_cache_node is initialized  before publication Andrew Morton <akpm@linux-foundation.org> - 2017-07-10 22:40 +0200
        Re: [PATCH] slub: make sure struct kmem_cache_node is initialized  before publication Alexander Potapenko <glider@google.com> - 2017-07-12 16:20 +0200
          Re: [PATCH] slub: make sure struct kmem_cache_node is initialized  before publication Andrew Morton <akpm@linux-foundation.org> - 2017-07-12 21:30 +0200
            Re: [PATCH] slub: make sure struct kmem_cache_node is initialized  before publication Christopher Lameter <cl@linux.com> - 2017-07-12 22:00 +0200

csiph-web