4c05976d2e5f69387811aa861757595a2f69ec29
[openwrt/staging/wigyori.git] /
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()
5
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
9 mtu values.")
10
11 We read dev->mtu without holding RTNL in many places,
12 with READ_ONCE() annotations.
13
14 It is time to take care of ndo_change_mtu() methods
15 to use corresponding WRITE_ONCE()
16
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>
26 ---
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(-)
30
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
34
35 /* if network interface not up, no need for complexity */
36 if (!netif_running(dev)) {
37 - dev->mtu = new_mtu;
38 + WRITE_ONCE(dev->mtu, new_mtu);
39 cp_set_rxbufsize(cp); /* set new rx buf size */
40 return 0;
41 }
42
43 /* network IS up, close it, reset MTU, and come up again. */
44 cp_close(dev);
45 - dev->mtu = new_mtu;
46 + WRITE_ONCE(dev->mtu, new_mtu);
47 cp_set_rxbufsize(cp);
48 return cp_open(dev);
49 }
50 --- a/drivers/net/ethernet/realtek/r8169_main.c
51 +++ b/drivers/net/ethernet/realtek/r8169_main.c
52 @@ -3952,7 +3952,7 @@ static int rtl8169_change_mtu(struct net
53 {
54 struct rtl8169_private *tp = netdev_priv(dev);
55
56 - dev->mtu = new_mtu;
57 + WRITE_ONCE(dev->mtu, new_mtu);
58 netdev_update_features(dev);
59 rtl_jumbo_config(tp);
60 rtl_set_eee_txidle_timer(tp);