af_key: Add lock to key dump
authorYuejie Shi <syjcnss@gmail.com>
Fri, 31 Mar 2017 07:10:20 +0000 (15:10 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 7 Aug 2017 01:59:39 +0000 (18:59 -0700)
commit0f94b36de37c73bdb3affe7352acac819082d360
tree59357393d8f6ccddce04e6fd75757867ab0d5f95
parentefcfbfb1d8bf756d1b58fe215bf4e419d176435b
af_key: Add lock to key dump

commit 89e357d83c06b6fac581c3ca7f0ee3ae7e67109e upstream.

A dump may come in the middle of another dump, modifying its dump
structure members. This race condition will result in NULL pointer
dereference in kernel. So add a lock to prevent that race.

Fixes: 83321d6b9872 ("[AF_KEY]: Dump SA/SP entries non-atomically")
Signed-off-by: Yuejie Shi <syjcnss@gmail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Mark Salyzyn <salyzyn@android.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/key/af_key.c