]> git.baikalelectronics.ru Git - kernel.git/commit
tipc: Fix potential tipc_aead refcnt leak in tipc_crypto_rcv
authorXiyu Yang <xiyuyang19@fudan.edu.cn>
Wed, 15 Apr 2020 08:39:56 +0000 (16:39 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 18 Apr 2020 20:17:04 +0000 (13:17 -0700)
commitc78f22ce19a71fb57826bf852a868c92e3363f3a
tree51f978e622ce9337532be2ee78ea093f27c3b9f9
parentd990fd27b4586da892d38fb49123e3ab0d073b57
tipc: Fix potential tipc_aead refcnt leak in tipc_crypto_rcv

tipc_crypto_rcv() invokes tipc_aead_get(), which returns a reference of
the tipc_aead object to "aead" with increased refcnt.

When tipc_crypto_rcv() returns, the original local reference of "aead"
becomes invalid, so the refcount should be decreased to keep refcount
balanced.

The issue happens in one error path of tipc_crypto_rcv(). When TIPC
message decryption status is EINPROGRESS or EBUSY, the function forgets
to decrease the refcnt increased by tipc_aead_get() and causes a refcnt
leak.

Fix this issue by calling tipc_aead_put() on the error path when TIPC
message decryption status is EINPROGRESS or EBUSY.

Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/crypto.c