]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit - lib/rhashtable.c
lib: fix data race in rhashtable_rehash_one
authorDmitriy Vyukov <dvyukov@google.com>
Tue, 22 Sep 2015 08:51:52 +0000 (10:51 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 23 Sep 2015 00:36:07 +0000 (17:36 -0700)
commit7def0f952eccdd0edb3c504f4dab35ee0d3aba1f
treeb07b5d821064709d15bf725818ab3e3a751daafe
parent23eedbc2435ddd226717603c4f3c8efec7bdbb4d
lib: fix data race in rhashtable_rehash_one

rhashtable_rehash_one() uses complex logic to update entry->next field,
after INIT_RHT_NULLS_HEAD and NULLS_MARKER expansion:

entry->next = 1 | ((base + off) << 1)

This can be compiled along the lines of:

entry->next = base + off
entry->next <<= 1
entry->next |= 1

Which will break concurrent readers.

NULLS value recomputation is not needed here, so just remove
the complex logic.

The data race was found with KernelThreadSanitizer (KTSAN).

Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
lib/rhashtable.c