linux/include
Maxim Mikityanskiy 94ce3b64c6 net/tls: Use RCU API to access tls_ctx->netdev
Currently, tls_device_down synchronizes with tls_device_resync_rx using
RCU, however, the pointer to netdev is stored using WRITE_ONCE and
loaded using READ_ONCE.

Although such approach is technically correct (rcu_dereference is
essentially a READ_ONCE, and rcu_assign_pointer uses WRITE_ONCE to store
NULL), using special RCU helpers for pointers is more valid, as it
includes additional checks and might change the implementation
transparently to the callers.

Mark the netdev pointer as __rcu and use the correct RCU helpers to
access it. For non-concurrent access pass the right conditions that
guarantee safe access (locks taken, refcount value). Also use the
correct helper in mlx5e, where even READ_ONCE was missing.

The transition to RCU exposes existing issues, fixed by this commit:

1. bond_tls_device_xmit could read netdev twice, and it could become
NULL the second time, after the NULL check passed.

2. Drivers shouldn't stop processing the last packet if tls_device_down
just set netdev to NULL, before tls_dev_del was called. This prevents a
possible packet drop when transitioning to the fallback software mode.

Fixes: 89df6a8104 ("net/bonding: Implement TLS TX device offload")
Fixes: c55dcdd435 ("net/tls: Fix use-after-free after the TLS device goes down and up")
Signed-off-by: Maxim Mikityanskiy <maximmi@nvidia.com>
Link: https://lore.kernel.org/r/20220810081602.1435800-1-maximmi@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2022-08-10 22:58:43 -07:00
..
acpi Merge branches 'acpi-processor', 'acpi-apei' and 'acpi-ec' 2022-07-29 20:08:25 +02:00
asm-generic Random number generator updates for Linux 6.0-rc1. 2022-08-02 17:31:35 -07:00
clocksource - Add the missing DT bindings for the MTU nomadik timer (Linus 2022-07-28 12:33:34 +02:00
crypto crypto: aria - Implement ARIA symmetric cipher algorithm 2022-07-15 16:38:19 +08:00
drm drm/scheduler: Don't kill jobs in interrupt context 2022-07-15 10:09:15 -04:00
dt-bindings ARM: new SoC support for 6.0 2022-08-02 08:29:18 -07:00
keys
kunit kunit: flatten kunit_suite*** to kunit_suite** in .kunit_test_suites 2022-07-11 17:13:15 -06:00
kvm
linux Merge https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf 2022-08-10 21:48:15 -07:00
math-emu
media
memory
misc
net net/tls: Use RCU API to access tls_ctx->netdev 2022-08-10 22:58:43 -07:00
pcmcia
ras
rdma
scsi scsi/core: Use the new blk_opf_t type 2022-07-14 12:14:32 -06:00
soc net: dsa: felix: keep reference on entire tc-taprio config 2022-06-30 21:18:15 -07:00
sound
target
trace Networking changes for 6.0. 2022-08-03 16:29:08 -07:00
uapi genetlink: correct uAPI defines 2022-08-10 13:49:50 +01:00
ufs
vdso
video video: of_display_timing.h: include errno.h 2022-07-06 17:16:20 +02:00
xen