mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
net/tcp_sigpool: Use kref_get_unless_zero()
commitb901a4e276upstream. The freeing and re-allocation of algorithm are protected by cpool_mutex, so it doesn't fix an actual use-after-free, but avoids a deserved refcount_warn_saturate() warning. A trivial fix for the racy behavior. Fixes:8c73b26315("net/tcp: Prepare tcp_md5sig_pool for TCP-AO") Suggested-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Dmitry Safonov <dima@arista.com> Tested-by: Bagas Sanjaya <bagasdotme@gmail.com> Reported-by: syzbot <syzkaller@googlegroups.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
0490d0b862
commit
2ee4194be0
@@ -162,9 +162,8 @@ int tcp_sigpool_alloc_ahash(const char *alg, size_t scratch_size)
|
||||
if (strcmp(cpool[i].alg, alg))
|
||||
continue;
|
||||
|
||||
if (kref_read(&cpool[i].kref) > 0)
|
||||
kref_get(&cpool[i].kref);
|
||||
else
|
||||
/* pairs with tcp_sigpool_release() */
|
||||
if (!kref_get_unless_zero(&cpool[i].kref))
|
||||
kref_init(&cpool[i].kref);
|
||||
ret = i;
|
||||
goto out;
|
||||
|
||||
Reference in New Issue
Block a user