1 From 1eb2cded45b35816085c1f962933c187d970f9dc Mon Sep 17 00:00:00 2001
2 From: Eric Dumazet <edumazet@google.com>
3 Date: Mon, 6 May 2024 10:28:12 +0000
4 Subject: [PATCH] net: annotate writes on dev->mtu from ndo_change_mtu()
6 Simon reported that ndo_change_mtu() methods were never
7 updated to use WRITE_ONCE(dev->mtu, new_mtu) as hinted
8 in commit 501a90c94510 ("inet: protect against too small
11 We read dev->mtu without holding RTNL in many places,
12 with READ_ONCE() annotations.
14 It is time to take care of ndo_change_mtu() methods
15 to use corresponding WRITE_ONCE()
17 Signed-off-by: Eric Dumazet <edumazet@google.com>
18 Reported-by: Simon Horman <horms@kernel.org>
19 Closes: https://lore.kernel.org/netdev/20240505144608.GB67882@kernel.org/
20 Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
21 Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
22 Reviewed-by: Simon Horman <horms@kernel.org>
23 Acked-by: Shannon Nelson <shannon.nelson@amd.com>
24 Link: https://lore.kernel.org/r/20240506102812.3025432-1-edumazet@google.com
25 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
27 drivers/net/ethernet/realtek/8139cp.c | 4 ++--
28 drivers/net/ethernet/realtek/r8169_main.c | 2 +-
29 2 files changed, 3 insertions(+), 3 deletions(-)
31 --- a/drivers/net/ethernet/realtek/8139cp.c
32 +++ b/drivers/net/ethernet/realtek/8139cp.c
33 @@ -1277,14 +1277,14 @@ static int cp_change_mtu(struct net_devi
35 /* if network interface not up, no need for complexity */
36 if (!netif_running(dev)) {
38 + WRITE_ONCE(dev->mtu, new_mtu);
39 cp_set_rxbufsize(cp); /* set new rx buf size */
43 /* network IS up, close it, reset MTU, and come up again. */
46 + WRITE_ONCE(dev->mtu, new_mtu);
50 --- a/drivers/net/ethernet/realtek/r8169_main.c
51 +++ b/drivers/net/ethernet/realtek/r8169_main.c
52 @@ -3925,7 +3925,7 @@ static int rtl8169_change_mtu(struct net
54 struct rtl8169_private *tp = netdev_priv(dev);
57 + WRITE_ONCE(dev->mtu, new_mtu);
58 netdev_update_features(dev);
60 rtl_set_eee_txidle_timer(tp);