Skip to content

Commit f1b7f14

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 f19e995 commit f1b7f14

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
@@ -1976,10 +1976,10 @@ int tls_sw_recvmsg(struct sock *sk,
19761976
if (unlikely(flags & MSG_ERRQUEUE))
19771977
return sock_recv_errqueue(sk, msg, len, SOL_IP, IP_RECVERR);
19781978

1979-
psock = sk_psock_get(sk);
19801979
err = tls_rx_reader_lock(sk, ctx, flags & MSG_DONTWAIT);
19811980
if (err < 0)
19821981
return err;
1982+
psock = sk_psock_get(sk);
19831983
bpf_strp_enabled = sk_psock_strp_enabled(psock);
19841984

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

0 commit comments

Comments
 (0)