* [PATCH] tipc: Fix potential tipc_aead refcnt leak in tipc_crypto_rcv
@ 2020-04-15 8:39 Xiyu Yang
2020-04-18 20:18 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Xiyu Yang @ 2020-04-15 8:39 UTC (permalink / raw)
To: Jon Maloy, Ying Xue, David S. Miller, Jakub Kicinski, netdev,
tipc-discussion, linux-kernel
Cc: yuanxzhang, kjlu, Xiyu Yang, Xin Tan
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>
---
net/tipc/crypto.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/tipc/crypto.c b/net/tipc/crypto.c
index c8c47fc72653..8c47ded2edb6 100644
--- a/net/tipc/crypto.c
+++ b/net/tipc/crypto.c
@@ -1712,6 +1712,7 @@ int tipc_crypto_rcv(struct net *net, struct tipc_crypto *rx,
case -EBUSY:
this_cpu_inc(stats->stat[STAT_ASYNC]);
*skb = NULL;
+ tipc_aead_put(aead);
return rc;
default:
this_cpu_inc(stats->stat[STAT_NOK]);
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tipc: Fix potential tipc_aead refcnt leak in tipc_crypto_rcv
2020-04-15 8:39 [PATCH] tipc: Fix potential tipc_aead refcnt leak in tipc_crypto_rcv Xiyu Yang
@ 2020-04-18 20:18 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-04-18 20:18 UTC (permalink / raw)
To: xiyuyang19
Cc: jmaloy, ying.xue, kuba, netdev, tipc-discussion, linux-kernel,
yuanxzhang, kjlu, tanxin.ctf
From: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Date: Wed, 15 Apr 2020 16:39:56 +0800
> 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>
Applied and queued up for -stable.
This code is harder to audit than it needs to be due to the special
casing of things like -ENOKEY etc. It should rather explicitly handle
the NULL test on aead in this top-level piece of code, which would
make the validation of aead reference counting much more explicit and
clear.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-18 20:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-15 8:39 [PATCH] tipc: Fix potential tipc_aead refcnt leak in tipc_crypto_rcv Xiyu Yang
2020-04-18 20:18 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.