Skip to content

Commit 30fabe5

Browse files
qsngregkh
authored andcommitted
tls: get psock ref after taking rxlock to avoid leak
[ Upstream commit 417e91e ] At the start of tls_sw_recvmsg, we take a reference on the psock, and then call tls_rx_reader_lock. If that fails, we return directly without releasing the reference. Instead of adding a new label, just take the reference after locking has succeeded, since we don't need it before. Fixes: 4cbc325 ("tls: rx: allow only one reader at a time") Signed-off-by: Sabrina Dubroca <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://lore.kernel.org/r/fe2ade22d030051ce4c3638704ed58b67d0df643.1711120964.git.sd@queasysnail.net Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent f52c8f1 commit 30fabe5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/tls/tls_sw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2062,10 +2062,10 @@ int tls_sw_recvmsg(struct sock *sk,
20622062
if (unlikely(flags & MSG_ERRQUEUE))
20632063
return sock_recv_errqueue(sk, msg, len, SOL_IP, IP_RECVERR);
20642064

2065-
psock = sk_psock_get(sk);
20662065
err = tls_rx_reader_lock(sk, ctx, flags & MSG_DONTWAIT);
20672066
if (err < 0)
20682067
return err;
2068+
psock = sk_psock_get(sk);
20692069
bpf_strp_enabled = sk_psock_strp_enabled(psock);
20702070

20712071
/* If crypto failed the connection is broken */

0 commit comments

Comments
 (0)