android_kernel_sony_sdm845/net/tls
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Tariq Toukan 417d710f0d UPSTREAM: net/tls: Fix race in TLS device down flow
[ Upstream commit f08d8c1bb97c48f24a82afaa2fd8c140f8d3da8b ]

Socket destruction flow and tls_device_down function sync against each
other using tls_device_lock and the context refcount, to guarantee the
device resources are freed via tls_dev_del() by the end of
tls_device_down.

In the following unfortunate flow, this won't happen:
- refcount is decreased to zero in tls_device_sk_destruct.
- tls_device_down starts, skips the context as refcount is zero, going
  all the way until it flushes the gc work, and returns without freeing
  the device resources.
- only then, tls_device_queue_ctx_destruction is called, queues the gc
  work and frees the context's device resources.

Solve it by decreasing the refcount in the socket's destruction flow
under the tls_device_lock, for perfect synchronization.  This does not
slow down the common likely destructor flow, in which both the refcount
is decreased and the spinlock is acquired, anyway.

Fixes: e8f69799810c ("net/tls: Add generic NIC offload infrastructure")
Reviewed-by: Maxim Mikityanskiy <maximmi@nvidia.com>
Change-Id: I81919a18b1266192315018bd3fd6f24270f3d02d
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Sorayukii <sorayukii69@gmail.com>
2026-05-15 17:58:36 +07:00
..
Kconfig UPSTREAM: net/tls: Add generic NIC offload infrastructure 2026-05-15 17:58:23 +07:00
Makefile UPSTREAM: net/tls: Add generic NIC offload infrastructure 2026-05-15 17:58:23 +07:00
tls_device.c UPSTREAM: net/tls: Fix race in TLS device down flow 2026-05-15 17:58:36 +07:00
tls_device_fallback.c UPSTREAM: net/tls: fix socket wmem accounting on fallback with netem 2026-05-15 17:58:35 +07:00
tls_main.c UPSTREAM: net: tls, fix sk_write_space NULL write when tx disabled 2026-05-15 17:58:35 +07:00
tls_sw.c UPSTREAM: net/tls: missing received data after fast remote close 2026-05-15 17:58:35 +07:00