Skip to content

Commit 62b4011

Browse files
sherllydavem330
authored andcommitted
net/tls: Fix sk_psock refcnt leak when in tls_data_ready()
tls_data_ready() invokes sk_psock_get(), which returns a reference of the specified sk_psock object to "psock" with increased refcnt. When tls_data_ready() returns, local variable "psock" becomes invalid, so the refcount should be decreased to keep refcount balanced. The reference counting issue happens in one exception handling path of tls_data_ready(). When "psock->ingress_msg" is empty but "psock" is not NULL, the function forgets to decrease the refcnt increased by sk_psock_get(), causing a refcnt leak. Fix this issue by calling sk_psock_put() on all paths when "psock" is not NULL. Signed-off-by: Xiyu Yang <[email protected]> Signed-off-by: Xin Tan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4becb7e commit 62b4011

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/tls/tls_sw.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2083,8 +2083,9 @@ static void tls_data_ready(struct sock *sk)
20832083
strp_data_ready(&ctx->strp);
20842084

20852085
psock = sk_psock_get(sk);
2086-
if (psock && !list_empty(&psock->ingress_msg)) {
2087-
ctx->saved_data_ready(sk);
2086+
if (psock) {
2087+
if (!list_empty(&psock->ingress_msg))
2088+
ctx->saved_data_ready(sk);
20882089
sk_psock_put(sk, psock);
20892090
}
20902091
}

0 commit comments

Comments
 (0)