af_key: Add lock to key dump
authorYuejie Shi <syjcnss@gmail.com>
Fri, 31 Mar 2017 07:10:20 +0000 (15:10 +0800)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 18 Jul 2017 17:38:40 +0000 (18:38 +0100)
commit02085b1734f1bdc3ad5d7159c6a115be207946e5
tree4ff52384cc39aece4bc5756d877b8ea6db86055e
parent4c68c4f78e65dada597269ae8995736b7a736007
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>
[bwh: Backported to 3.2:
 - pfkey_dump() doesn't support filters
 - Adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
net/key/af_key.c