aboutsummaryrefslogtreecommitdiff
path: root/net/hsr
diff options
context:
space:
mode:
authorGravatar Eric Dumazet <edumazet@google.com> 2024-05-06 10:28:12 +0000
committerGravatar Jakub Kicinski <kuba@kernel.org> 2024-05-07 16:19:14 -0700
commit1eb2cded45b35816085c1f962933c187d970f9dc (patch)
tree27a26692748d3c69fcd896a10db9bc89c1eb54b5 /net/hsr
parentnet: dccp: Fix ccid2_rtt_estimator() kernel-doc (diff)
downloadlinux-1eb2cded45b35816085c1f962933c187d970f9dc.tar.gz
linux-1eb2cded45b35816085c1f962933c187d970f9dc.tar.bz2
linux-1eb2cded45b35816085c1f962933c187d970f9dc.zip
net: annotate writes on dev->mtu from ndo_change_mtu()
Simon reported that ndo_change_mtu() methods were never updated to use WRITE_ONCE(dev->mtu, new_mtu) as hinted in commit 501a90c94510 ("inet: protect against too small mtu values.") We read dev->mtu without holding RTNL in many places, with READ_ONCE() annotations. It is time to take care of ndo_change_mtu() methods to use corresponding WRITE_ONCE() Signed-off-by: Eric Dumazet <edumazet@google.com> Reported-by: Simon Horman <horms@kernel.org> Closes: https://lore.kernel.org/netdev/20240505144608.GB67882@kernel.org/ Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Reviewed-by: Sabrina Dubroca <sd@queasysnail.net> Reviewed-by: Simon Horman <horms@kernel.org> Acked-by: Shannon Nelson <shannon.nelson@amd.com> Link: https://lore.kernel.org/r/20240506102812.3025432-1-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/hsr')
-rw-r--r--net/hsr/hsr_device.c2
-rw-r--r--net/hsr/hsr_main.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c
index 86127300b102..26d5282a6496 100644
--- a/net/hsr/hsr_device.c
+++ b/net/hsr/hsr_device.c
@@ -123,7 +123,7 @@ static int hsr_dev_change_mtu(struct net_device *dev, int new_mtu)
return -EINVAL;
}
- dev->mtu = new_mtu;
+ WRITE_ONCE(dev->mtu, new_mtu);
return 0;
}
diff --git a/net/hsr/hsr_main.c b/net/hsr/hsr_main.c
index 9756e657bab9..d7ae32473c41 100644
--- a/net/hsr/hsr_main.c
+++ b/net/hsr/hsr_main.c
@@ -96,7 +96,7 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event,
break; /* Handled in ndo_change_mtu() */
mtu_max = hsr_get_max_mtu(port->hsr);
master = hsr_port_get_hsr(port->hsr, HSR_PT_MASTER);
- master->dev->mtu = mtu_max;
+ WRITE_ONCE(master->dev->mtu, mtu_max);
break;
case NETDEV_UNREGISTER:
if (!is_hsr_master(dev)) {