@@ -282,7 +282,7 @@ static bool icmpv4_mask_allow(struct net *net, int type, int code)
282282 return true;
283283
284284 /* Limit if icmp type is enabled in ratemask. */
285- if (!((1 << type ) & net -> ipv4 .sysctl_icmp_ratemask ))
285+ if (!((1 << type ) & READ_ONCE ( net -> ipv4 .sysctl_icmp_ratemask ) ))
286286 return true;
287287
288288 return false;
@@ -320,7 +320,8 @@ static bool icmpv4_xrlim_allow(struct net *net, struct rtable *rt,
320320
321321 vif = l3mdev_master_ifindex (dst -> dev );
322322 peer = inet_getpeer_v4 (net -> ipv4 .peers , fl4 -> daddr , vif , 1 );
323- rc = inet_peer_xrlim_allow (peer , net -> ipv4 .sysctl_icmp_ratelimit );
323+ rc = inet_peer_xrlim_allow (peer ,
324+ READ_ONCE (net -> ipv4 .sysctl_icmp_ratelimit ));
324325 if (peer )
325326 inet_putpeer (peer );
326327out :
@@ -693,7 +694,7 @@ void __icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info,
693694
694695 rcu_read_lock ();
695696 if (rt_is_input_route (rt ) &&
696- net -> ipv4 .sysctl_icmp_errors_use_inbound_ifaddr )
697+ READ_ONCE ( net -> ipv4 .sysctl_icmp_errors_use_inbound_ifaddr ) )
697698 dev = dev_get_by_index_rcu (net , inet_iif (skb_in ));
698699
699700 if (dev )
@@ -933,7 +934,7 @@ static enum skb_drop_reason icmp_unreach(struct sk_buff *skb)
933934 * get the other vendor to fix their kit.
934935 */
935936
936- if (!net -> ipv4 .sysctl_icmp_ignore_bogus_error_responses &&
937+ if (!READ_ONCE ( net -> ipv4 .sysctl_icmp_ignore_bogus_error_responses ) &&
937938 inet_addr_type_dev_table (net , skb -> dev , iph -> daddr ) == RTN_BROADCAST ) {
938939 net_warn_ratelimited ("%pI4 sent an invalid ICMP type %u, code %u error to a broadcast: %pI4 on %s\n" ,
939940 & ip_hdr (skb )-> saddr ,
@@ -993,7 +994,7 @@ static enum skb_drop_reason icmp_echo(struct sk_buff *skb)
993994
994995 net = dev_net (skb_dst (skb )-> dev );
995996 /* should there be an ICMP stat for ignored echos? */
996- if (net -> ipv4 .sysctl_icmp_echo_ignore_all )
997+ if (READ_ONCE ( net -> ipv4 .sysctl_icmp_echo_ignore_all ) )
997998 return SKB_NOT_DROPPED_YET ;
998999
9991000 icmp_param .data .icmph = * icmp_hdr (skb );
@@ -1028,7 +1029,7 @@ bool icmp_build_probe(struct sk_buff *skb, struct icmphdr *icmphdr)
10281029 u16 ident_len ;
10291030 u8 status ;
10301031
1031- if (!net -> ipv4 .sysctl_icmp_echo_enable_probe )
1032+ if (!READ_ONCE ( net -> ipv4 .sysctl_icmp_echo_enable_probe ) )
10321033 return false;
10331034
10341035 /* We currently only support probing interfaces on the proxy node
@@ -1249,7 +1250,7 @@ int icmp_rcv(struct sk_buff *skb)
12491250 */
12501251 if ((icmph -> type == ICMP_ECHO ||
12511252 icmph -> type == ICMP_TIMESTAMP ) &&
1252- net -> ipv4 .sysctl_icmp_echo_ignore_broadcasts ) {
1253+ READ_ONCE ( net -> ipv4 .sysctl_icmp_echo_ignore_broadcasts ) ) {
12531254 reason = SKB_DROP_REASON_INVALID_PROTO ;
12541255 goto error ;
12551256 }
0 commit comments