linux/drivers/net
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
..
appletalk
arcnet
bonding net/tls: Use RCU API to access tls_ctx->netdev 2022-08-10 22:58:43 -07:00
caif caif_virtio: fix race between virtio_device_ready() and ndo_open() 2022-06-27 08:04:30 -04:00
can can: mcp251x: Fix race condition on receive interrupt 2022-08-09 21:40:22 +02:00
dsa net: dsa: felix: suppress non-changes to the tagging protocol 2022-08-09 12:13:03 -07:00
ethernet net/tls: Use RCU API to access tls_ctx->netdev 2022-08-10 22:58:43 -07:00
fddi fddi/skfp: fix repeated words in comments 2022-07-11 14:12:54 +01:00
fjes
hamradio hamradio: 6pack: fix array-index-out-of-bounds in decode_std_command() 2022-06-17 11:39:46 +01:00
hippi
hyperv
ieee802154
ipa Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-07-28 18:21:16 -07:00
ipvlan ipvlan: adopt u64_stats_t 2022-06-09 21:53:10 -07:00
mctp
mdio
netdevsim Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-08-03 09:04:55 +02:00
pcs Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-07-28 18:21:16 -07:00
phy net: phy: dp83867: fix get nvmem cell fail 2022-08-08 20:57:03 -07:00
plip plip: avoid rcu debug splat 2022-08-09 12:16:02 -07:00
ppp ppp: Fix typo in comment 2022-06-17 20:17:04 -07:00
slip
team team: adopt u64_stats_t 2022-06-09 21:53:12 -07:00
usb Revert "net: usb: ax88179_178a needs FLAG_SEND_ZLP" 2022-08-10 09:28:56 +01:00
vmxnet3 vmxnet3: do not reschedule napi for rx processing 2022-07-29 12:11:23 +01:00
vxlan vxlan: do not use RT_TOS for IPv6 flowlabel 2022-08-09 22:19:20 -07:00
wan
wireguard wireguard: allowedips: don't corrupt stack when detecting overflow 2022-08-02 13:47:50 -07:00
wireless wifi: wilc1000: fix spurious inline in wilc_handle_disconnect() 2022-08-08 11:11:04 +03:00
wwan
xen-netback Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-07-14 15:27:35 -07:00
amt.c amt: fix typo in comment 2022-07-28 22:21:51 -07:00
bareudp.c
dummy.c
eql.c net: rename reference+tracking helpers 2022-06-09 21:52:55 -07:00
geneve.c geneve: do not use RT_TOS for IPv6 flowlabel 2022-08-09 22:19:20 -07:00
gtp.c
ifb.c
Kconfig Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-07-07 12:07:37 -07:00
LICENSE.SRC
loopback.c
macsec.c macsec: Fix traffic counters/statistics 2022-08-10 13:45:06 +01:00
macvlan.c vlan: adopt u64_stats_t 2022-06-09 21:53:09 -07:00
macvtap.c
Makefile
mdio.c
mhi_net.c
mii.c
net_failover.c
netconsole.c net: rename reference+tracking helpers 2022-06-09 21:52:55 -07:00
nlmon.c
ntb_netdev.c
rionet.c
sb1000.c
Space.c
sungem_phy.c net: sungem_phy: Add of_node_put() for reference returned by of_get_parent() 2022-07-21 19:04:19 -07:00
tap.c net: tap: NULL pointer derefence in dev_parse_header_protocol when skb->dev is null 2022-08-05 08:56:35 +01:00
thunderbolt.c
tun.c net: tun: avoid disabling NAPI twice 2022-06-30 11:34:10 -07:00
veth.c Revert "veth: Add updating of trans_start" 2022-08-03 19:20:13 -07:00
virtio_net.c virtio_net: fix memory leak inside XPD_TX with mergeable 2022-08-08 09:43:55 +01:00
vrf.c xfrm: no need to set DST_NOPOLICY in IPv4 2022-06-10 11:01:36 +02:00
vsockmon.c
xen-netfront.c xen-netfront: re-order error checks in xennet_get_responses() 2022-07-14 12:20:18 +02:00