diff options
| author | Herbert Xu <herbert@gondor.apana.org.au> | 2020-06-08 16:48:43 +1000 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-07-09 09:37:10 +0200 |
| commit | 9a8ecc6a3ebe625eddd6e96f419762b198de93ce (patch) | |
| tree | e94169780446b816056a39d4b3623e8eaf1c14e0 /include | |
| parent | a464152c184dde346628114659bd6729c5f75c8f (diff) | |
| download | linux-9a8ecc6a3ebe625eddd6e96f419762b198de93ce.tar.gz linux-9a8ecc6a3ebe625eddd6e96f419762b198de93ce.tar.bz2 linux-9a8ecc6a3ebe625eddd6e96f419762b198de93ce.zip | |
crypto: af_alg - fix use-after-free in af_alg_accept() due to bh_lock_sock()
commit 34c86f4c4a7be3b3e35aa48bd18299d4c756064d upstream.
The locking in af_alg_release_parent is broken as the BH socket
lock can only be taken if there is a code-path to handle the case
where the lock is owned by process-context. Instead of adding
such handling, we can fix this by changing the ref counts to
atomic_t.
This patch also modifies the main refcnt to include both normal
and nokey sockets. This way we don't have to fudge the nokey
ref count when a socket changes from nokey to normal.
Credits go to Mauricio Faria de Oliveira who diagnosed this bug
and sent a patch for it:
https://lore.kernel.org/linux-crypto/20200605161657.535043-1-mfo@canonical.com/
Reported-by: Brian Moyles <bmoyles@netflix.com>
Reported-by: Mauricio Faria de Oliveira <mfo@canonical.com>
Fixes: 37f96694cf73 ("crypto: af_alg - Use bh_lock_sock in...")
Cc: <stable@vger.kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/crypto/if_alg.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/crypto/if_alg.h b/include/crypto/if_alg.h index 482461d8931d..11f107df78dc 100644 --- a/include/crypto/if_alg.h +++ b/include/crypto/if_alg.h @@ -34,8 +34,8 @@ struct alg_sock { struct sock *parent; - unsigned int refcnt; - unsigned int nokey_refcnt; + atomic_t refcnt; + atomic_t nokey_refcnt; const struct af_alg_type *type; void *private; |
