]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
crypto: af_alg - Disallow bind/setkey/... after accept(2)
authorHerbert Xu <herbert@gondor.apana.org.au>
Wed, 30 Dec 2015 03:47:53 +0000 (11:47 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 19 Feb 2016 22:28:35 +0000 (14:28 -0800)
commit44566ad6cb5d72f5018443923d66b30e86765080
treeb6d3a8b66ad906366bc1c38444fbce6000dc7da5
parentca3b842758312a5a3d7e1dc21ab451f03912cc27
crypto: af_alg - Disallow bind/setkey/... after accept(2)

commit c840ac6af3f8713a71b4d2363419145760bd6044 upstream.

Each af_alg parent socket obtained by socket(2) corresponds to a
tfm object once bind(2) has succeeded.  An accept(2) call on that
parent socket creates a context which then uses the tfm object.

Therefore as long as any child sockets created by accept(2) exist
the parent socket must not be modified or freed.

This patch guarantees this by using locks and a reference count
on the parent socket.  Any attempt to modify the parent socket will
fail with EBUSY.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
crypto/af_alg.c
include/crypto/if_alg.h