While reading sysctl_ip_dynaddr, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers.
Unified · Split
| @@ -1179,7 +1179,7 @@ ip_autobind_reuse - BOOLEAN · 1178 unmodified lines | |||
| 1179 | option should only be set by experts. | 1179 | option should only be set by experts. |
| 1180 | Default: 0 | 1180 | Default: 0 |
| 1181 | 1181 | ||
| 1182 | ip_dynaddr - BOOLEAN | 1182 | ip_dynaddr - INTEGER |
| 1183 | If set non-zero, enables support for dynamic addresses. | 1183 | If set non-zero, enables support for dynamic addresses. |
| 1184 | If set to a non-zero value larger than 1, a kernel log | 1184 | If set to a non-zero value larger than 1, a kernel log |
| 1185 | message will be printed when dynamic address rewriting | 1185 | message will be printed when dynamic address rewriting |
| @@ -1246,7 +1246,7 @@ static int inet_sk_reselect_saddr(struct sock *sk) · 1245 unmodified lines | |||
| 1246 | if (new_saddr == old_saddr) | 1246 | if (new_saddr == old_saddr) |
| 1247 | return 0; | 1247 | return 0; |
| 1248 | 1248 | ||
| 1249 | if (sock_net(sk)->ipv4.sysctl_ip_dynaddr > 1) { | 1249 | if (READ_ONCE(sock_net(sk)->ipv4.sysctl_ip_dynaddr) > 1) { |
| 1250 | pr_info("%s(): shifting inet->saddr from %pI4 to %pI4\n", | 1250 | pr_info("%s(): shifting inet->saddr from %pI4 to %pI4\n", |
| 1251 | __func__, &old_saddr, &new_saddr); | 1251 | __func__, &old_saddr, &new_saddr); |
| 1252 | } | 1252 | } |
| @@ -1301,7 +1301,7 @@ int inet_sk_rebuild_header(struct sock *sk) · 48 unmodified lines | |||
| 1301 | * Other protocols have to map its equivalent state to TCP_SYN_SENT. | 1301 | * Other protocols have to map its equivalent state to TCP_SYN_SENT. |
| 1302 | * DCCP maps its DCCP_REQUESTING state to TCP_SYN_SENT. -acme | 1302 | * DCCP maps its DCCP_REQUESTING state to TCP_SYN_SENT. -acme |
| 1303 | */ | 1303 | */ |
| 1304 | if (!sock_net(sk)->ipv4.sysctl_ip_dynaddr || | 1304 | if (!READ_ONCE(sock_net(sk)->ipv4.sysctl_ip_dynaddr) || |
| 1305 | sk->sk_state != TCP_SYN_SENT || | 1305 | sk->sk_state != TCP_SYN_SENT || |
| 1306 | (sk->sk_userlocks & SOCK_BINDADDR_LOCK) || | 1306 | (sk->sk_userlocks & SOCK_BINDADDR_LOCK) || |
| 1307 | (err = inet_sk_reselect_saddr(sk)) != 0) | 1307 | (err = inet_sk_reselect_saddr(sk)) != 0) |